From 7af523da15c0220829297c35d57a1ea8ab1a1dd3 Mon Sep 17 00:00:00 2001 From: DoctorReid Date: Sun, 8 Sep 2024 15:40:16 +0800 Subject: [PATCH] =?UTF-8?q?#165=20=E4=BC=98=E5=8C=96=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=99=A8=E6=97=A5=E5=BF=97=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/one_dragon/envs/python_service.py | 7 +++++-- src/one_dragon/gui/view/install_interface.py | 5 ++--- src/one_dragon/utils/cmd_utils.py | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/one_dragon/envs/python_service.py b/src/one_dragon/envs/python_service.py index 1f0b52af..48d9b6eb 100644 --- a/src/one_dragon/envs/python_service.py +++ b/src/one_dragon/envs/python_service.py @@ -63,8 +63,11 @@ def is_virtual_python(self) -> bool: 是否虚拟环境的python :return: """ - env = os.environ - return 'VIRTUAL_ENV' in env or 'CONDA_PREFIX' in env + is_virtual_str = cmd_utils.run_command([self.env_config.python_path, "-c", "import sys; print(getattr(sys, 'base_prefix', sys.prefix) != sys.prefix)"]) + if is_virtual_str is None: + return False + else: + return is_virtual_str == 'True' def install_default_pip(self, progress_callback: Optional[Callable[[float, str], None]] = None) -> bool: """ diff --git a/src/one_dragon/gui/view/install_interface.py b/src/one_dragon/gui/view/install_interface.py index 000dddec..734836dc 100644 --- a/src/one_dragon/gui/view/install_interface.py +++ b/src/one_dragon/gui/view/install_interface.py @@ -57,11 +57,10 @@ def get_content_widget(self) -> QWidget: update_group.addSettingCard(self.venv_opt) v_layout.addWidget(update_group) - log_group = SettingCardGroup(gt('安装日志', 'ui')) - self.log_card = LogDisplayCard() - log_group.addSettingCard(self.log_card) v_layout.addWidget(log_group) + self.log_card = LogDisplayCard() + v_layout.addWidget(self.log_card, stretch=1) return content_widget diff --git a/src/one_dragon/utils/cmd_utils.py b/src/one_dragon/utils/cmd_utils.py index 1bcb261e..fcfada67 100644 --- a/src/one_dragon/utils/cmd_utils.py +++ b/src/one_dragon/utils/cmd_utils.py @@ -66,6 +66,7 @@ def run_command(commands: List[str], cwd: Optional[str] = None, else: return None except Exception: + log.error("执行命令失败", exc_info=True) return None