#!/usr/bin/env python import os import json def change_key_file(): key_file = '/app/base/var/reg/CRB-Reductor.key' d = json.load(open(key_file)) d['CRB-Reductor']['registred'] = 1 d['CRB-Reductor']['activated'] = True dump = json.dumps(d, sort_keys=True, indent=4) with open(key_file, 'w') as f: f.write(dump) def change_reg_file(): key_file = '/app/base/var/reg/CRB-Reductor.reg' d = json.load(open(key_file)) if os.path.isdir('/app/'): apps = os.listdir('/app/') for app in apps: if os.path.isdir('/app/{0}'.format(app)) and os.path.exists('/app/{0}/VERSION'.format(app)): if app not in d['CRB-Reductor']['apps']: d['CRB-Reductor']['apps'].append(app) dump = json.dumps(d, sort_keys=True, indent=4) with open(key_file, 'w') as f: f.write(dump) if __name__ == '__main__': change_key_file() change_reg_file()