Beispiel #1
0
        private string VerifyAndResolveVersion(string version)
        {
            // Get the versions either from disk or on the web
            var versionInfo = _versionProvider.GetVersionInfo();

            // Get the default version. This could be having just the major or major.minor version.
            // So try getting the latest version of the default version.
            if (string.IsNullOrEmpty(version))
            {
                version = versionInfo.DefaultVersion;
            }

            var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion(
                version,
                versionInfo.SupportedVersions);

            if (string.IsNullOrEmpty(maxSatisfyingVersion))
            {
                var exc = new UnsupportedVersionException(
                    PythonConstants.PythonName,
                    version,
                    versionInfo.SupportedVersions);
                _logger.LogError(
                    exc,
                    $"Exception caught, the version '{version}' is not supported for the Python platform.");
                throw exc;
            }

            return(maxSatisfyingVersion);
        }
Beispiel #2
0
        public string GetMaxSatisfyingVersionAndVerify(string version)
        {
            var versionInfo          = _versionProvider.GetVersionInfo();
            var maxSatisfyingVersion = SemanticVersionResolver.GetMaxSatisfyingVersion(
                version,
                versionInfo.SupportedVersions);

            if (string.IsNullOrEmpty(maxSatisfyingVersion))
            {
                var exc = new UnsupportedVersionException(
                    PythonConstants.PlatformName,
                    version,
                    versionInfo.SupportedVersions);
                _logger.LogError(
                    exc,
                    $"Exception caught, the version '{version}' is not supported for the Python platform.");
                throw exc;
            }

            return(maxSatisfyingVersion);
        }
Beispiel #3
0
        private string GetVersionUsingHierarchicalRules(string detectedVersion)
        {
            // Explicitly specified version by user wins over detected version
            if (!string.IsNullOrEmpty(_pythonScriptGeneratorOptions.PythonVersion))
            {
                return(_pythonScriptGeneratorOptions.PythonVersion);
            }

            // If a version was detected, then use it.
            if (detectedVersion != null)
            {
                return(detectedVersion);
            }

            // Fallback to default version
            var versionInfo = _versionProvider.GetVersionInfo();

            return(versionInfo.DefaultVersion);
        }
Beispiel #4
0
        private string GetDefaultVersionFromProvider()
        {
            var versionInfo = _versionProvider.GetVersionInfo();

            return(versionInfo.DefaultVersion);
        }