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