mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Version 2.3.7
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (pwnagotchi-torch-64)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (pwnagotchi)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
@ -1,15 +1,17 @@
|
|||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import _thread
|
|
||||||
import threading
|
import threading
|
||||||
import importlib, importlib.util
|
import importlib, importlib.util
|
||||||
import logging
|
import logging
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default")
|
default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default")
|
||||||
loaded = {}
|
loaded = {}
|
||||||
database = {}
|
database = {}
|
||||||
locks = {}
|
locks = {}
|
||||||
|
|
||||||
|
THREAD_POOL_SIZE = 10
|
||||||
|
executor = ThreadPoolExecutor(max_workers=THREAD_POOL_SIZE)
|
||||||
|
|
||||||
class Plugin:
|
class Plugin:
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -28,7 +30,6 @@ class Plugin:
|
|||||||
if cb is not None and callable(cb):
|
if cb is not None and callable(cb):
|
||||||
locks["%s::%s" % (plugin_name, attr_name)] = threading.Lock()
|
locks["%s::%s" % (plugin_name, attr_name)] = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
def toggle_plugin(name, enable=True):
|
def toggle_plugin(name, enable=True):
|
||||||
"""
|
"""
|
||||||
Load or unload a plugin
|
Load or unload a plugin
|
||||||
@ -42,7 +43,7 @@ def toggle_plugin(name, enable=True):
|
|||||||
global loaded, database
|
global loaded, database
|
||||||
|
|
||||||
if pwnagotchi.config:
|
if pwnagotchi.config:
|
||||||
if name not in pwnagotchi.config['main']['plugins']:
|
if not name in pwnagotchi.config['main']['plugins']:
|
||||||
pwnagotchi.config['main']['plugins'][name] = dict()
|
pwnagotchi.config['main']['plugins'][name] = dict()
|
||||||
pwnagotchi.config['main']['plugins'][name]['enabled'] = enable
|
pwnagotchi.config['main']['plugins'][name]['enabled'] = enable
|
||||||
save_config(pwnagotchi.config, '/etc/pwnagotchi/config.toml')
|
save_config(pwnagotchi.config, '/etc/pwnagotchi/config.toml')
|
||||||
@ -67,12 +68,10 @@ def toggle_plugin(name, enable=True):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def on(event_name, *args, **kwargs):
|
def on(event_name, *args, **kwargs):
|
||||||
for plugin_name in loaded.keys():
|
for plugin_name in loaded.keys():
|
||||||
one(plugin_name, event_name, *args, **kwargs)
|
one(plugin_name, event_name, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def locked_cb(lock_name, cb, *args, **kwargs):
|
def locked_cb(lock_name, cb, *args, **kwargs):
|
||||||
global locks
|
global locks
|
||||||
|
|
||||||
@ -82,7 +81,6 @@ def locked_cb(lock_name, cb, *args, **kwargs):
|
|||||||
with locks[lock_name]:
|
with locks[lock_name]:
|
||||||
cb(*args, *kwargs)
|
cb(*args, *kwargs)
|
||||||
|
|
||||||
|
|
||||||
def one(plugin_name, event_name, *args, **kwargs):
|
def one(plugin_name, event_name, *args, **kwargs):
|
||||||
global loaded
|
global loaded
|
||||||
|
|
||||||
@ -94,13 +92,11 @@ def one(plugin_name, event_name, *args, **kwargs):
|
|||||||
try:
|
try:
|
||||||
lock_name = "%s::%s" % (plugin_name, cb_name)
|
lock_name = "%s::%s" % (plugin_name, cb_name)
|
||||||
locked_cb_args = (lock_name, callback, *args, *kwargs)
|
locked_cb_args = (lock_name, callback, *args, *kwargs)
|
||||||
_thread.start_new_thread(locked_cb, locked_cb_args)
|
executor.submit(locked_cb, *locked_cb_args)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e))
|
logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e))
|
||||||
logging.error(e, exc_info=True)
|
logging.error(e, exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def load_from_file(filename):
|
def load_from_file(filename):
|
||||||
logging.debug("loading %s" % filename)
|
logging.debug("loading %s" % filename)
|
||||||
plugin_name = os.path.basename(filename.replace(".py", ""))
|
plugin_name = os.path.basename(filename.replace(".py", ""))
|
||||||
@ -109,7 +105,6 @@ def load_from_file(filename):
|
|||||||
spec.loader.exec_module(instance)
|
spec.loader.exec_module(instance)
|
||||||
return plugin_name, instance
|
return plugin_name, instance
|
||||||
|
|
||||||
|
|
||||||
def load_from_path(path, enabled=()):
|
def load_from_path(path, enabled=()):
|
||||||
global loaded, database
|
global loaded, database
|
||||||
logging.debug("loading plugins from %s - enabled: %s" % (path, enabled))
|
logging.debug("loading plugins from %s - enabled: %s" % (path, enabled))
|
||||||
@ -125,7 +120,6 @@ def load_from_path(path, enabled=()):
|
|||||||
|
|
||||||
return loaded
|
return loaded
|
||||||
|
|
||||||
|
|
||||||
def load(config):
|
def load(config):
|
||||||
enabled = [name for name, options in config['main']['plugins'].items() if
|
enabled = [name for name, options in config['main']['plugins'].items() if
|
||||||
'enabled' in options and options['enabled']]
|
'enabled' in options and options['enabled']]
|
||||||
|
@ -38,8 +38,7 @@ def check(version, repo, native=True):
|
|||||||
# check if this release is compatible with arm6
|
# check if this release is compatible with arm6
|
||||||
for asset in latest['assets']:
|
for asset in latest['assets']:
|
||||||
download_url = asset['browser_download_url']
|
download_url = asset['browser_download_url']
|
||||||
if download_url.endswith('.zip') and (
|
if download_url.endswith('.zip') and (info['arch'] in download_url or (is_arm and 'armhf' in download_url)):
|
||||||
info['arch'] in download_url or (is_arm and 'armhf' in download_url)):
|
|
||||||
info['url'] = download_url
|
info['url'] = download_url
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user