From 8afe569b19ccf57a8ea18a2ea8056d6619f3dd80 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Wed, 24 Aug 2022 17:41:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90=E7=9A=84?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E8=A7=A3=E6=9E=90=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoConfig.py | 117 +++++++++++++++++++++++++ InstallDll.py | 37 +++++--- InstallMono.py | 17 +++- __pycache__/InstallDll.cpython-310.pyc | Bin 0 -> 3360 bytes mainwindow.py | 1 + 5 files changed, 157 insertions(+), 15 deletions(-) create mode 100644 AutoConfig.py mode change 100644 => 100755 InstallDll.py create mode 100644 __pycache__/InstallDll.cpython-310.pyc diff --git a/AutoConfig.py b/AutoConfig.py new file mode 100644 index 0000000..815fd91 --- /dev/null +++ b/AutoConfig.py @@ -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") \ No newline at end of file diff --git a/InstallDll.py b/InstallDll.py old mode 100644 new mode 100755 index 593574d..d7d346b --- a/InstallDll.py +++ b/InstallDll.py @@ -15,6 +15,29 @@ import sys import json import traceback 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(): input("按回车键退出") @@ -49,15 +72,6 @@ if __name__ == "__main__": if not os.path.exists(f"{wineBotton}/drive_c/windows/system32"): print("这不是 Wine 容器") 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 while True: @@ -74,7 +88,8 @@ if __name__ == "__main__": break try: 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 except: pass @@ -100,5 +115,5 @@ if __name__ == "__main__": # 下载 DLL print(f"正在下载{dllName},请稍后") 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("下载失败!请重试") diff --git a/InstallMono.py b/InstallMono.py index d9ecef2..da62561 100755 --- a/InstallMono.py +++ b/InstallMono.py @@ -12,6 +12,7 @@ ################# import os import sys +import traceback import pyquery if "--help" in sys.argv: @@ -47,6 +48,10 @@ else: ''') homePath = os.path.expanduser('~') +try: + exitInputShow = int(os.getenv("ENTERNOTSHOW")) +except: + exitInputShow = True try: # 获取最新版本的版本号 programVersionList = pyquery.PyQuery(url=f"http://mirrors.ustc.edu.cn/wine/wine/wine-{sys.argv[3]}/") @@ -54,13 +59,15 @@ except: 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"): print("无本地缓存数据,无法进行、结束") - input("按回车键退出") + if exitInputShow: + input("按回车键退出") exit() file = open(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt", "r") version = file.read().replace("\n", "") print("安装版本:", version) 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() programVersion = programVersionList("a:last-child").attr.href # 获取最新版本安装包的URL @@ -92,7 +99,8 @@ if os.path.exists(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/install.m print("已经缓存,使用本地版本") file.close() 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() file = open(f"{homePath}/.cache/deepin-wine-runner/{sys.argv[3]}/information.txt", "w+") @@ -114,4 +122,5 @@ except: print("写入缓存") file.write(programVersion) file.close() -input("安装结束,按回车键退出") \ No newline at end of file +if exitInputShow: + input("安装结束,按回车键退出") \ No newline at end of file diff --git a/__pycache__/InstallDll.cpython-310.pyc b/__pycache__/InstallDll.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..413ca4455129c6a801fcaac65aa0b36177254f63 GIT binary patch literal 3360 zcma(TTT>L-xleb`Fbo4KF3KQ_BW{9hG7Mr|lT?bNTxwIBSX8Q#)as-*)G+4=BSR0I z?gpG96%;S9$|X@*70|(5kxhBaYOTsee?Z<-seVZ%OZUt?q zem&nIRa)wo;0gZ66IZrL($@$SKE(k13|>90ND`GONlH<7Cs86`IVy`?i7H}Oqbil7 z9_FPARjFr8CQ`bL$(bUiW_-*uEm7~RJV#Cx&ylGABS|YE68?a{XqdoWG7Qi$gnbCp zViur&R(f2eB{XnGjg}Q)N@*Ejwg7$WahYzRTLIcex6$%5QnZAX)9qdIB;iZ+Ek;gk z?~`~hXsr-dymZIfzEkWZQ!|_-Xdkw~}-({6_x8M=c7SKb2z6`eZY|x7#8<-Wq?iE-seFt}{ zMuR}Bq~94P(JEGz*)=E8a`5#ZZWdV;^F!4CWK~g*HlB_!KMOGM9U_u~5=fM}Fh~bQ zWxiX$0da%Bg_ycc7|=2;%@z>}>iB!Nj>jarFIvssrkG3rFd3Fxq>q0YtwCQ{jcZv{ zrG?f4ANB*x_S((1O1`D0D@~}!k zs<)a|gKSbGy?-mH!1q`cSW@N)&@!wNA^LrgA(`Ef-LUZeT<>x^z@$t_)O1}!yNbam=^DhbjNgq@d!;Ob+ZC==Ek4c6I1rcr@6U>)u;FVJv0x0mQ+tHg=sYHkD!8v z6M9NBcK~~-%ef}?`CoI7Z@*kVwVC9MOxmB^1d`yM^gpMye-58S4oblq2$?rW>(jvL%^p=s9VX{hS%U z<;lY*Tg~ov#;d`yj_w3VGvQm{Bk z0}cf_s5&Ua>X|K?BLNA#^tQgLicp^DV{LKlQ=016Bl=0`$?gM9k@U_OPsEzyq3}Rx z|9hdZE>;?FYzFk|%1mzP?91irVj_eF5?>FUT79~>x-_)S2X->5YGF!W82KhzBmP-<)UBHi8mAp~j>FR89Ik_2L$B_2M~jb-3r` z6=~*PaE|+6`M_<6XJA4!1h$8B<16RJ8E6j<|HevY6D%S7$(Q!MtI(U+PgftUx zbJ^*sm&-TzL8IhG?qUvvbM?PF7HR$1BCR4j&eZwUrLVGgmh#s=x7Y7DoEpx(&p_Ym z(+jzk6%!Gdi3d-z3uE@=xQP?nrR6U@cgEpnyl&#eaB=IJKp=m9Ecf6_eJ$S(WL^b} zrQ#iH6&pMjXYH|gm*wNE*JN;8aU4RHr-#FR1s52MCb+;lm|>{~8!*JU7t?^3AfKWe zT-+UEpj&EtDwPy-3x|aUv%js)Qe(WM&r*_1<9MlCYER7Qw7igYG#3OE--(MDlwh%+ zam&LK9i3nw{*CBh7D-qhv!{n~jziBX7S6S?fq20T7P?{l(?5dP%vAtE{+^DrmvMh!B3uWGg_; p@Qt%uCFSr_Nt5`3bqKL?zOu4X@Zy9=-748Cmyt5~lK-y$>%Yk93vd7c literal 0 HcmV?d00001 diff --git a/mainwindow.py b/mainwindow.py index ca95dd4..9775c54 100755 --- a/mainwindow.py +++ b/mainwindow.py @@ -1351,6 +1351,7 @@ updateThingsString = '''※1、新增新的 Wine 安装器,并支持将安 5、修复评分功能名称为空也可以上传评分的问题 6、去除 toilet 依赖,使在 Deepin 23 Preview 上运行更佳 7、支持删除所有由 Wine 创建的启动器快捷方式 +8、支持从云端获取 Dll 并添加 ''' for i in information["Thank"]: thankText += f"{i}\n"