From f2a36f8325b22d97de1172b23dd08ef37fbfed91 Mon Sep 17 00:00:00 2001 From: Dariush Vesal Date: Mon, 1 Apr 2024 08:08:28 +0330 Subject: [PATCH] Add try catch for method update_wg_usage to show propper error cause --- common/commander.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/commander.py b/common/commander.py index 108b8687e..11117fc65 100755 --- a/common/commander.py +++ b/common/commander.py @@ -155,8 +155,15 @@ def apply_users(): @cli.command('update-wg-usage') def update_wg_usage(): - wg_raw_output = subprocess.check_output(['wg', 'show', 'hiddifywg', 'transfer']) - print(wg_raw_output.decode()) + try: + wg_raw_output = subprocess.check_output(['wg', 'show', 'hiddifywg', 'transfer']) + output_str = wg_raw_output.decode() + if 'hiddifywg' in output_str: + print(output_str) + else: + raise Exception("Interface hiddifywg (wireguard) not found") + except subprocess.CalledProcessError as e: + print("Can not find interface hiddifywg, you can try change port wireguard.", e) if __name__ == "__main__":