deep-wine-runner/Model/__init__.py

39 lines
1.2 KiB
Python
Raw Normal View History

2023-04-08 11:57:36 +08:00
#!/usr/bin/env python3
2022-08-27 02:00:41 +08:00
import os
2022-09-10 22:36:50 +08:00
import sys
import PyQt5.QtWidgets as QtWidgets
2022-08-27 02:00:41 +08:00
def OpenTerminal(command):
if terminalEnd[terminal][1]:
os.system(f"\"{terminal}\" \"{terminalEnd[terminal][0]}\" \"{command}\"")
return
os.system(f"\"{terminal}\" \"{terminalEnd[terminal][0]}\" {command}")
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
# 对终端的获取
# 为什么 openkylin 只有 mate-terminal
# 优先为深度终端
terminal = ""
terminalList = [
"deepin-terminal",
"mate-terminal",
2022-09-10 22:36:50 +08:00
"gnome-terminal",
"xfce4-terminal"
2022-08-27 02:00:41 +08:00
]
terminalEnd = {
2022-09-05 13:33:53 +08:00
f"{programPath}/../launch.sh\" \"deepin-terminal": ["-e", 0],
2022-08-27 02:00:41 +08:00
"mate-terminal": ["-e", 1],
2022-09-10 22:36:50 +08:00
"gnome-terminal": ["--", 0],
"xfce4-terminal": ["-e", 1]
2022-08-27 02:00:41 +08:00
}
for i in terminalList:
if not os.system(f"which {i}"):
if i == "deepin-terminal":
2022-09-05 13:33:53 +08:00
i = f"{programPath}/../launch.sh\" \"deepin-terminal"
2022-08-27 02:00:41 +08:00
terminal = i
break
if terminal == "":
print("无法识别到以下的任意一个终端")
print(" ".join(terminalList))
2022-09-10 22:36:50 +08:00
app = QtWidgets.QApplication(sys.argv)
QtWidgets.QMessageBox.critical(None, "错误", "无法识别到以下的任意一个终端\n" + " ".join(terminalList))
2022-09-05 13:33:53 +08:00
exit()