Move config to static-data

master
Arinerron 2018-05-04 00:14:27 -07:00
parent c3d86eafa1
commit 0af569acff
No known key found for this signature in database
GPG Key ID: 99383627861C62F0
3 changed files with 23 additions and 4 deletions

View File

@ -59,8 +59,11 @@ class Onionr:
if not data_exists: if not data_exists:
os.mkdir('data/') os.mkdir('data/')
exists = os.path.exists(config.get_config_file()) if os.path.exists('static-data/default_config.json'):
config.set_config({'devmode': True, 'log': {'file': {'output': True, 'path': 'data/output.log'}, 'console': {'output': True, 'color': True}}}) # this is the default config, it will be overwritten if a config file already exists. Else, it saves it config.set_config(json.loads(open('static-data/default_config.json').read())) # this is the default config, it will be overwritten if a config file already exists. Else, it saves it
else:
# the default config file doesn't exist, try hardcoded config
config.set_config({'devmode': True, 'log': {'file': {'output': True, 'path': 'data/output.log'}, 'console': {'output': True, 'color': True}}})
if not exists: if not exists:
config.save() config.save()
config.reload() # this will read the configuration file into memory config.reload() # this will read the configuration file into memory
@ -454,7 +457,7 @@ class Onionr:
os.makedirs(plugins.get_plugins_folder(plugin_name)) os.makedirs(plugins.get_plugins_folder(plugin_name))
with open(plugins.get_plugins_folder(plugin_name) + '/main.py', 'a') as main: with open(plugins.get_plugins_folder(plugin_name) + '/main.py', 'a') as main:
main.write(open('static-data/default_plugin.txt').read().replace('$user', os.getlogin()).replace('$date', datetime.datetime.now().strftime('%Y-%m-%d'))) main.write(open('static-data/default_plugin.py').read().replace('$user', os.getlogin()).replace('$date', datetime.datetime.now().strftime('%Y-%m-%d')))
logger.info('Enabling plugin "%s"...' % plugin_name) logger.info('Enabling plugin "%s"...' % plugin_name)
plugins.enable(plugin_name, self) plugins.enable(plugin_name, self)
@ -546,7 +549,7 @@ class Onionr:
''' '''
Displays statistics and exits Displays statistics and exits
''' '''
logger.info('Our pubkey: ' + self.onionrCore._crypto.pubKey) logger.info('Our pubkey: ' + self.onionrCore._crypto.pubKey)
logger.info('Our address: ' + self.get_hostname()) logger.info('Our address: ' + self.get_hostname())
return return

View File

@ -0,0 +1,16 @@
{
"devmode": true,
"dc_response": true,
"log": {
"file": {
"output": true,
"path": "data/output.log"
},
"console": {
"output": true,
"color": true
}
}
}