Merge branch 'fix/pmgrPipWithSudo' into devel
Conflicts: src/octoprint/util/pip.py
This commit is contained in:
commit
705f0706fd
2 changed files with 13 additions and 5 deletions
|
|
@ -196,7 +196,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||
pip=dict(
|
||||
available=self._pip_caller.available,
|
||||
command=self._pip_caller.command,
|
||||
version=str(self._pip_caller.version),
|
||||
version=self._pip_caller.version_string,
|
||||
use_sudo=self._pip_caller.use_sudo,
|
||||
additional_args=self._settings.get(["pip_args"])
|
||||
))
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class PipCaller(CommandlineCaller):
|
|||
|
||||
self._command = None
|
||||
self._version = None
|
||||
self._version_string = None
|
||||
self._use_sudo = False
|
||||
|
||||
self.trigger_refresh()
|
||||
|
|
@ -60,6 +61,10 @@ class PipCaller(CommandlineCaller):
|
|||
def version(self):
|
||||
return self._version
|
||||
|
||||
@property
|
||||
def version_string(self):
|
||||
return self._version_string
|
||||
|
||||
@property
|
||||
def use_sudo(self):
|
||||
return self._use_sudo
|
||||
|
|
@ -70,7 +75,7 @@ class PipCaller(CommandlineCaller):
|
|||
|
||||
def trigger_refresh(self):
|
||||
try:
|
||||
self._command, self._version, self._use_sudo = self._find_pip()
|
||||
self._command, self._version, self._version_string, self._use_sudo = self._find_pip()
|
||||
except:
|
||||
self._logger.exception("Error while discovering pip command")
|
||||
self._command = None
|
||||
|
|
@ -100,12 +105,15 @@ class PipCaller(CommandlineCaller):
|
|||
|
||||
def _find_pip(self):
|
||||
pip_command = self.configured
|
||||
|
||||
if pip_command is not None and pip_command.startswith("sudo "):
|
||||
pip_command = pip_command[len("sudo "):]
|
||||
pip_sudo = True
|
||||
else:
|
||||
pip_sudo = False
|
||||
|
||||
pip_version = None
|
||||
version_segment = None
|
||||
|
||||
if pip_command is None:
|
||||
import os
|
||||
|
|
@ -167,12 +175,12 @@ class PipCaller(CommandlineCaller):
|
|||
pip_version = pkg_resources.parse_version(version_segment)
|
||||
except:
|
||||
self._logger.exception("Error while trying to parse version string from pip command")
|
||||
return None, None
|
||||
return None, None, None
|
||||
else:
|
||||
self._logger.info("Found pip at {}, version is {}".format(pip_command, version_segment))
|
||||
|
||||
if pip_version in self.__class__.broken:
|
||||
self._logger.error("This version of pip is known to have errors that make it incompatible with how it needs to be used by OctoPrint. Please upgrade your pip version.")
|
||||
return None, None, False
|
||||
return None, None, None, False
|
||||
|
||||
return pip_command, pip_version, pip_sudo
|
||||
return pip_command, pip_version, version_segment, pip_sudo
|
||||
|
|
|
|||
Loading…
Reference in a new issue