Addon Manager: Refactor installation code
Improve testability of installation code by refactoring it to completely separate the GUI and non-GUI code, and to provide more robust support for non-GUI access to some type of Addon Manager activity.
This commit is contained in:
@@ -94,39 +94,16 @@ def call_pip(args) -> List[str]:
|
||||
call_args.extend(args)
|
||||
proc = None
|
||||
try:
|
||||
no_window_flag = 0
|
||||
if hasattr(subprocess, "CREATE_NO_WINDOW"):
|
||||
no_window_flag = subprocess.CREATE_NO_WINDOW # Added in Python 3.7
|
||||
proc = subprocess.run(
|
||||
call_args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=True,
|
||||
timeout=30,
|
||||
creationflags=no_window_flag,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
pip_failed = True
|
||||
except subprocess.CalledProcessError as e:
|
||||
pip_failed = True
|
||||
print(e)
|
||||
except subprocess.TimeoutExpired:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"pip took longer than 30 seconds to return results, giving up on it",
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
FreeCAD.Console.PrintLog(" ".join(call_args))
|
||||
proc = utils.run_interruptable_subprocess(call_args)
|
||||
except subprocess.CalledProcessError:
|
||||
pip_failed = True
|
||||
|
||||
result = []
|
||||
if not pip_failed:
|
||||
data = proc.stdout.decode()
|
||||
data = proc.stdout
|
||||
result = data.split("\n")
|
||||
elif proc:
|
||||
raise PipFailed(proc.stderr.decode())
|
||||
raise PipFailed(proc.stderr)
|
||||
else:
|
||||
raise PipFailed("pip timed out")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user