This commit is contained in:
gfdgd xi 2022-10-15 17:31:48 +08:00
parent aa6743cd3e
commit 7a56a66f6c
3 changed files with 57 additions and 0 deletions

54
API/Python/__init__.py Normal file
View File

@ -0,0 +1,54 @@
#!/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}\"")

Binary file not shown.

3
API/demo/a.py Normal file
View File

@ -0,0 +1,3 @@
import WineRunner
WineRunner.Bash("a").runList([["thank"], ["version"]])
#WineRunner.Bash("a").runCommand("thank")