Merge branch 'maintenance' into devel
# Conflicts: # src/octoprint/environment.py
This commit is contained in:
commit
548da0d64f
3 files changed
+31
-5
No files matched your search
@@ -7,7 +7,6 @@ __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import threading
|
||||
import yaml
|
||||
@@ -16,6 +15,7 @@ import psutil
|
||||
|
||||
from octoprint.plugin import EnvironmentDetectionPlugin
|
||||
from octoprint.util.platform import get_os
|
||||
from octoprint.util.version import get_python_version_string
|
||||
|
||||
class EnvironmentDetector(object):
|
||||
|
||||
@@ -70,7 +70,7 @@ class EnvironmentDetector(object):
|
||||
|
||||
# determine python version
|
||||
try:
|
||||
result["version"] = platform.python_version()
|
||||
result["version"] = get_python_version_string()
|
||||
except Exception:
|
||||
self._logger.exception("Error detecting python version")
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ from octoprint.server import VERSION, REVISION, BRANCH
|
||||
from octoprint.access import USER_GROUP, ADMIN_GROUP
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.util import dict_merge, to_unicode
|
||||
from octoprint.util.version import get_comparable_version
|
||||
from octoprint.util.version import get_comparable_version, get_python_version_string
|
||||
from octoprint.util.pip import LocalPipCaller
|
||||
import octoprint.settings
|
||||
|
||||
@@ -195,13 +195,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
return self._configured_checks
|
||||
|
||||
def _check_environment(self):
|
||||
from platform import python_version
|
||||
import pkg_resources
|
||||
|
||||
local_pip = LocalPipCaller()
|
||||
|
||||
# check python and setuptools version
|
||||
versions = dict(python=python_version(),
|
||||
versions = dict(python=get_python_version_string(),
|
||||
setuptools=pkg_resources.get_distribution("setuptools").version,
|
||||
pip=local_pip.version_string)
|
||||
supported = get_comparable_version(versions["python"]) >= get_comparable_version(MINIMUM_PYTHON) \
|
||||
|
||||
@@ -118,6 +118,33 @@ def is_octoprint_compatible(*compatibility_entries, **kwargs):
|
||||
return True
|
||||
|
||||
|
||||
def get_python_version_string():
|
||||
from platform import python_version
|
||||
version_string = python_version()
|
||||
|
||||
# Debian has the python version set to 2.7.15+ which is not PEP440 compliant (bug 914072)
|
||||
if version_string.endswith("+"):
|
||||
version_string = python_version[:-1]
|
||||
|
||||
return version_string
|
||||
|
||||
|
||||
def get_python_version():
|
||||
return get_comparable_version(get_python_version_string())
|
||||
|
||||
|
||||
def is_python_compatible(compat, **kwargs):
|
||||
if not compat:
|
||||
return True
|
||||
|
||||
python_version = kwargs.get("python_version")
|
||||
if python_version is None:
|
||||
python_version = get_python_version_string()
|
||||
|
||||
s = pkg_resources.Requirement.parse("Python" + compat)
|
||||
return python_version in s
|
||||
|
||||
|
||||
def get_comparable_version(version_string, base=False):
|
||||
if "-" in version_string:
|
||||
version_string = version_string[:version_string.find("-")]
|
||||
|
||||
Reference in new issue
Block a user