Merge pull request #79 from ayasa520/prop

prop: write prop to /var/lib/waydroid/waydroid.cfg
pull/81/head
Casu Al Snek 3 years ago committed by GitHub
commit d770a95995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,3 +1,4 @@
import configparser
import os import os
import re import re
import zipfile import zipfile
@ -54,16 +55,14 @@ 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 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")

Loading…
Cancel
Save