This commit is contained in:
deathbybandaid 2023-01-06 13:59:00 -05:00
parent bd4320caf2
commit 4507b0aa67

View File

@ -20,11 +20,11 @@ script_settings = {
}
def loggit(logtext):
def loggit(logtext, force_err=False):
if script_settings["logging"]["log_file"]:
with open(script_settings["logging"]["log_file_path"], 'a') as logwrite:
logwrite.write(logtext)
if script_settings["logging"]["output_level"]:
if script_settings["logging"]["output_level"] or force_err:
sys.stderr.write(logtext)
else:
sys.stdout.write(logtext)
@ -47,10 +47,12 @@ def main():
sys.exit(0)
elif arr_event_type not in ["Download", "Rename"]:
raise Exception("%s is not a supported tdarr_inform Event." % arr_event_type)
loggit("%s is not a supported tdarr_inform Event." % arr_event_type, True)
sys.exit(0)
if arr_file_path_key not in os.environ:
raise Exception("%s Environment variable was missing." % arr_file_path_key)
loggit("%s Environment variable was missing." % arr_file_path_key, True)
sys.exit(1)
arr_file_path = os.environ[arr_file_path_key]
loggit("Preparing payload to POST to tdarr API\n" % sys.argv)