Merge pull request #14 from xBelladonna/clock/toml

Follow migration to toml for clock plugin
This commit is contained in:
Simone Margaritelli 2020-06-26 14:17:08 +02:00 committed by GitHub
commit 4c61cc51c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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