Qemu优化

This commit is contained in:
2022-12-03 21:47:05 +08:00
parent 9c0e2d11b3
commit f6698e2f39
5 changed files with 48 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ import PyQt5.QtWidgets as QtWidgets
if __name__ == "__main__":
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
homePath = os.getenv("HOME")
if len(sys.argv) <= 2:
if len(sys.argv) <= 1:
print("参数不足")
sys.exit(1)
app = QtWidgets.QApplication(sys.argv)
@@ -19,8 +19,23 @@ if __name__ == "__main__":
userName = getpass.getuser()
for i in sys.argv[2:]:
commandList += f"'{i}' "
if commandList.replace(" ", "") == "":
commandList = "bash"
# 需要先取消挂载其它目录以防止冲突
path = f"{homePath}/.deepin-wine-runner-ubuntu-images"
for i in os.listdir(path):
archPath = f"{path}/{i}"
if os.path.isdir(archPath):
for k in os.listdir(archPath):
bottlePath = f"{archPath}/{k}"
if os.path.isdir(bottlePath):
if f"{i}/{k}" == sys.argv[1]:
continue
if os.path.ismount(f"{bottlePath}/dev"):
os.system(f"pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash '{programPath}/UnMount.sh' '{bottlePath}' ")
# 判断是否挂载
if not os.path.ismount(f"{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/proc"):
if not os.path.ismount(f"{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/dev"):
print("文件暂未挂载,开始挂载")
sys.exit(os.system(f"pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY bash '{programPath}/Mount.sh' '{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}' '{userName}' {commandList}"))
sys.exit(os.system(f"pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY chroot '--userspec={userName}:{userName}' '{homePath}/.deepin-wine-runner-ubuntu-images/{sys.argv[1]}/' env 'HOME=/home/{userName}' {commandList}"))