uengine-runner/uengine-useadb

74 lines
2.6 KiB
Plaintext
Raw Normal View History

2021-08-30 17:49:12 +08:00
#!/usr/bin/env python3
#########################################
2022-07-23 12:44:33 +08:00
# 版本1.8.0
# 更新时间2022年07月23日
2021-08-30 17:49:12 +08:00
#########################################
import os
import sys
import traceback
import updatekiller
2022-07-23 12:44:33 +08:00
import PyQt5.QtWidgets as QtWidgets
2021-08-30 17:49:12 +08:00
########################
#
########################
# 写入文本文档
def write_txt(path: "路径", things: "内容")->"写入文本文档":
file = open(path, 'w', encoding='UTF-8') # 设置文件对象
file.write(things) # 写入文本
file.close() # 关闭文本对象
# 读取文本文档
def readtxt(path: "路径")->"读取文本文档":
f = open(path, "r") # 设置文件对象
str = f.read() # 获取内容
f.close() # 关闭文本对象
return str # 返回结果
###################
# 判断是不是 root
###################
2022-07-23 12:44:33 +08:00
app = QtWidgets.QApplication(sys.argv)
2021-08-30 17:49:12 +08:00
if os.geteuid() != 0:
print("不是以 root 权限运行本程序!")
2022-07-23 12:44:33 +08:00
QtWidgets.QMessageBox.critical(None, "错误", "不是以 root 权限运行本程序!")
2021-08-30 17:49:12 +08:00
sys.exit(1)
###################
#
###################
try:
2022-07-23 12:44:33 +08:00
if sys.argv[1] == "1" and QtWidgets.QMessageBox.question(None, "提示", "你确定要删除吗?", QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Cancel) == QtWidgets.QMessageBox.Ok:
2021-08-30 17:49:12 +08:00
os.remove("/data/uengine/data/data/misc/adb/adb_keys")
2022-07-23 12:44:33 +08:00
QtWidgets.QMessageBox.information(None, "提示", "完成")
2021-08-30 17:49:12 +08:00
except:
traceback.print_exc()
2022-07-23 12:44:33 +08:00
QtWidgets.QMessageBox.critical(None, "错误", traceback.format_exc())
2021-08-30 17:49:12 +08:00
sys.exit(2)
if sys.argv[1] == "1":
sys.exit(0)
2022-07-23 12:44:33 +08:00
if QtWidgets.QMessageBox.question(None, "提示", '''请阅读以下提示然后确定是否继续:
2021-08-30 17:49:12 +08:00
1、安装后即可使用 adb 连接 UEngine;
2、重置 UEngine 或 adb 就需要重新设置该支持补丁;
2022-07-23 12:44:33 +08:00
3、需要 root 权限;''') == QtWidgets.QMessageBox.No:
2021-08-30 17:49:12 +08:00
sys.exit(0)
# 写入(需要 root
if not os.path.exists("/data/uengine/data/data/misc/adb"):
2022-07-23 12:44:33 +08:00
QtWidgets.QMessageBox.critical(None, "错误", "无法读取 UEngine 数据!")
2021-08-30 17:49:12 +08:00
sys.exit(1)
try:
things = readtxt(sys.argv[2])
adbKey = []
# 提取内容
for i in things.split('\n'):
adbKey.append(i[0: i.find(" ")])
old = ""
if os.path.exists("/data/uengine/data/data/misc/adb/adb_keys"):
old = readtxt("/data/uengine/data/data/misc/adb/adb_keys") + "\n"
write_txt("/data/uengine/data/data/misc/adb/adb_keys", old + "\n".join(adbKey))
2022-07-23 12:44:33 +08:00
QtWidgets.QMessageBox.information(None, "提示", "完成")
2021-08-30 17:49:12 +08:00
except:
traceback.print_exc()
2022-07-23 12:44:33 +08:00
QtWidgets.QMessageBox.information(None, "错误", traceback.format_exc())
sys.exit(2)