Move config to static-data
This commit is contained in:
parent
c3d86eafa1
commit
0af569acff
@ -59,8 +59,11 @@ class Onionr:
|
||||
if not data_exists:
|
||||
os.mkdir('data/')
|
||||
|
||||
exists = os.path.exists(config.get_config_file())
|
||||
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
|
||||
if os.path.exists('static-data/default_config.json'):
|
||||
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:
|
||||
config.save()
|
||||
config.reload() # this will read the configuration file into memory
|
||||
@ -454,7 +457,7 @@ class Onionr:
|
||||
|
||||
os.makedirs(plugins.get_plugins_folder(plugin_name))
|
||||
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)
|
||||
plugins.enable(plugin_name, self)
|
||||
|
16
onionr/static-data/default_config.json
Normal file
16
onionr/static-data/default_config.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"devmode": true,
|
||||
"dc_response": true,
|
||||
|
||||
"log": {
|
||||
"file": {
|
||||
"output": true,
|
||||
"path": "data/output.log"
|
||||
},
|
||||
|
||||
"console": {
|
||||
"output": true,
|
||||
"color": true
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user