From b8cc11eff840b4d867a37d4fd00538e8aaacfc03 Mon Sep 17 00:00:00 2001 From: Jeroen Oudshoorn Date: Fri, 8 Sep 2023 20:26:24 +0200 Subject: [PATCH] Revert "Version 2.3.4" This reverts commit 7b6cfa2b58f33107bbe14bf8d960b0cca280b1de. --- bin/pwnagotchi | 13 ++++++++++--- pwnagotchi/_version.py | 2 +- pwnagotchi/bettercap.py | 6 +++--- pwnagotchi/plugins/__init__.py | 34 +++++++++++++--------------------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/bin/pwnagotchi b/bin/pwnagotchi index 96f405c7..46712c3e 100755 --- a/bin/pwnagotchi +++ b/bin/pwnagotchi @@ -114,11 +114,14 @@ if __name__ == '__main__': parser.add_argument('--debug', dest="debug", action="store_true", default=False, help="Enable debug logs.") + parser.add_argument('--version', dest="version", action="store_true", default=False, + help="Print the version.") + parser.add_argument('--print-config', dest="print_config", action="store_true", default=False, help="Print the configuration.") parser.add_argument('--check-update', dest="check_update", action="store_true", default=False, - help="Check for updates on Pwnagotchi. And tells current version.") + help="Check for updates on Pwnagotchi.") parser.add_argument('--donate', dest="donate", action="store_true", default=False, help="How to donate to this project.") @@ -142,7 +145,7 @@ if __name__ == '__main__': local = version_to_tuple(pwnagotchi.__version__) remote = version_to_tuple(latest_ver) if remote > local: - user_input = input("There is a new version available! Update from v%s to v%s?\n[y(es)/n(o)]" % (pwnagotchi.__version__, latest_ver)) + user_input = input("There is a new version available! Update to %s? [y(es)/n(o)]" % latest_ver) # input validation if user_input.lower() in ('y', 'yes'): os.system("rm /root/.auto-update && systemctl restart pwnagotchi") @@ -152,7 +155,11 @@ if __name__ == '__main__': elif user_input.lower() in ('n', 'no'): # using this elif for readability print("Okay, guess not!") else: - print("You are currently on the latest release, v%s." % pwnagotchi.__version__) + print("You are currently on the latest release, %s." % pwnagotchi.__version__) + sys.exit(0) + + if args.version: + print(pwnagotchi.__version__) sys.exit(0) config = utils.load_config(args) diff --git a/pwnagotchi/_version.py b/pwnagotchi/_version.py index 6ec85d61..8a242cd3 100644 --- a/pwnagotchi/_version.py +++ b/pwnagotchi/_version.py @@ -1 +1 @@ -__version__ = '2.3.4' +__version__ = '2.3.3' diff --git a/pwnagotchi/bettercap.py b/pwnagotchi/bettercap.py index e2eef3dd..bb9f7992 100644 --- a/pwnagotchi/bettercap.py +++ b/pwnagotchi/bettercap.py @@ -51,13 +51,13 @@ class Client(object): logging.debug("Error while parsing event (%s)", ex) except websockets.exceptions.ConnectionClosedError: logging.debug("Lost websocket connection. Reconnecting...") - await asyncio.sleep(1) # Sleep for x seconds before reconnecting + await asyncio.sleep(1) # Sleep for 5 seconds before reconnecting except websockets.exceptions.WebSocketException as wex: logging.debug("Websocket exception (%s)", wex) - await asyncio.sleep(1) # Sleep for x seconds before reconnecting + await asyncio.sleep(1) # Sleep for 5 seconds before reconnecting except Exception as e: logging.exception("Other error while opening websocket (%s) with parameter %s", e, s) - await asyncio.sleep(1) # Sleep for x seconds before reconnecting + await asyncio.sleep(1) # Sleep for 5 seconds before reconnecting def run(self, command, verbose_errors=True): for _ in range(0, 2): diff --git a/pwnagotchi/plugins/__init__.py b/pwnagotchi/plugins/__init__.py index 512f056c..f43a4140 100644 --- a/pwnagotchi/plugins/__init__.py +++ b/pwnagotchi/plugins/__init__.py @@ -13,7 +13,6 @@ locks = {} THREAD_POOL_SIZE = 10 executor = ThreadPoolExecutor(max_workers=THREAD_POOL_SIZE) - class Plugin: @classmethod def __init_subclass__(cls, **kwargs): @@ -31,7 +30,6 @@ class Plugin: if cb is not None and callable(cb): locks["%s::%s" % (plugin_name, attr_name)] = threading.Lock() - def toggle_plugin(name, enable=True): """ Load or unload a plugin @@ -70,12 +68,10 @@ def toggle_plugin(name, enable=True): return False - def on(event_name, *args, **kwargs): for plugin_name in loaded.keys(): one(plugin_name, event_name, *args, **kwargs) - def locked_cb(lock_name, cb, *args, **kwargs): global locks @@ -85,24 +81,21 @@ def locked_cb(lock_name, cb, *args, **kwargs): with locks[lock_name]: cb(*args, *kwargs) - def one(plugin_name, event_name, *args, **kwargs): global loaded - if not executor._shutdown: - if plugin_name in loaded: - plugin = loaded[plugin_name] - cb_name = 'on_%s' % event_name - callback = getattr(plugin, cb_name, None) - if callback is not None and callable(callback): - try: - lock_name = "%s::%s" % (plugin_name, cb_name) - locked_cb_args = (lock_name, callback, *args, *kwargs) - executor.submit(locked_cb, *locked_cb_args) - except Exception as e: - logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e)) - logging.error(e, exc_info=True) - else: - logging.warning("Executor is shut down. Cannot schedule new futures.") + + if plugin_name in loaded: + plugin = loaded[plugin_name] + cb_name = 'on_%s' % event_name + callback = getattr(plugin, cb_name, None) + if callback is not None and callable(callback): + try: + lock_name = "%s::%s" % (plugin_name, cb_name) + locked_cb_args = (lock_name, callback, *args, *kwargs) + executor.submit(locked_cb, *locked_cb_args) + except Exception as e: + logging.error("error while running %s.%s : %s" % (plugin_name, cb_name, e)) + logging.error(e, exc_info=True) def load_from_file(filename): logging.debug("loading %s" % filename) @@ -127,7 +120,6 @@ def load_from_path(path, enabled=()): return loaded - def load(config): enabled = [name for name, options in config['main']['plugins'].items() if 'enabled' in options and options['enabled']]