Maker CLI a bit faster in responding
We don't actually need the pip caller, which necessitates version detection and hence increases waiting times tremendously - a simple command line call with the auto detected pip command for uninstalling stuff is enough and cuts off a lot of the CLI response times.
This commit is contained in:
parent
32bb4dd50a
commit
221b497932
2 changed files with 12 additions and 20 deletions
|
|
@ -7,7 +7,6 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
|
|||
|
||||
|
||||
import click
|
||||
import logging
|
||||
|
||||
class OctoPrintDevelCommands(click.MultiCommand):
|
||||
"""
|
||||
|
|
@ -23,7 +22,6 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
|||
click.MultiCommand.__init__(self, *args, **kwargs)
|
||||
|
||||
from octoprint.util.commandline import CommandlineCaller
|
||||
from octoprint.util.pip import LocalPipCaller
|
||||
from functools import partial
|
||||
|
||||
def log_util(f):
|
||||
|
|
@ -32,19 +30,10 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
|||
f(line)
|
||||
return log
|
||||
|
||||
log_call = log_util(lambda x: click.echo(">> {}".format(x)))
|
||||
log_stdout = log_util(click.echo)
|
||||
log_stderr = log_util(partial(click.echo, err=True))
|
||||
|
||||
self.pip_caller = LocalPipCaller()
|
||||
self.pip_caller.on_log_call = log_call
|
||||
self.pip_caller.on_log_stdout = log_stdout
|
||||
self.pip_caller.on_log_stderr = log_stderr
|
||||
|
||||
self.command_caller = CommandlineCaller()
|
||||
self.command_caller.on_log_call = log_call
|
||||
self.command_caller.on_log_stdout = log_stdout
|
||||
self.command_caller.on_log_stderr = log_stderr
|
||||
self.command_caller.on_log_call = log_util(lambda x: click.echo(">> {}".format(x)))
|
||||
self.command_caller.on_log_stdout = log_util(click.echo)
|
||||
self.command_caller.on_log_stderr = log_util(partial(click.echo, err=True))
|
||||
|
||||
def _get_prefix_methods(self, method_prefix):
|
||||
for name in [x for x in dir(self) if x.startswith(method_prefix)]:
|
||||
|
|
@ -219,7 +208,9 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
|||
return command
|
||||
|
||||
def plugin_uninstall(self):
|
||||
if not self.pip_caller.available:
|
||||
from octoprint.util.pip import PipCaller
|
||||
pip_command = PipCaller.autodetect_pip()
|
||||
if pip_command is None:
|
||||
return
|
||||
|
||||
@click.command("uninstall")
|
||||
|
|
@ -233,8 +224,8 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
|||
click.echo("This doesn't look like an OctoPrint plugin name")
|
||||
sys.exit(1)
|
||||
|
||||
call = ["uninstall", "--yes", name]
|
||||
self.pip_caller.execute(*call)
|
||||
call = [pip_command, "uninstall", "--yes", name]
|
||||
self.command_caller.call(call)
|
||||
|
||||
return command
|
||||
|
||||
|
|
|
|||
|
|
@ -211,11 +211,12 @@ class PipCaller(CommandlineCaller):
|
|||
pip_sudo = False
|
||||
|
||||
if pip_command is None:
|
||||
pip_command = self._autodetect_pip()
|
||||
pip_command = self.autodetect_pip()
|
||||
|
||||
return pip_command, pip_sudo
|
||||
|
||||
def _autodetect_pip(self):
|
||||
@classmethod
|
||||
def autodetect_pip(cls):
|
||||
import os
|
||||
python_command = sys.executable
|
||||
binary_dir = os.path.dirname(python_command)
|
||||
|
|
@ -333,7 +334,7 @@ class PipCaller(CommandlineCaller):
|
|||
class LocalPipCaller(PipCaller):
|
||||
|
||||
def _get_pip_command(self):
|
||||
return self._autodetect_pip(), False
|
||||
return self.autodetect_pip(), False
|
||||
|
||||
def _check_pip_setup(self, pip_command):
|
||||
import sys
|
||||
|
|
|
|||
Loading…
Reference in a new issue