Write prop to /var/lib/waydroid/waydroid.cfg
This commit is contained in:
parent
556f277fec
commit
e305dd1dc4
2 changed files with 17 additions and 19 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import configparser
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
|
|
@ -60,27 +61,25 @@ class General:
|
|||
z.extractall(self.extract_to)
|
||||
|
||||
def add_props(self):
|
||||
with open(os.path.join("/var/lib/waydroid/waydroid_base.prop"), "r") as propfile:
|
||||
prop_content = propfile.read()
|
||||
for key in self.apply_props:
|
||||
if key not in prop_content:
|
||||
prop_content = prop_content+"\n{key}={value}".format(key=key, value=self.apply_props[key])
|
||||
else:
|
||||
p = re.compile(r"^{key}=.*$".format(key=key), re.M)
|
||||
prop_content = re.sub(p, "{key}={value}".format(key=key, value=self.apply_props[key]), prop_content)
|
||||
with open(os.path.join("/var/lib/waydroid/waydroid_base.prop"), "w") as propfile:
|
||||
propfile.write(prop_content)
|
||||
cfg = configparser.ConfigParser()
|
||||
cfg.read("/var/lib/waydroid/waydroid.cfg")
|
||||
|
||||
for key in self.apply_props.keys():
|
||||
cfg.set('properties', key, self.apply_props[key])
|
||||
|
||||
with open("/var/lib/waydroid/waydroid.cfg", "w") as f:
|
||||
cfg.write(f)
|
||||
|
||||
def remove_props(self):
|
||||
with open(os.path.join("/var/lib/waydroid/waydroid_base.prop"), "r") as propfile:
|
||||
prop_content = propfile.read()
|
||||
for key in self.apply_props:
|
||||
if key in prop_content:
|
||||
p = re.compile(r"^{key}=.*(\n)*".format(key=key), re.M)
|
||||
prop_content = re.sub(p, "", prop_content)
|
||||
with open(os.path.join("/var/lib/waydroid/waydroid_base.prop"), "w") as propfile:
|
||||
propfile.write(prop_content)
|
||||
cfg = configparser.ConfigParser()
|
||||
cfg.read("/var/lib/waydroid/waydroid.cfg")
|
||||
|
||||
for key in self.apply_props.keys():
|
||||
cfg.remove_option('properties', key)
|
||||
|
||||
with open("/var/lib/waydroid/waydroid.cfg", "w") as f:
|
||||
cfg.write(f)
|
||||
|
||||
def mount(self):
|
||||
img = os.path.join(images.get_image_dir(), self.partition+".img")
|
||||
mount_point = ""
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ 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
|
||||
|
|
|
|||
Loading…
Reference in a new issue