From f55efbee7f9c61a7a08ba361cdbb64d73816c6c1 Mon Sep 17 00:00:00 2001 From: alejandro Date: Thu, 17 Aug 2023 12:45:09 +0200 Subject: [PATCH] minor changes in transfer (retry) --- .../extras/pandoraPlugintools/transfer.py | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/pandora_server/extras/pandoraPlugintools/transfer.py b/pandora_server/extras/pandoraPlugintools/transfer.py index 6a574355c1..9c8316c6c5 100644 --- a/pandora_server/extras/pandoraPlugintools/transfer.py +++ b/pandora_server/extras/pandoraPlugintools/transfer.py @@ -126,52 +126,49 @@ def tentacle_xml( tentacle_cmd = f"{tentacle_path} -v -a {tentacle_ops['address']} -p {tentacle_ops['port']} {tentacle_ops['extra_opts']} {data_file.strip()}" tentacle_exe=subprocess.Popen(tentacle_cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE, shell=True) rc=tentacle_exe.wait() - - if debug == 0 : - os.remove(data_file.strip()) + result = True + if rc != 0 : if retry: - if _GLOBAL_VARIABLES['tentacle_retries'] > 1: - _GLOBAL_VARIABLES['tentacle_retries'] = 1 + tentacle_retries = _GLOBAL_VARIABLES['tentacle_retries'] + + if tentacle_retries < 1: + tentacle_retries = 1 retry_count = 0 - while retry_count < _GLOBAL_VARIABLES['tentacle_retries'] : + while retry_count < tentacle_retries : tentacle_exe=subprocess.Popen(tentacle_cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE, shell=True) rc=tentacle_exe.wait() - if debug == 0 : - os.remove(data_file.strip()) - if rc == 0: break if print_errors: stderr = tentacle_exe.stderr.read().decode() - msg = f"Tentacle error (Retry {retry_count + 1}/{_GLOBAL_VARIABLES['tentacle_retries']}): {stderr}" + msg = f"Tentacle error (Retry {retry_count + 1}/{tentacle_retries}): {stderr}" print_stderr(str(datetime.today().strftime('%Y-%m-%d %H:%M')) + msg) retry_count += 1 - if retry_count >= _GLOBAL_VARIABLES['tentacle_retries']: - if print_errors: - stderr = tentacle_exe.stderr.read().decode() - msg = f"Tentacle error (Final Retry): {stderr}" - print_stderr(str(datetime.today().strftime('%Y-%m-%d %H:%M')) + msg) - return False + if retry_count >= tentacle_retries: + result = False else: if print_errors: stderr = tentacle_exe.stderr.read().decode() msg="Tentacle error:" + str(stderr) print_stderr(str(datetime.today().strftime('%Y-%m-%d %H:%M')) + msg) - return False + result = False - + if debug == 0 : + os.remove(data_file.strip()) + + return result else: if print_errors: