plugins are now enabled by config.yml or custom.yml (closes )

This commit is contained in:
Simone Margaritelli 2019-10-03 23:24:48 +02:00
parent 56b1d21bb0
commit bbe5540c43
8 changed files with 13 additions and 14 deletions
sdcard/rootfs/root/pwnagotchi

@ -3,7 +3,11 @@ main:
# currently implemented: en (default), de, nl, it
lang: en
# custom plugins path, if null only default plugins with be loaded
plugins: null
custom_plugins:
# which plugins to load and enable
plugins:
- gps
- twitter
# monitor interface to use
iface: mon0
# command to run to bring the mon interface up in case it's not up already
@ -15,7 +19,9 @@ main:
# if true, will not restart the wifi module
no_restart: false
# access points to ignore
whitelist: []
whitelist:
- EXAMPLE_NETWORK
- ANOTHER_EXAMPLE_NETWORK
# if not null, filter access points by this regular expression
filter: null
# cryptographic key for identity

@ -1,5 +1,4 @@
#!/usr/bin/python3
import os
import argparse
import time
import logging
@ -33,9 +32,9 @@ args = parser.parse_args()
config = utils.load_config(args)
utils.setup_logging(args, config)
plugins.load_from_path(plugins.default_path)
if 'plugins' in config['main'] and config['main']['plugins'] is not None:
plugins.load_from_path(config['main']['plugins'])
plugins.load_from_path(plugins.default_path, enabled=config['main']['plugins'])
if 'custom_plugins' in config['main'] and config['main']['custom_plugins'] is not None:
plugins.load_from_path(config['main']['custom_plugins'], enabled=config['main']['plugins'])
plugins.on('loaded')

@ -27,14 +27,13 @@ def load_from_file(filename):
return plugin_name, instance
def load_from_path(path):
def load_from_path(path, enabled=()):
global loaded
for filename in glob.glob(os.path.join(path, "*.py")):
name, plugin = load_from_file(filename)
if name in loaded:
raise Exception("plugin %s already loaded from %s" % (name, plugin.__file__))
elif not plugin.__enabled__:
elif name not in enabled:
# print("plugin %s is not enabled" % name)
pass
else:

@ -3,7 +3,6 @@ __version__ = '1.0.0'
__name__ = 'hello_world'
__license__ = 'GPL3'
__description__ = 'An example plugin for pwnagotchi that implements all the available callbacks.'
__enabled__ = False # IMPORTANT: set this to True to enable your plugin.
import logging

@ -3,7 +3,6 @@ __version__ = '1.0.0'
__name__ = 'gps'
__license__ = 'GPL3'
__description__ = 'Save GPS coordinates whenever an handshake is captured.'
__enabled__ = True # set to false if you just don't use GPS
import logging
import json

@ -7,7 +7,6 @@ __version__ = '1.0.0'
__name__ = 'memtemp'
__license__ = 'GPL3'
__description__ = 'A plugin that will add a memory and temperature indicator'
__enabled__ = False
import struct

@ -3,7 +3,6 @@ __version__ = '1.0.0'
__name__ = 'twitter'
__license__ = 'GPL3'
__description__ = 'This plugin creates tweets about the recent activity of pwnagotchi'
__enabled__ = True
import logging
from pwnagotchi.voice import Voice

@ -12,7 +12,6 @@ __version__ = '1.0.0'
__name__ = 'ups_lite'
__license__ = 'GPL3'
__description__ = 'A plugin that will add a voltage indicator for the UPS Lite v1.1'
__enabled__ = False
import struct