mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-01-13 01:58:27 +08:00
初步完成的脚本解析器
This commit is contained in:
parent
51d471f649
commit
8afe569b19
117
AutoConfig.py
Normal file
117
AutoConfig.py
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
import os
|
||||||
|
import PyQt5.QtCore as QtCore
|
||||||
|
shell = """# “#”后面代表注释
|
||||||
|
# 可以为了方便观看改为 bash 的高亮模式
|
||||||
|
# 安装 dll
|
||||||
|
installdll 0
|
||||||
|
installdll 1
|
||||||
|
# 安装字体
|
||||||
|
installfont 0 # 后面参数填 Wine 运行器的字体安装器提示的编号
|
||||||
|
# 安装字体(安装星火应用商店的微软核心字体)
|
||||||
|
installsparkcorefont
|
||||||
|
# 安装 Mono
|
||||||
|
installmono
|
||||||
|
# 安装 gecko
|
||||||
|
installgecko
|
||||||
|
# 安装 vcpp
|
||||||
|
installvcpp 0 # 后面参数填 Wine 运行器的 VCPP 安装器提示的编号
|
||||||
|
# 安装 .net
|
||||||
|
installnet # 后面参数填 Wine 运行器的 VCPP 安装器提示的编号
|
||||||
|
# 安装 MSXML
|
||||||
|
installmsxml # 后面参数填 Wine 运行器的 MSXML 安装器提示的编号
|
||||||
|
#aaaaa
|
||||||
|
"""
|
||||||
|
|
||||||
|
class Command():
|
||||||
|
# 可以被使用的命令
|
||||||
|
commandList = [
|
||||||
|
"installdll",
|
||||||
|
"installfont",
|
||||||
|
"installsparkcorefont",
|
||||||
|
"installmono",
|
||||||
|
"installgecko",
|
||||||
|
"installvcpp",
|
||||||
|
"installnet",
|
||||||
|
"installmsxml"
|
||||||
|
]
|
||||||
|
def __init__(self, commandString: str) -> None:
|
||||||
|
self.commandString = commandString
|
||||||
|
|
||||||
|
# 解析器
|
||||||
|
# 命令字符串转可供解析的列表
|
||||||
|
def GetCommandList(self) -> list:
|
||||||
|
shellList = []
|
||||||
|
shellFirstShell = self.commandString.split("\n")
|
||||||
|
# 转换成可以执行的数组
|
||||||
|
for l in range(0, len(shellFirstShell)):
|
||||||
|
i = shellFirstShell[l]
|
||||||
|
# 判断有没有注释
|
||||||
|
if "#" in i:
|
||||||
|
# 忽略注释
|
||||||
|
i = i[:i.index("#")]
|
||||||
|
# 删除前后空格
|
||||||
|
i = i.strip()
|
||||||
|
# 如果是空行
|
||||||
|
if i == "":
|
||||||
|
# 忽略此行,此行不做处理
|
||||||
|
continue
|
||||||
|
# 解析
|
||||||
|
i = i.split()
|
||||||
|
# 判断是否为合法的参数,否则提示并忽略
|
||||||
|
if not i[0] in self.commandList:
|
||||||
|
print(f"行{l + 1}命令{i[0]}不存在,忽略")
|
||||||
|
continue
|
||||||
|
shellList.append(i)
|
||||||
|
return shellList
|
||||||
|
|
||||||
|
# 运行器
|
||||||
|
class Run():
|
||||||
|
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||||
|
def InstallDll(self) -> int:
|
||||||
|
import InstallDll
|
||||||
|
return InstallDll.Download(self.wineBottonPath, InstallDll.GetNameByNumber(int(self.command[1])), InstallDll.GetUrlByNumber(int(self.command[1])))
|
||||||
|
|
||||||
|
def InstallFont(self) -> int:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def InstallMono(self) -> int:
|
||||||
|
return os.system(f"ENTERNOTSHOW=0 '{self.programPath}/InstallMono.py' '{self.wineBottonPath}' '{self.wine}' mono")
|
||||||
|
|
||||||
|
def InstallGecko(self) -> int:
|
||||||
|
return os.system(f"ENTERNOTSHOW=0 '{self.programPath}/InstallMono.py' '{self.wineBottonPath}' '{self.wine}' gecko")
|
||||||
|
|
||||||
|
def InstallVCPP(self) -> int:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def InstallNet(self) -> int:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def InstallMsxml(self) -> int:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def InstallSparkCoreFont(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 可以运行的命令的映射关系
|
||||||
|
# 可以被使用的命令的映射
|
||||||
|
commandList = {
|
||||||
|
"installdll": InstallDll,
|
||||||
|
"installfont": InstallFont,
|
||||||
|
"installsparkcorefont": InstallSparkCoreFont,
|
||||||
|
"installmono": InstallMono,
|
||||||
|
"installgecko": InstallGecko,
|
||||||
|
"installvcpp": InstallVCPP,
|
||||||
|
"installnet": InstallNet,
|
||||||
|
"installmsxml": InstallMsxml
|
||||||
|
}
|
||||||
|
# 解析
|
||||||
|
def __init__(self, command: list, wineBottonPath: str, wine: str) -> int:
|
||||||
|
self.wineBottonPath = wineBottonPath
|
||||||
|
self.wine = wine
|
||||||
|
for i in command:
|
||||||
|
self.command = i
|
||||||
|
self.commandList[i[0]](self)
|
||||||
|
|
||||||
|
|
||||||
|
com = Command(shell)
|
||||||
|
com.Run(com.GetCommandList(), "/home/gfdgd_xi/.wine", "deepin-wine6-stable")
|
37
InstallDll.py
Normal file → Executable file
37
InstallDll.py
Normal file → Executable file
@ -15,6 +15,29 @@ import sys
|
|||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
import requests
|
import requests
|
||||||
|
# 获取云列表
|
||||||
|
url = "https://code.gitlink.org.cn/gfdgd_xi/wine-runner-list/raw/branch/master/dlls"
|
||||||
|
print("获取列表中……", end="")
|
||||||
|
try:
|
||||||
|
lists = json.loads(requests.get(f"{url}/list.json").text)
|
||||||
|
except:
|
||||||
|
print("\r列表获取失败!")
|
||||||
|
exit()
|
||||||
|
print("\r列表获取成功!")
|
||||||
|
|
||||||
|
def GetUrlByNumber(dllID: int) -> str:
|
||||||
|
dllName = lists[dllID][0]
|
||||||
|
return f"{url}/{lists[int(dllID)][1]}/{lists[int(dllID)][2]}/{lists[int(dllID)][0]}"
|
||||||
|
|
||||||
|
def GetNameByNumber(dllID: int) -> str:
|
||||||
|
return lists[dllID][0]
|
||||||
|
|
||||||
|
def Download(wineBotton, dllName, urlPart) -> bool:
|
||||||
|
try:
|
||||||
|
os.remove(f"{wineBotton}/drive_c/windows/system32/{dllName}")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return not os.system(f"aria2c -x 16 -s 16 -d '{wineBotton}/drive_c/windows/system32' -o '{dllName}' '{urlPart}'")
|
||||||
|
|
||||||
def exit():
|
def exit():
|
||||||
input("按回车键退出")
|
input("按回车键退出")
|
||||||
@ -49,15 +72,6 @@ if __name__ == "__main__":
|
|||||||
if not os.path.exists(f"{wineBotton}/drive_c/windows/system32"):
|
if not os.path.exists(f"{wineBotton}/drive_c/windows/system32"):
|
||||||
print("这不是 Wine 容器")
|
print("这不是 Wine 容器")
|
||||||
exit()
|
exit()
|
||||||
# 获取云列表
|
|
||||||
url = "https://code.gitlink.org.cn/gfdgd_xi/wine-runner-list/raw/branch/master/dlls"
|
|
||||||
print("获取列表中……", end="")
|
|
||||||
try:
|
|
||||||
lists = json.loads(requests.get(f"{url}/list.json").text)
|
|
||||||
except:
|
|
||||||
print("\r列表获取失败!")
|
|
||||||
exit()
|
|
||||||
print("\r列表获取成功!")
|
|
||||||
# 获取用户希望安装的DLL
|
# 获取用户希望安装的DLL
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -74,7 +88,8 @@ if __name__ == "__main__":
|
|||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
dllName = lists[int(dllName)][0]
|
dllName = lists[int(dllName)][0]
|
||||||
urlPart = f"{url}/{lists[int(dllName)][1]}/{lists[int(dllName)][2]}/{lists[int(dllName)][0]}"
|
urlPart = GetUrlByNumber(int(dllName))
|
||||||
|
f"{url}/{lists[int(dllName)][1]}/{lists[int(dllName)][2]}/{lists[int(dllName)][0]}"
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -100,5 +115,5 @@ if __name__ == "__main__":
|
|||||||
# 下载 DLL
|
# 下载 DLL
|
||||||
print(f"正在下载{dllName},请稍后")
|
print(f"正在下载{dllName},请稍后")
|
||||||
print(f"下载链接:{urlPart}")
|
print(f"下载链接:{urlPart}")
|
||||||
if os.system(f"aria2c -x 16 -s 16 -d '{wineBotton}/drive_c/windows/system32' -o '{dllName}' '{urlPart}'"):
|
if not Download(wineBotton, dllName, urlPart):
|
||||||
print("下载失败!请重试")
|
print("下载失败!请重试")
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#################
|
#################
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
import pyquery
|
import pyquery
|
||||||
|
|
||||||
if "--help" in sys.argv:
|
if "--help" in sys.argv:
|
||||||
@ -47,6 +48,10 @@ else:
|
|||||||
|
|
||||||
''')
|
''')
|
||||||
homePath = os.path.expanduser('~')
|
homePath = os.path.expanduser('~')
|
||||||
|
try:
|
||||||
|
exitInputShow = int(os.getenv("ENTERNOTSHOW"))
|
||||||
|
except:
|
||||||
|
exitInputShow = True
|
||||||
try:
|
try:
|
||||||
# 获取最新版本的版本号
|
# 获取最新版本的版本号
|
||||||
programVersionList = pyquery.PyQuery(url=f"http://mirrors.ustc.edu.cn/wine/wine/wine-{sys.argv[3]}/")
|
programVersionList = pyquery.PyQuery(url=f"http://mirrors.ustc.edu.cn/wine/wine/wine-{sys.argv[3]}/")
|
||||||
@ -54,13 +59,15 @@ except:
|
|||||||
print("无法连接下载服务器,将使用本地缓存")
|
print("无法连接下载服务器,将使用本地缓存")
|
||||||
if not os.path.exists(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.msi") or not os.path.exists(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt"):
|
if not os.path.exists(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.msi") or not os.path.exists(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt"):
|
||||||
print("无本地缓存数据,无法进行、结束")
|
print("无本地缓存数据,无法进行、结束")
|
||||||
input("按回车键退出")
|
if exitInputShow:
|
||||||
|
input("按回车键退出")
|
||||||
exit()
|
exit()
|
||||||
file = open(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt", "r")
|
file = open(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt", "r")
|
||||||
version = file.read().replace("\n", "")
|
version = file.read().replace("\n", "")
|
||||||
print("安装版本:", version)
|
print("安装版本:", version)
|
||||||
os.system(f"WINEPREFIX={sys.argv[1]} {sys.argv[2]} msiexec /i \"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.msi\"")
|
os.system(f"WINEPREFIX={sys.argv[1]} {sys.argv[2]} msiexec /i \"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.msi\"")
|
||||||
input("安装结束,按回车键退出")
|
if exitInputShow:
|
||||||
|
input("安装结束,按回车键退出")
|
||||||
exit()
|
exit()
|
||||||
programVersion = programVersionList("a:last-child").attr.href
|
programVersion = programVersionList("a:last-child").attr.href
|
||||||
# 获取最新版本安装包的URL
|
# 获取最新版本安装包的URL
|
||||||
@ -92,7 +99,8 @@ if os.path.exists(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.m
|
|||||||
print("已经缓存,使用本地版本")
|
print("已经缓存,使用本地版本")
|
||||||
file.close()
|
file.close()
|
||||||
os.system(f"WINEPREFIX={sys.argv[1]} {sys.argv[2]} msiexec /i \"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.msi\"")
|
os.system(f"WINEPREFIX={sys.argv[1]} {sys.argv[2]} msiexec /i \"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.msi\"")
|
||||||
input("安装结束,按回车键退出")
|
if exitInputShow:
|
||||||
|
input("安装结束,按回车键退出")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
file = open(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt", "w+")
|
file = open(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt", "w+")
|
||||||
@ -114,4 +122,5 @@ except:
|
|||||||
print("写入缓存")
|
print("写入缓存")
|
||||||
file.write(programVersion)
|
file.write(programVersion)
|
||||||
file.close()
|
file.close()
|
||||||
input("安装结束,按回车键退出")
|
if exitInputShow:
|
||||||
|
input("安装结束,按回车键退出")
|
BIN
__pycache__/InstallDll.cpython-310.pyc
Normal file
BIN
__pycache__/InstallDll.cpython-310.pyc
Normal file
Binary file not shown.
@ -1351,6 +1351,7 @@ updateThingsString = '''<b>※1、新增新的 Wine 安装器,并支持将安
|
|||||||
5、修复评分功能名称为空也可以上传评分的问题
|
5、修复评分功能名称为空也可以上传评分的问题
|
||||||
6、去除 toilet 依赖,使在 Deepin 23 Preview 上运行更佳
|
6、去除 toilet 依赖,使在 Deepin 23 Preview 上运行更佳
|
||||||
7、支持删除所有由 Wine 创建的启动器快捷方式
|
7、支持删除所有由 Wine 创建的启动器快捷方式
|
||||||
|
8、支持从云端获取 Dll 并添加
|
||||||
'''
|
'''
|
||||||
for i in information["Thank"]:
|
for i in information["Thank"]:
|
||||||
thankText += f"{i}\n"
|
thankText += f"{i}\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user