From bbcd7eb65d002547536933a19f43775d57ae73bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Virgovi=C4=8D?= Date: Sun, 31 Dec 2023 22:19:57 +0000 Subject: [PATCH] refactor: use f-strings (#179) --- graphenex/core/cli/commands.py | 2 +- graphenex/core/web/views.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/graphenex/core/cli/commands.py b/graphenex/core/cli/commands.py index 4e757ff..12ad2f5 100644 --- a/graphenex/core/cli/commands.py +++ b/graphenex/core/cli/commands.py @@ -457,7 +457,7 @@ def do_harden(self, arg): err_msg += " Try running the grapheneX with sudo." logger.error(err_msg) except Exception as e: - logger.error("Failed to execute hardening command. " + str(e)) + logger.error(f"Failed to execute hardening command: {e}") def do_EOF(self, arg): """EOF exit""" diff --git a/graphenex/core/web/views.py b/graphenex/core/web/views.py index e737aa1..329a056 100644 --- a/graphenex/core/web/views.py +++ b/graphenex/core/web/views.py @@ -153,14 +153,14 @@ def hardening_exec(data): emit(data + "_log", {"state": "error"}) logger.error(err_msg) except Exception as e: - fail_msg = "Failed to execute hardening command." + fail_msg = "Failed to execute hardening command" emit('log_message', { 'tag': 'danger', 'content': fail_msg, 'duration': 2000 }) emit(data + "_log", {"msg": str(e), "state": "error"}) - logger.error(fail_msg + " " + str(e)) + logger.error(f"{fail_msg}: {e}") @socketio.on('add_module') @@ -220,7 +220,7 @@ def add_module(mod): # Success event with module count emit('new_module_added', get_mod_count(module_dict)) except Exception as e: - exception_msg = "Error occurred while adding new module. " + str(e) + exception_msg = f"Error occurred while adding new module: {e}" emit('log_message', { 'tag': 'warning', 'content': exception_msg,