From 325dbb472aefeee69071e9197f1558a1f3f9e9d9 Mon Sep 17 00:00:00 2001 From: Rikka <1103670381@qq.com> Date: Thu, 12 Jan 2023 02:33:51 +0800 Subject: [PATCH] Update *run* method --- waydroid_extras.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/waydroid_extras.py b/waydroid_extras.py index 4bf0fdb..672ca04 100755 --- a/waydroid_extras.py +++ b/waydroid_extras.py @@ -62,12 +62,15 @@ def restart(): DBusContainerService().Start(waydroid_session) def run(args): - try: - result = subprocess.run(args=args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - result.check_returncode() - except subprocess.CalledProcessError as e: - print("\nOutput: ", e.stderr.decode("utf-8") ) - raise + result = subprocess.run(args=args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if result.stderr: + print(result.stderr.decode("utf-8")) + raise subprocess.CalledProcessError( + returncode = result.returncode, + cmd = result.args, + stderr = result.stderr + ) + return result def install_gapps(): @@ -153,8 +156,8 @@ def get_android_id(): sqs = """ SELECT * FROM main WHERE name='android_id' """ - queryout = subprocess.check_output(["sqlite3", "/var/lib/waydroid/data/data/com.google.android.gsf/databases/gservices.db", sqs.strip()], stderr=subprocess.STDOUT) - print(queryout.decode().replace("android_id|", "").strip()) + queryout = run(["sqlite3", "/var/lib/waydroid/data/data/com.google.android.gsf/databases/gservices.db", sqs.strip()]) + print(queryout.stdout.decode().replace("android_id|", "").strip()) print(" ^----- Open https://google.com/android/uncertified/?pli=1") print(" Login with your google id then submit the form with id shown above") except subprocess.CalledProcessError as e: