From 5f7ae5d590c7a8e79bd055aae93715a0d8972c74 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sun, 21 Apr 2013 09:15:13 +0930 Subject: [PATCH] fix nzbget failure conditions let us assume any unpack and par issues are not easily repairable. therefore we want to call snatch next. Also fixed comparison to string, not int. --- nzbToCouchPotato.py | 27 +++++++++++++++------------ nzbToGamez.py | 27 +++++++++++++++------------ nzbToHeadPhones.py | 27 +++++++++++++++------------ nzbToMedia.py | 27 +++++++++++++++------------ nzbToMylar.py | 27 +++++++++++++++------------ nzbToSickBeard.py | 27 +++++++++++++++------------ 6 files changed, 90 insertions(+), 72 deletions(-) diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py index 7fd724f3..5a2650d9 100755 --- a/nzbToCouchPotato.py +++ b/nzbToCouchPotato.py @@ -152,25 +152,25 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # Check nzbget.conf options status = 0 - if os.environ['NZBOP_UNPACK'] != "yes": + if os.environ['NZBOP_UNPACK'] != 'yes': Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") sys.exit(POSTPROCESS_ERROR) # Check par status - if os.environ['NZBPP_PARSTATUS'] == 3: + if os.environ['NZBPP_PARSTATUS'] == '3': Logger.warning("Par-check successful, but Par-repair disabled, exiting") sys.exit(POSTPROCESS_NONE) - if os.environ['NZBPP_PARSTATUS'] == 1: + if os.environ['NZBPP_PARSTATUS'] == '1': Logger.warning("Par-check failed, setting status \"failed\"") status = 1 # Check unpack status - if os.environ['NZBPP_UNPACKSTATUS'] == 1: + if os.environ['NZBPP_UNPACKSTATUS'] == '1': Logger.warning("Unpack failed, setting status \"failed\"") status = 1 - if os.environ['NZBPP_UNPACKSTATUS'] == 0 and os.environ['NZBPP_PARSTATUS'] != 2: + if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': # Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): @@ -178,18 +178,21 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 fileExtension = os.path.splitext(file)[1] if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']: - Logger.warning("Post-Process: Archive files exist but unpack skipped, exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"") + status = 1 + break if fileExtension in ['.par2']: - Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g") + status = 1 + break - if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")): + if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1: Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting") - sys.exit(POSTPROCESS_NONE) + status = 1) - Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") + if not status == 1: + Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") # Check if destination directory exists (important for reprocessing of history items) if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): diff --git a/nzbToGamez.py b/nzbToGamez.py index da439c2f..63baf90b 100755 --- a/nzbToGamez.py +++ b/nzbToGamez.py @@ -102,25 +102,25 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # Check nzbget.conf options status = 0 - if os.environ['NZBOP_UNPACK'] != "yes": + if os.environ['NZBOP_UNPACK'] != 'yes': Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") sys.exit(POSTPROCESS_ERROR) # Check par status - if os.environ['NZBPP_PARSTATUS'] == 3: + if os.environ['NZBPP_PARSTATUS'] == '3': Logger.warning("Par-check successful, but Par-repair disabled, exiting") sys.exit(POSTPROCESS_NONE) - if os.environ['NZBPP_PARSTATUS'] == 1: + if os.environ['NZBPP_PARSTATUS'] == '1': Logger.warning("Par-check failed, setting status \"failed\"") status = 1 # Check unpack status - if os.environ['NZBPP_UNPACKSTATUS'] == 1: + if os.environ['NZBPP_UNPACKSTATUS'] == '1': Logger.warning("Unpack failed, setting status \"failed\"") status = 1 - if os.environ['NZBPP_UNPACKSTATUS'] == 0 and os.environ['NZBPP_PARSTATUS'] != 2: + if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': # Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): @@ -128,18 +128,21 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 fileExtension = os.path.splitext(file)[1] if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']: - Logger.warning("Post-Process: Archive files exist but unpack skipped, exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"") + status = 1 + break if fileExtension in ['.par2']: - Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g") + status = 1 + break - if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")): + if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1: Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting") - sys.exit(POSTPROCESS_NONE) + status = 1) - Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") + if not status == 1: + Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") # Check if destination directory exists (important for reprocessing of history items) if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): diff --git a/nzbToHeadPhones.py b/nzbToHeadPhones.py index 7c4d3bcb..3020b4f7 100755 --- a/nzbToHeadPhones.py +++ b/nzbToHeadPhones.py @@ -107,25 +107,25 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # Check nzbget.conf options status = 0 - if os.environ['NZBOP_UNPACK'] != "yes": + if os.environ['NZBOP_UNPACK'] != 'yes': Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") sys.exit(POSTPROCESS_ERROR) # Check par status - if os.environ['NZBPP_PARSTATUS'] == 3: + if os.environ['NZBPP_PARSTATUS'] == '3': Logger.warning("Par-check successful, but Par-repair disabled, exiting") sys.exit(POSTPROCESS_NONE) - if os.environ['NZBPP_PARSTATUS'] == 1: + if os.environ['NZBPP_PARSTATUS'] == '1': Logger.warning("Par-check failed, setting status \"failed\"") status = 1 # Check unpack status - if os.environ['NZBPP_UNPACKSTATUS'] == 1: + if os.environ['NZBPP_UNPACKSTATUS'] == '1': Logger.warning("Unpack failed, setting status \"failed\"") status = 1 - if os.environ['NZBPP_UNPACKSTATUS'] == 0 and os.environ['NZBPP_PARSTATUS'] != 2: + if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': # Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): @@ -133,18 +133,21 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 fileExtension = os.path.splitext(file)[1] if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']: - Logger.warning("Post-Process: Archive files exist but unpack skipped, exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"") + status = 1 + break if fileExtension in ['.par2']: - Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g") + status = 1 + break - if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")): + if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1: Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting") - sys.exit(POSTPROCESS_NONE) + status = 1) - Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") + if not status == 1: + Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") # Check if destination directory exists (important for reprocessing of history items) if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): diff --git a/nzbToMedia.py b/nzbToMedia.py index 168b165d..197a5c4c 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -314,25 +314,25 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # Check nzbget.conf options status = 0 - if os.environ['NZBOP_UNPACK'] != "yes": + if os.environ['NZBOP_UNPACK'] != 'yes': Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") sys.exit(POSTPROCESS_ERROR) # Check par status - if os.environ['NZBPP_PARSTATUS'] == 3: + if os.environ['NZBPP_PARSTATUS'] == '3': Logger.warning("Par-check successful, but Par-repair disabled, exiting") sys.exit(POSTPROCESS_NONE) - if os.environ['NZBPP_PARSTATUS'] == 1: + if os.environ['NZBPP_PARSTATUS'] == '1': Logger.warning("Par-check failed, setting status \"failed\"") status = 1 # Check unpack status - if os.environ['NZBPP_UNPACKSTATUS'] == 1: + if os.environ['NZBPP_UNPACKSTATUS'] == '1': Logger.warning("Unpack failed, setting status \"failed\"") status = 1 - if os.environ['NZBPP_UNPACKSTATUS'] == 0 and os.environ['NZBPP_PARSTATUS'] != 2: + if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': # Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): @@ -340,18 +340,21 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 fileExtension = os.path.splitext(file)[1] if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']: - Logger.warning("Post-Process: Archive files exist but unpack skipped, exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"") + status = 1 + break if fileExtension in ['.par2']: - Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g") + status = 1 + break - if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")): + if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1: Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting") - sys.exit(POSTPROCESS_NONE) + status = 1) - Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") + if not status == 1: + Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") # Check if destination directory exists (important for reprocessing of history items) if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): diff --git a/nzbToMylar.py b/nzbToMylar.py index 3c2b4458..1e0e8b01 100755 --- a/nzbToMylar.py +++ b/nzbToMylar.py @@ -99,25 +99,25 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # Check nzbget.conf options status = 0 - if os.environ['NZBOP_UNPACK'] != "yes": + if os.environ['NZBOP_UNPACK'] != 'yes': Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") sys.exit(POSTPROCESS_ERROR) # Check par status - if os.environ['NZBPP_PARSTATUS'] == 3: + if os.environ['NZBPP_PARSTATUS'] == '3': Logger.warning("Par-check successful, but Par-repair disabled, exiting") sys.exit(POSTPROCESS_NONE) - if os.environ['NZBPP_PARSTATUS'] == 1: + if os.environ['NZBPP_PARSTATUS'] == '1': Logger.warning("Par-check failed, setting status \"failed\"") status = 1 # Check unpack status - if os.environ['NZBPP_UNPACKSTATUS'] == 1: + if os.environ['NZBPP_UNPACKSTATUS'] == '1': Logger.warning("Unpack failed, setting status \"failed\"") status = 1 - if os.environ['NZBPP_UNPACKSTATUS'] == 0 and os.environ['NZBPP_PARSTATUS'] != 2: + if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': # Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): @@ -125,18 +125,21 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 fileExtension = os.path.splitext(file)[1] if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']: - Logger.warning("Post-Process: Archive files exist but unpack skipped, exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"") + status = 1 + break if fileExtension in ['.par2']: - Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g") + status = 1 + break - if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")): + if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1: Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting") - sys.exit(POSTPROCESS_NONE) + status = 1) - Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") + if not status == 1: + Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") # Check if destination directory exists (important for reprocessing of history items) if not os.path.isdir(os.environ['NZBPP_DIRECTORY']): diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index f275b68e..2717bd64 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -148,25 +148,25 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # Check nzbget.conf options status = 0 - if os.environ['NZBOP_UNPACK'] != "yes": + if os.environ['NZBOP_UNPACK'] != 'yes': Logger.error("Please enable option \"Unpack\" in nzbget configuration file, exiting") sys.exit(POSTPROCESS_ERROR) # Check par status - if os.environ['NZBPP_PARSTATUS'] == 3: + if os.environ['NZBPP_PARSTATUS'] == '3': Logger.warning("Par-check successful, but Par-repair disabled, exiting") sys.exit(POSTPROCESS_NONE) - if os.environ['NZBPP_PARSTATUS'] == 1: + if os.environ['NZBPP_PARSTATUS'] == '1': Logger.warning("Par-check failed, setting status \"failed\"") status = 1 # Check unpack status - if os.environ['NZBPP_UNPACKSTATUS'] == 1: + if os.environ['NZBPP_UNPACKSTATUS'] == '1': Logger.warning("Unpack failed, setting status \"failed\"") status = 1 - if os.environ['NZBPP_UNPACKSTATUS'] == 0 and os.environ['NZBPP_PARSTATUS'] != 2: + if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] != '2': # Unpack is disabled or was skipped due to nzb-file properties or due to errors during par-check for dirpath, dirnames, filenames in os.walk(os.environ['NZBPP_DIRECTORY']): @@ -174,18 +174,21 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 fileExtension = os.path.splitext(file)[1] if fileExtension in ['.rar', '.7z'] or os.path.splitext(fileExtension)[1] in ['.rar', '.7z']: - Logger.warning("Post-Process: Archive files exist but unpack skipped, exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Archive files exist but unpack skipped, setting status \"failed\"") + status = 1 + break if fileExtension in ['.par2']: - Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), exiting") - sys.exit(POSTPROCESS_NONE) + Logger.warning("Post-Process: Unpack skipped and par-check skipped (although par2-files exist), setting status \"failed\"g") + status = 1 + break - if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")): + if os.path.isfile(os.path.join(os.environ['NZBPP_DIRECTORY'], "_brokenlog.txt")) and not status == 1: Logger.warning("Post-Process: _brokenlog.txt exists, download is probably damaged, exiting") - sys.exit(POSTPROCESS_NONE) + status = 1) - Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") + if not status == 1: + Logger.info("Neither archive- nor par2-files found, _brokenlog.txt doesn't exist, considering download successful") # Check if destination directory exists (important for reprocessing of history items) if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):