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

This commit is contained in:
strohitv
2025-07-06 23:44:01 +02:00
parent 93104326c4
commit bd6053c7cf

15
s3s.py
View File

@@ -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: