diff --git a/adb.py b/adb.py index 99b4be8..d6ed05c 100644 --- a/adb.py +++ b/adb.py @@ -10,9 +10,9 @@ from android_db import AndroidSQLConn from load_things import loaded from decode_parcel import decode_parcel debug = True -defaults = loaded.defaults +config = loaded.config keycodes = loaded.keycodes -exe = defaults.exe +exe = config.defaults.exe exists = '''if [ -e "{file}" ]; then if [ -d "{file}" ]; then echo "directory" @@ -168,7 +168,7 @@ class Device: if os.path.exists(local): last = os.path.split(local)[-1] real_dir = local - local = os.path.join(defaults['local']['temp'],last) + local = os.path.join(config['local']['temp'],last) merge_flag = True try: self.adb("pull","-a",remote,local) @@ -232,7 +232,7 @@ class Device: def backup(self,*partitions,name = None): if self.mode != 'recovery': self.reboot('recovery') - backupdir = defaults['local']['TWRP'] + backupdir = config['local']['twrp'] options_dict = { "system": "S", "data": "D", @@ -263,13 +263,13 @@ class Device: if os.path.exists(name): local_name = name name = os.path.split(name)[-1] - update_path = '{}/{}'.format(defaults['remote']['updates'],name) - if not self.exists(defaults['remote']['updates']): - self.sudo('mkdir',defaults['remote']['updates']) + update_path = '{}/{}'.format(config['remote']['updates'],name) + if not self.exists(config['remote']['updates']): + self.sudo('mkdir',config['remote']['updates']) if not self.exists(update_path): - self.push(local_name,defaults['remote']['updates']) + self.push(local_name,config['remote']['updates']) else: - update_path = '{}/{}'.format(defaults['remote']['updates'],name) + update_path = '{}/{}'.format(config['remote']['updates'],name) self.shell("twrp","install",update_path) if __name__ == "__main__" and debug: d = Device.prim_device() \ No newline at end of file diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..c71a2f5 --- /dev/null +++ b/config.ini @@ -0,0 +1,15 @@ +[defaults] +date_format = %Y-%m-%d_%H.%M.%S +exe = c:\Program Files (x86)\ADB\adb.exe +[remote] +messages = /data/user_de/0/com.android.providers.telephony/databases/mmssms.db +screenshots = /sdcard/Pictures/Screenshots +titanium_backup = /sdcard/TitaniumBackup +updates = /data/lineageos_updates +[local] +twrp = %userprofile%\Android\TWRP +messages = %userprofile%\Android\messages +screenshots = %userprofile%\Pictures\Screenshots +temp = %userprofile%\Android\harbor +titanium_backup = %userprofile%\Android\TitaniumBackup +updates = %userprofile%\Downloads\sort\phone_updates \ No newline at end of file diff --git a/load_things.py b/load_things.py index e37ec0a..af1721e 100644 --- a/load_things.py +++ b/load_things.py @@ -1,10 +1,14 @@ import json import munch import os +import configparser path = os.path.dirname(__file__) -with open(os.path.join(path,'defaults.json')) as d,open(os.path.join(path,'keycodes.json')) as k: - defaults = munch.munchify(json.load(d)) +parser = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation()) +parser.read(os.path.join(path,'config.ini')) +with open(os.path.join(path,'keycodes.json')) as k: + keycodes = munch.munchify(json.load(k)) -for key,value in defaults['local'].items(): - defaults['local'][key] = os.path.expandvars(value) -loaded = munch.Munch(defaults = defaults,keycodes = keycodes) \ No newline at end of file +config = parser.__dict__['_sections'] +for key,value in config['local'].items(): + config['local'][key] = os.path.expandvars(value) +loaded = munch.munchify(dict(config = config,keycodes = keycodes)) \ No newline at end of file diff --git a/output b/output deleted file mode 100644 index 36487b9..0000000 --- a/output +++ /dev/null @@ -1 +0,0 @@ -'X:\\Users\\Ralphie\\Google Drive\\Python\\lib\\shlex.py' \ No newline at end of file