mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-06-04 06:09:50 +08:00
修复打包器在部分机器上的适配问题
This commit is contained in:
parent
d169d96329
commit
811fc0b2dc
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,4 +5,5 @@ VM-source/Makefile
|
|||||||
*.rpm
|
*.rpm
|
||||||
*.pro.user
|
*.pro.user
|
||||||
.vscode
|
.vscode
|
||||||
|
package-script.zip
|
||||||
build-*-Debug
|
build-*-Debug
|
||||||
|
@ -28,6 +28,10 @@ from trans import *
|
|||||||
from DefaultSetting import *
|
from DefaultSetting import *
|
||||||
from Model import *
|
from Model import *
|
||||||
|
|
||||||
|
TMPDIR = os.getenv("TMPDIR")
|
||||||
|
if (TMPDIR == None):
|
||||||
|
TMPDIR = ""
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# 程序所需事件
|
# 程序所需事件
|
||||||
#################
|
#################
|
||||||
@ -1473,7 +1477,7 @@ fi
|
|||||||
debPackagePath = savePath
|
debPackagePath = savePath
|
||||||
print("g")
|
print("g")
|
||||||
else:
|
else:
|
||||||
debPackagePath = f"/tmp/{random.randint(0, 9999)}"
|
debPackagePath = f"{TMPDIR}/tmp/{random.randint(0, 9999)}"
|
||||||
#self.run_command(f"rm -rfv /tmp/{debPackagePath}")
|
#self.run_command(f"rm -rfv /tmp/{debPackagePath}")
|
||||||
print("f")
|
print("f")
|
||||||
# 为了避免删库,必须保证是 deb 文件构建目录才进行清空
|
# 为了避免删库,必须保证是 deb 文件构建目录才进行清空
|
||||||
@ -1929,12 +1933,14 @@ def ChangeWine():
|
|||||||
|
|
||||||
# 获取用户桌面目录
|
# 获取用户桌面目录
|
||||||
def get_desktop_path():
|
def get_desktop_path():
|
||||||
|
if (not os.path.exists(get_home() + "/.config/user-dirs.dirs")):
|
||||||
|
return f"{get_home()}/Desktop"
|
||||||
for line in open(get_home() + "/.config/user-dirs.dirs"): # 以行来读取配置文件
|
for line in open(get_home() + "/.config/user-dirs.dirs"): # 以行来读取配置文件
|
||||||
desktop_index = line.find("XDG_DESKTOP_DIR=\"") # 寻找是否有对应项,有返回 0,没有返回 -1
|
desktop_index = line.find("XDG_DESKTOP_DIR=\"") # 寻找是否有对应项,有返回 0,没有返回 -1
|
||||||
if desktop_index != -1: # 如果有对应项
|
if desktop_index != -1: # 如果有对应项
|
||||||
break # 结束循环
|
break # 结束循环
|
||||||
if desktop_index == -1: # 如果是提前结束,值一定≠-1,如果是没有提前结束,值一定=-1
|
if desktop_index == -1: # 如果是提前结束,值一定≠-1,如果是没有提前结束,值一定=-1
|
||||||
return -1
|
return f"{get_home()}/Desktop"
|
||||||
else:
|
else:
|
||||||
get = line[17:-2] # 截取桌面目录路径
|
get = line[17:-2] # 截取桌面目录路径
|
||||||
get_index = get.find("$HOME") # 寻找是否有对应的项,需要替换内容
|
get_index = get.find("$HOME") # 寻找是否有对应的项,需要替换内容
|
||||||
@ -1966,7 +1972,7 @@ def ReadDeb(unzip = False):
|
|||||||
if debPath == "":
|
if debPath == "":
|
||||||
return
|
return
|
||||||
# 分类讨论
|
# 分类讨论
|
||||||
path = f"/tmp/deb-unzip-{random.randint(0, 1000)}"
|
path = f"{TMPDIR}/tmp/deb-unzip-{random.randint(0, 1000)}"
|
||||||
# 新建文件夹
|
# 新建文件夹
|
||||||
os.system(f"mkdir -p '{path}'")
|
os.system(f"mkdir -p '{path}'")
|
||||||
# 解包 control 文件
|
# 解包 control 文件
|
||||||
@ -2312,9 +2318,12 @@ programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
|||||||
wine = {"deepin-wine": "deepin-wine", "deepin-wine5": "deepin-wine5", "wine": "wine", "wine64": "wine64", "deepin-wine5 stable": "deepin-wine5-stable", "deepin-wine6 stable": "deepin-wine6-stable", "spark-wine7-devel": "spark-wine7-devel", "ukylin-wine": "ukylin-wine", "okylin-wine": "okylin-wine", "spark-wine8": "spark-wine8", "spark-wine8-wow": "spark-wine8-wow", "deepin-wine6-vannila": "deepin-wine6-vannila", "deepin-wine8-stable": "deepin-wine8-stable", "spark-wine9": "spark-wine9", "spark-wine9-wow": "spark-wine9-wow", "spark-wine": "spark-wine"}
|
wine = {"deepin-wine": "deepin-wine", "deepin-wine5": "deepin-wine5", "wine": "wine", "wine64": "wine64", "deepin-wine5 stable": "deepin-wine5-stable", "deepin-wine6 stable": "deepin-wine6-stable", "spark-wine7-devel": "spark-wine7-devel", "ukylin-wine": "ukylin-wine", "okylin-wine": "okylin-wine", "spark-wine8": "spark-wine8", "spark-wine8-wow": "spark-wine8-wow", "deepin-wine6-vannila": "deepin-wine6-vannila", "deepin-wine8-stable": "deepin-wine8-stable", "spark-wine9": "spark-wine9", "spark-wine9-wow": "spark-wine9-wow", "spark-wine": "spark-wine"}
|
||||||
wineValue = {"deepin-wine": "deepin-wine", "deepin-wine5": "deepin-wine5", "wine": "wine", "wine64": "wine64", "deepin-wine5-stable": "deepin-wine5 stable", "deepin-wine6-stable": "deepin-wine6 stable", "spark-wine7-devel": "spark-wine7-devel", "ukylin-wine": "ukylin-wine", "okylin-wine": "okylin-wine", "spark-wine8": "spark-wine8", "spark-wine8-wow": "spark-wine8-wow", "deepin-wine6-vannila": "deepin-wine6-vannila", "deepin-wine8-stable": "deepin-wine8-stable", "spark-wine": "spark-wine"}
|
wineValue = {"deepin-wine": "deepin-wine", "deepin-wine5": "deepin-wine5", "wine": "wine", "wine64": "wine64", "deepin-wine5-stable": "deepin-wine5 stable", "deepin-wine6-stable": "deepin-wine6 stable", "spark-wine7-devel": "spark-wine7-devel", "ukylin-wine": "ukylin-wine", "okylin-wine": "okylin-wine", "spark-wine8": "spark-wine8", "spark-wine8-wow": "spark-wine8-wow", "deepin-wine6-vannila": "deepin-wine6-vannila", "deepin-wine8-stable": "deepin-wine8-stable", "spark-wine": "spark-wine"}
|
||||||
# 读取 wine 本地列表
|
# 读取 wine 本地列表
|
||||||
for i in os.listdir("/opt"):
|
try:
|
||||||
if os.path.exists(f"/opt/{i}/bin/wine"):
|
for i in os.listdir("/opt"):
|
||||||
wine[f"/opt/{i}/bin/wine"] = f"/opt/{i}/bin/wine"
|
if os.path.exists(f"/opt/{i}/bin/wine"):
|
||||||
|
wine[f"/opt/{i}/bin/wine"] = f"/opt/{i}/bin/wine"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
for i in os.listdir(f"{get_home()}/.deepinwine"):
|
for i in os.listdir(f"{get_home()}/.deepinwine"):
|
||||||
if os.path.exists(f"{get_home()}/.deepinwine/{i}/bin/wine"):
|
if os.path.exists(f"{get_home()}/.deepinwine/{i}/bin/wine"):
|
||||||
|
@ -37,24 +37,5 @@ class Trans():
|
|||||||
try:
|
try:
|
||||||
return self.word[text].replace("(", "(").replace(")", ")")
|
return self.word[text].replace("(", "(").replace(")", ")")
|
||||||
except:
|
except:
|
||||||
if self.unCloudTrans:
|
# 网络翻译接口已废弃
|
||||||
return text
|
return text
|
||||||
# 机翻
|
|
||||||
data = { 'doctype': 'json', 'type': 'auto','i': text}
|
|
||||||
jsonReturn = requests.post("http://fanyi.youdao.com/translate", data=data).json()["translateResult"]
|
|
||||||
transText = ""
|
|
||||||
for i in jsonReturn:
|
|
||||||
print(i[0])
|
|
||||||
transText += f'{i[0]["tgt"]}\n'
|
|
||||||
if "\n" in text:
|
|
||||||
transText = transText.replace("\n\n", "\n")[:-1]
|
|
||||||
else:
|
|
||||||
transText = transText[:-1]
|
|
||||||
self.word[text] = transText.replace("(", "(").replace(")", ")")
|
|
||||||
try:
|
|
||||||
with open(self.fileName, "w") as file:
|
|
||||||
file.write(json.dumps(self.word, ensure_ascii=False))
|
|
||||||
except:
|
|
||||||
traceback.print_exc()
|
|
||||||
print(f"{text}=>{transText}")
|
|
||||||
return transText
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user