save in dotted format

This commit is contained in:
dadav
2020-04-01 08:17:22 +02:00
parent 76b71f5c3f
commit 9a22321799
5 changed files with 55 additions and 7 deletions

View File

@ -5,6 +5,9 @@ import threading
import importlib, importlib.util
import logging
from pwnagotchi.ui import view
from pwnagotchi import config
from pwnagotchi.utils import save_config
default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default")
loaded = {}
@ -36,11 +39,17 @@ def toggle_plugin(name, enable=True):
returns True if changed, otherwise False
"""
global loaded, database
global loaded, database, config
if config:
config['main']['plugins'][name] = enable
save_config(config, '/etc/pwnagotchi/config.toml')
if not enable and name in loaded:
if getattr(loaded[name], 'on_unload', None):
loaded[name].on_unload(view.ROOT)
del loaded[name]
return True
if enable and name in database and name not in loaded:

View File

@ -2,8 +2,8 @@ import logging
import json
import toml
import _thread
import pwnagotchi.plugins as plugins
from pwnagotchi import restart
from pwnagotchi import restart, plugins
from pwnagotchi.utils import save_config
from flask import abort
from flask import render_template_string
@ -500,9 +500,8 @@ class WebConfig(plugins.Plugin):
if path == "save-config":
try:
parsed_toml = toml.loads(request.get_json())
with open('/etc/pwnagotchi/config.toml') as config_file:
toml.dump(parsed_toml, config_file)
save_config(parsed_toml, '/etc/pwnagotchi/config.toml')
_thread.start_new_thread(restart, (self.mode,))
return "success"
except Exception as ex: