From 4d15b6153ca1fa4b854b9ec8ed712ff6383b58d1 Mon Sep 17 00:00:00 2001 From: Rikka <1103670381@qq.com> Date: Wed, 25 Jan 2023 19:51:07 +0800 Subject: [PATCH] Fix resize error log --- stuffs/microg.py | 3 ++- stuffs/smartdock.py | 3 ++- tools/helper.py | 19 +++++++------------ tools/images.py | 10 ++-------- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/stuffs/microg.py b/stuffs/microg.py index 0f0d090..bfc847a 100644 --- a/stuffs/microg.py +++ b/stuffs/microg.py @@ -84,7 +84,8 @@ class MicroG(General): print("\r\tPlease start WayDroid for further setup {}".format(list[index%4]), end="") index += 1 sleep(5) - print() + if index != 0: + print() Logger.info("Signature spoofing") run("waydroid shell pm grant com.google.android.gms android.permission.FAKE_PACKAGE_SIGNATURE".split()) run("waydroid shell pm grant com.android.vending android.permission.FAKE_PACKAGE_SIGNATURE".split()) diff --git a/stuffs/smartdock.py b/stuffs/smartdock.py index de9b2f9..b8a8e99 100644 --- a/stuffs/smartdock.py +++ b/stuffs/smartdock.py @@ -31,5 +31,6 @@ class Smartdock(General): print("\r\tPlease start WayDroid for further setup {}".format(list[index%4]), end="") index += 1 sleep(5) - print() + if index != 0: + print() run(["waydroid", "shell", "cmd", "package", "set-home-activity", "cu.axel.smartdock/.activities.LauncherActivity"]) diff --git a/tools/helper.py b/tools/helper.py index 649a7fe..bc92890 100644 --- a/tools/helper.py +++ b/tools/helper.py @@ -1,4 +1,5 @@ import os +import re import platform import re import subprocess @@ -18,24 +19,18 @@ def get_download_dir(): os.makedirs(download_loc) return download_loc -def run(args: list, env = None, ignore = None): - result = subprocess.run( - args=args, - env=env, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE - ) - +def run(args, ignore=""): + result = subprocess.run(args=args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # print(result.stdout.decode()) if result.stderr: error = result.stderr.decode("utf-8") - if ignore and re.match(ignore, error): + if re.match(ignore, error): return result Logger.error(error) raise subprocess.CalledProcessError( - returncode=result.returncode, - cmd=result.args, - stderr=result.stderr + returncode = result.returncode, + cmd = result.args, + stderr = result.stderr ) return result diff --git a/tools/images.py b/tools/images.py index b626c37..22ff095 100644 --- a/tools/images.py +++ b/tools/images.py @@ -24,14 +24,8 @@ def umount(mount_point, exists=True): mount_point)) def resize(img_file, size): - try: - run(["e2fsck", "-y", "-f", img_file]) - except subprocess.CalledProcessError: - pass - try: - run(["resize2fs", img_file, size]) - except subprocess.CalledProcessError: - pass + run(["sudo", "e2fsck", "-y", "-f", img_file], "^e2fsck \d+\.\d+\.\d (.+)\n$") + run(["sudo", "resize2fs", img_file, size], "^resize2fs \d+\.\d+\.\d (.+)\n$") def get_image_dir(): # Read waydroid config to get image location