diff --git a/tools/container.py b/tools/container.py index 2884b60..aaf8703 100644 --- a/tools/container.py +++ b/tools/container.py @@ -1,6 +1,9 @@ -import re +import configparser +import os +import sys import dbus from tools.helper import run +from tools.logger import Logger def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"): return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf) @@ -16,11 +19,20 @@ def use_dbus(): return True def use_overlayfs(): - with open("/var/lib/waydroid/waydroid.cfg") as f: - cont=f.read() - if re.search("mount_overlays[ \t]*=[ \t]*True", cont): - return True - return False + cfg = configparser.ConfigParser() + cfg_file = os.environ.get("WAYDROID_CONFIG", "/var/lib/waydroid/waydroid.cfg") + if not os.path.isfile(cfg_file): + Logger.error("Cannot locate waydroid config file, reinit wayland and try again!") + sys.exit(1) + cfg.read(cfg_file) + if "waydroid" not in cfg: + Logger.error("Required entry in config was not found, Cannot continue!") + if "mount_overlays" not in cfg["waydroid"]: + return False + if cfg["waydroid"]["mount_overlays"]=="True": + return True + return False + def get_session(): return DBusContainerService().GetSession() diff --git a/tools/helper.py b/tools/helper.py index 23b86fd..0f6a833 100644 --- a/tools/helper.py +++ b/tools/helper.py @@ -90,6 +90,7 @@ def shell(arg: str, env: Optional[str] = None): def download_file(url, f_name): md5 = "" + # response = requests.get(url, stream=True, proxies=os.getenv("https_proxy","HTTPS_PROXY")) response = requests.get(url, stream=True) total_size_in_bytes = int(response.headers.get('content-length', 0)) block_size = 1024 # 1 Kibibyte diff --git a/tools/images.py b/tools/images.py index 78a0e2e..9d6cd92 100644 --- a/tools/images.py +++ b/tools/images.py @@ -36,6 +36,6 @@ def get_image_dir(): sys.exit(1) cfg.read(cfg_file) if "waydroid" not in cfg: - Logger.error("ERROR: Required entry in config was not found, Cannot continue!") #magisk + Logger.error("Required entry in config was not found, Cannot continue!") #magisk sys.exit(1) return cfg["waydroid"]["images_path"]