Browse Source

using ini for config instead of json

ini_config
Raphael Roberts 7 years ago
parent
commit
b3184b2c4a
  1. 18
      adb.py
  2. 15
      config.ini
  3. 14
      load_things.py
  4. 1
      output

18
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()

15
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

14
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)
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))

1
output

@ -1 +0,0 @@
'X:\\Users\\Ralphie\\Google Drive\\Python\\lib\\shlex.py'
Loading…
Cancel
Save