From 85a259ee5562ce8f3d7ff0bd726d932ffd18ad51 Mon Sep 17 00:00:00 2001 From: Jordan Thompson Date: Mon, 15 Jul 2024 08:49:33 -0700 Subject: [PATCH] Add try/catch and patch packages() method --- WAS_Node_Suite.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/WAS_Node_Suite.py b/WAS_Node_Suite.py index bf2bdc3..ff1012f 100644 --- a/WAS_Node_Suite.py +++ b/WAS_Node_Suite.py @@ -331,7 +331,13 @@ if was_config.__contains__('webui_styles'): def packages(versions=False): import sys import subprocess - return [( r.decode().split('==')[0] if not versions else r.decode() ) for r in subprocess.check_output([sys.executable, '-s', '-m', 'pip', 'freeze']).split()] + try: + result = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'], stderr=subprocess.STDOUT) + lines = result.decode().splitlines() + return [line if versions else line.split('==')[0] for line in lines] + except subprocess.CalledProcessError as e: + print("An error occurred while fetching packages:", e.output.decode()) + return [] def install_package(package, uninstall_first: Union[List[str], str] = None): if os.getenv("WAS_BLOCK_AUTO_INSTALL", 'False').lower() in ('true', '1', 't'):