est
This commit is contained in:
parent
03af625cae
commit
04240588f2
@ -32,10 +32,6 @@ import sys
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
# fp = open('/opt/testlog.log', 'a', 0)
|
|
||||||
# fp.write("Testing")
|
|
||||||
# fp.write("%s" % argv)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
SCRIPT_PATH = os.path.realpath(__file__)
|
SCRIPT_PATH = os.path.realpath(__file__)
|
||||||
SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
|
SCRIPT_DIR = os.path.dirname(SCRIPT_PATH)
|
||||||
@ -43,34 +39,25 @@ def main():
|
|||||||
log_file = os.path.join(SCRIPT_DIR, "testlog.log")
|
log_file = os.path.join(SCRIPT_DIR, "testlog.log")
|
||||||
logwrite = open(log_file, 'a')
|
logwrite = open(log_file, 'a')
|
||||||
|
|
||||||
envs = {}
|
|
||||||
|
|
||||||
if "sonarr_eventtype" in os.environ:
|
if "sonarr_eventtype" in os.environ:
|
||||||
arr_type = "sonarr"
|
arr_type = "sonarr"
|
||||||
|
arr_event_type = os.environ["sonarr_eventtype"]
|
||||||
|
arr_file_path_key = "sonarr_episodefile_path"
|
||||||
elif "radarr_eventtype" in os.environ:
|
elif "radarr_eventtype" in os.environ:
|
||||||
arr_type = "radarr"
|
arr_type = "radarr"
|
||||||
envs["%s_eventtype" % arr_type] = os.environ["%s_eventtype" % arr_type]
|
arr_event_type = os.environ["radarr_eventtype"]
|
||||||
logwrite.write("Recieved %s Event from %s\n" % (envs["%s_eventtype" % arr_type], arr_type.upper()))
|
arr_file_path_key = "radarr_moviefile_path"
|
||||||
|
|
||||||
if envs["%s_eventtype" % arr_type] == "Test":
|
print("tdarr_inform Recieved %s Event from %s\n" % (arr_event_type, arr_type))
|
||||||
|
|
||||||
|
if arr_event_type == "Test":
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
ENV_FILE = os.path.join(SCRIPT_DIR, "env_%s" % arr_type)
|
if arr_event_type not in ["Test"]:
|
||||||
logwrite.write("%s\n" % ENV_FILE)
|
raise Exception("%s is not a supported tdarr_inform Event." % arr_event_type)
|
||||||
|
|
||||||
# Checking all potentiall environment variables
|
if arr_file_path_key not in os.environ:
|
||||||
with open(ENV_FILE, 'r') as f:
|
raise Exception("%s Environment variable was missing." % arr_file_path_key)
|
||||||
for line in f:
|
|
||||||
env = line.rstrip()
|
|
||||||
if env in os.environ:
|
|
||||||
envs[env] = os.environ[env]
|
|
||||||
logwrite.write("%s %s" % (env, envs[env]))
|
|
||||||
|
|
||||||
# No environment variables were found
|
|
||||||
# Either the script was run manually as a test (ie Not ran by *arr)
|
|
||||||
# or, something went wrong : )
|
|
||||||
# if len(envs) == 0:
|
|
||||||
# raise Exception('No *arr Environment variables were found.')
|
|
||||||
|
|
||||||
logwrite.close()
|
logwrite.close()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user