From 521d8123adb6bcf3c9150d731641e77b1f2dbabc Mon Sep 17 00:00:00 2001 From: Louis PERDEREAU Date: Tue, 17 Dec 2024 14:21:49 +0100 Subject: [PATCH] feat(auth): Allow command on user, password config attributes --- src/pvecontrol/__init__.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/pvecontrol/__init__.py b/src/pvecontrol/__init__.py index a5c817a..e101edb 100644 --- a/src/pvecontrol/__init__.py +++ b/src/pvecontrol/__init__.py @@ -149,18 +149,21 @@ def _parser(): return parser.parse_args() + def _execute_command(cmd): - return subprocess.run(cmd, shell=True, check=True, capture_output=True).stdout.rstrip() + return subprocess.run(cmd, shell=True, check=True, capture_output=True).stdout.rstrip() + def run_auth_commands(clusterconfig): - regex = r"^\$\((.*)\)$" - result = re.match(regex, clusterconfig.user) - if result: - clusterconfig.user = _execute_command(result.group(1)) - - result = re.match(regex, clusterconfig.password) - if result: - clusterconfig.password = _execute_command(result.group(1)) + regex = r"^\$\((.*)\)$" + result = re.match(regex, clusterconfig.user) + if result: + clusterconfig.user = _execute_command(result.group(1)) + + result = re.match(regex, clusterconfig.password) + if result: + clusterconfig.password = _execute_command(result.group(1)) + def main(): # Disable urllib3 warnings about invalid certs