Use configparser to read waydroid config
This commit is contained in:
parent
d72bf018d1
commit
5f6fc21c38
3 changed files with 20 additions and 7 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
import re
|
import configparser
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
import dbus
|
import dbus
|
||||||
from tools.helper import run
|
from tools.helper import run
|
||||||
|
from tools.logger import Logger
|
||||||
|
|
||||||
def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"):
|
def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"):
|
||||||
return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf)
|
return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf)
|
||||||
|
|
@ -16,11 +19,20 @@ def use_dbus():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def use_overlayfs():
|
def use_overlayfs():
|
||||||
with open("/var/lib/waydroid/waydroid.cfg") as f:
|
cfg = configparser.ConfigParser()
|
||||||
cont=f.read()
|
cfg_file = os.environ.get("WAYDROID_CONFIG", "/var/lib/waydroid/waydroid.cfg")
|
||||||
if re.search("mount_overlays[ \t]*=[ \t]*True", cont):
|
if not os.path.isfile(cfg_file):
|
||||||
return True
|
Logger.error("Cannot locate waydroid config file, reinit wayland and try again!")
|
||||||
return False
|
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():
|
def get_session():
|
||||||
return DBusContainerService().GetSession()
|
return DBusContainerService().GetSession()
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ def shell(arg: str, env: Optional[str] = None):
|
||||||
|
|
||||||
def download_file(url, f_name):
|
def download_file(url, f_name):
|
||||||
md5 = ""
|
md5 = ""
|
||||||
|
# response = requests.get(url, stream=True, proxies=os.getenv("https_proxy","HTTPS_PROXY"))
|
||||||
response = requests.get(url, stream=True)
|
response = requests.get(url, stream=True)
|
||||||
total_size_in_bytes = int(response.headers.get('content-length', 0))
|
total_size_in_bytes = int(response.headers.get('content-length', 0))
|
||||||
block_size = 1024 # 1 Kibibyte
|
block_size = 1024 # 1 Kibibyte
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,6 @@ def get_image_dir():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
cfg.read(cfg_file)
|
cfg.read(cfg_file)
|
||||||
if "waydroid" not in cfg:
|
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)
|
sys.exit(1)
|
||||||
return cfg["waydroid"]["images_path"]
|
return cfg["waydroid"]["images_path"]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue