From f8a1fc6d9c21ff274bf78f9d252b18097bcdf9cf Mon Sep 17 00:00:00 2001 From: adhu2018 <41824074+adhu2018@users.noreply.github.com> Date: Sat, 21 Jan 2023 18:07:29 +0800 Subject: [PATCH] up --- config.yaml | 3 ++- xapkInstaller.py | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config.yaml b/config.yaml index bed7058..f529061 100644 --- a/config.yaml +++ b/config.yaml @@ -5,4 +5,5 @@ ks-key-alias: "mykey" # `alias` key-pass: "pass:hhh4567" # `pass:password` or `file:/path/to/key.pwd` adb: "/path/to/adb.exe" # 错误时会检测系统环境中有没有adb java: "/path/to/java.exe" -aapt: "/path/to/aapt.exe" \ No newline at end of file +aapt: "/path/to/aapt.exe" +bundletool: "/path/to/bundletool.jar" \ No newline at end of file diff --git a/xapkInstaller.py b/xapkInstaller.py index 665efc2..8ac9fd7 100644 --- a/xapkInstaller.py +++ b/xapkInstaller.py @@ -254,19 +254,18 @@ def check(ADB=None) -> List[str]: # adb -s shell xxx if run.returncode: - sys.exit(msg) + log.error(msg) elif len(devices) == 0: - sys.exit("安装失败:手机未连接电脑!") + log.error("安装失败:手机未连接电脑!") elif len(devices) == 1: pass elif len(devices) > 1: - if input("检测到1个以上的设备,是否进行多设备安装?(y/N)").lower() != "y": - sys.exit("用户取消安装!") + log.info('检测到1个以上的设备,将进行多设备安装') return devices def check_sth(key, conf='config.yaml'): - if key not in ['adb', 'java', 'aapt']: + if key not in ['adb', 'java', 'aapt', 'bundletool']: return None conf = read_yaml(conf) path = conf.get(key, key) @@ -277,9 +276,12 @@ def check_sth(key, conf='config.yaml'): run, msg = run_msg([key, '--version']) elif key in ['aapt']: run, msg = run_msg([key, 'v']) + elif key in ['bundletool']: + run, msg = run_msg([check_sth('java'), '-jar', key+'.jar', 'version']) except FileNotFoundError: run = None if run and (run.returncode == 0): + log.info(f'check_sth({key!r})') log.info(msg.strip()) return key log.error(f'未配置{key}') @@ -698,6 +700,8 @@ def main(root: str, one: str) -> bool: try: ADB = check_sth('adb') devices = check(ADB) + if len(devices) == 0: + sys.exit("安装失败:手机未连接电脑!") suffix = os.path.splitext(os.path.split(copy[1])[1])[1] for device in devices: