From a25eb4a7db152a278074fc316106870b178b9a8b Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Sat, 31 Dec 2022 18:45:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=91=BD=E4=BB=A4=EF=BC=9Ade?= =?UTF-8?q?compressionbottle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoShell/command/decompressionbottle | 14 +++++++++ ConfigLanguareRunner.py | 42 +++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100755 AutoShell/command/decompressionbottle diff --git a/AutoShell/command/decompressionbottle b/AutoShell/command/decompressionbottle new file mode 100755 index 0000000..b766ea2 --- /dev/null +++ b/AutoShell/command/decompressionbottle @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# 加入路径 +import os +import sys +programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string +sys.path.append(f"{programPath}/../../") +import ConfigLanguareRunner +# 符号转移 +argv = [] +for i in sys.argv[1:]: + argv.append(i.replace(" ", "\\ ")) +com = ConfigLanguareRunner.Command(f"{os.path.basename(sys.argv[0])} {' '.join(argv)}") +com.Run(com.GetCommandList(), os.getenv("WINEPREFIX"), os.getenv("WINE")) +sys.exit(int(ConfigLanguareRunner.programEnv[9][1])) \ No newline at end of file diff --git a/ConfigLanguareRunner.py b/ConfigLanguareRunner.py index e9fffd4..de201a2 100755 --- a/ConfigLanguareRunner.py +++ b/ConfigLanguareRunner.py @@ -11,6 +11,7 @@ import os import sys import time import json +import random import platform import traceback import subprocess @@ -57,6 +58,19 @@ readOnlyEnv = [ "($SYSTEM)", "($DEBUG)" ] + +def FindFile(file, name): + for i in os.listdir(file): + path = f"{file}/{i}" + if os.path.isdir(path): + returnPath = FindFile(path, name) + if returnPath != None: + return returnPath.replace("//", "/") + if os.path.isfile(path): + if i == name: + return path + return None + def Debug(): if "--debug" in sys.argv: traceback.print_exc() @@ -111,7 +125,8 @@ class Command(): "disbledWinebottlecreatelink", "enabledWinebottlecreatelink", "installvb", - "installother" + "installother", + "decompressionbottle" ] def __init__(self, commandString: str) -> None: @@ -389,6 +404,20 @@ class Command(): self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "/v", "ProxyServer", "/d", f"{proxyServerAddress}:{port}", "/f"] self.Bat() + def DecompressionBottle(self): + tempDebDir = f"/tmp/wine-runner-unpack-deb-{random.randint(0, 1000)}" + if os.system(f"dpkg -x '{self.command[1]}' '{tempDebDir}'"): + return 1 + zippath = FindFile(tempDebDir, "files.7z") + if zippath == None: + return 2 + # 解压文件 + os.system(f"mkdir -p '{self.command[2]}'") + fi = os.system(f"7z x -y '{zippath}' -o'{self.command[2]}'") + os.system(f"rm -rfv '{tempDebDir}'") + return fi + + def DisbledHttpProxy(self): self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "/v", "ProxyEnable", "/t", "REG_DWORD", "/d", "00000000", "/f"] self.Bat() @@ -443,7 +472,8 @@ class Command(): "disbledWinebottlecreatelink": DisbledWineBottleCreateLink, "enabledWinebottlecreatelink": EnabledWineBottleCreateLink, "installvb": InstallVB, - "installother": InstallOther + "installother": InstallOther, + "decompressionbottle": DecompressionBottle } # 参数数列表 @@ -488,7 +518,8 @@ class Command(): "disbledWinebottlecreatelink": [0], "enabledWinebottlecreatelink": [0], "installvb": [1], - "installother": [1] + "installother": [1], + "decompressionbottle": [2] } windowsUnrun = [ "createbotton", @@ -502,7 +533,8 @@ class Command(): "disbledopengl", "installdxvk", "installfont", - "installsparkcorefont" + "installsparkcorefont", + "decompressionbottle" ] # 解析 def __init__(self, command: list, wineBottonPath: str, wine: str) -> int: @@ -554,7 +586,7 @@ class Command(): i[a] = i[a].replace(b[0], b[1]) commandReturn = self.commandList[i[0]](self) if commandReturn: - print(f"运行命令{' '.join(self.command)}出现错误") + print(f"运行命令{' '.join(self.command)}出现错误,返回值:", commandReturn) programEnv[9][1] = str(commandReturn) if self.close: break