Follow migration to toml

Uses toml config with fallback to yaml if not toml exists.

Signed-off-by: xBelladonna <isabelladonnamoore@users.noreply.github.com>
This commit is contained in:
xBelladonna 2020-01-19 21:17:29 +09:30
parent e8d3628336
commit bd6067128d

View File

@ -5,6 +5,8 @@ import pwnagotchi.plugins as plugins
import pwnagotchi import pwnagotchi
import logging import logging
import datetime import datetime
import os
import toml
import yaml import yaml
@ -19,8 +21,12 @@ class PwnClock(plugins.Plugin):
def on_ui_setup(self, ui): def on_ui_setup(self, ui):
memenable = False memenable = False
with open('/etc/pwnagotchi/config.yml') as f: config_is_toml = True if os.path.exists(
data = yaml.load(f, Loader=yaml.FullLoader) '/etc/pwnagotchi/config.toml') else False
config_path = '/etc/pwnagotchi/config.toml' if config_is_toml else '/etc/pwnagotchi/config.yml'
with open(config_path) as f:
data = toml.load(f) if config_is_toml else yaml.load(
f, Loader=yaml.FullLoader)
if 'memtemp' in data["main"]["plugins"]: if 'memtemp' in data["main"]["plugins"]:
if 'enabled' in data["main"]["plugins"]["memtemp"]: if 'enabled' in data["main"]["plugins"]["memtemp"]: