deep-wine-runner/API/Python/__init__.py
2023-04-24 21:44:14 +08:00

55 lines
2.0 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# 使用系统默认的 python3 运行
###########################################################################################
# 作者gfdgd xi
# 版本2.4.0
# 更新时间2022年10月15日
# 感谢:感谢 wine 以及 deepin-wine 团队,提供了 wine 和 deepin-wine 给大家使用,让我能做这个程序
# 基于 Python3 构建
###########################################################################################
#################
# 加入路径
#################
import os
import sys
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
sys.path.append(f"{programPath}/../../")
#################
# 引入所需的库(正式内容)
#################
import os
import sys
import ConfigLanguareRunner
class Old:
wine = ""
wineprefix = ""
def __init__(self, wine = "", wineprefix = "") -> None:
self.wine = os.getenv("WINE") if wine == "" else wine
self.wineprefix = os.getenv("WINEPREFIX") if wine == "" else wineprefix
def runCommand(self, command: str) -> None:
com = ConfigLanguareRunner.Command(command)
print(com.GetCommandList())
return com.Run(com.GetCommandList(), self.wineprefix, self.wine)
def runList(self, command: list) -> None:
return ConfigLanguareRunner.Command("").Run(command, self.wineprefix, self.wine)
class Bash:
wine = ""
wineprefix = ""
def __init__(self, wine = "", wineprefix = "") -> None:
self.wine = os.getenv("WINE") if wine == "" else wine
self.wineprefix = os.getenv("WINEPREFIX") if wine == "" else wineprefix
def runCommand(self, command: str) -> int:
return os.system(f"'{programPath}/../../AutoShell/main.py' -c \"{command}\"")
def runList(self, command: list) -> int:
commandStr = ""
for k in command:
for i in k:
commandStr += f"'{i}' "
commandStr += ";"
return os.system(f"'{programPath}/../../AutoShell/main.py' -c \"{commandStr}\"")