Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Detritalw authored Feb 3, 2025
1 parent c24e495 commit f132572
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,19 @@ def setup_info_ui(self, widget):

def run_cmcl_list(self):
try:
result = subprocess.run(["cmcl", "-l"], capture_output=True, text=True, check=True)
cmcl_path = os.path.join(os.getcwd(), "cmcl.exe")
if not os.path.exists(cmcl_path) or not os.access(cmcl_path, os.X_OK):
self.log(f"cmcl.exe 不存在或不可执行: {cmcl_path}", logging.ERROR)
return

self.log(f"正在运行 {cmcl_path} -l")
result = subprocess.run(
[cmcl_path, "-l"],
capture_output=True,
text=True,
check=True,
cwd=os.getcwd() # 确保在当前工作目录下运行
)
set_list = [line.strip() for line in result.stdout.splitlines()[1:]] # 去除每行末尾的空格
self.log(f"cmcl -l 输出: {set_list}")
if not set_list:
Expand All @@ -1189,7 +1201,11 @@ def run_cmcl_list(self):
# run_choose.clear()
# run_choose.addItems(set_list)
except subprocess.CalledProcessError as e:
self.log(f"执行 cmcl -l 失败: {e}", logging.ERROR)
self.log(f"执行 cmcl -l 失败: {e.stderr}", logging.ERROR)
except OSError as e:
self.log(f"运行 cmcl -l 时发生操作系统错误: {e}", logging.ERROR)
except Exception as e:
self.log(f"运行 cmcl -l 时发生未知错误: {e}", logging.ERROR)

if __name__ == "__main__":
app = QApplication(sys.argv)
Expand Down

0 comments on commit f132572

Please sign in to comment.