From bd6053c7cfa085d2377bb7c6dc86616a6e222596 Mon Sep 17 00:00:00 2001 From: strohitv Date: Sun, 6 Jul 2025 23:44:01 +0200 Subject: [PATCH] add validation for DISABLE_REFRESH_RC and also fix bug that DISABLE_REFRESH_RC was provided as string, causing the script to always exist with RC 1 --- s3s.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/s3s.py b/s3s.py index 9928aae..71b7c9b 100644 --- a/s3s.py +++ b/s3s.py @@ -1830,8 +1830,7 @@ def main(): outfile = parser_result.o # output to local files skipprefetch = parser_result.skipprefetch # skip prefetch checks to ensure token validity - global DISABLE_REFRESH_RC - DISABLE_REFRESH_RC = parser_result.RC # stop application instead of trying to refresh tokens + rc_value = parser_result.RC # stop application instead of trying to refresh tokens # setup ####### @@ -1872,6 +1871,18 @@ def main(): print("Minimum number of seconds in monitoring mode is 60. Exiting.") sys.exit(0) + global DISABLE_REFRESH_RC + DISABLE_REFRESH_RC = None + if rc_value is not None: + try: + DISABLE_REFRESH_RC = int(rc_value) + except ValueError: + print("Number provided for --norefresh must be an integer. Exiting.") + sys.exit(1) + if DISABLE_REFRESH_RC < 0: + print("RC for --norefresh must be 0 or positive! Exiting.") + sys.exit(1) + # export results to file: -o flag ################################# if outfile: