IMP: Added ability to specify unrar location within config.ini (unrar_cmd=full_path), IMP: Added some more exception handling for post-processing errors

This commit is contained in:
evilhero 2014-10-14 03:31:49 -04:00
parent c071c98302
commit 52bbc5b42c
4 changed files with 47 additions and 14 deletions

View File

@ -771,9 +771,12 @@ class PostProcessor(object):
ofilename = filename
logger.fdebug(module + ' ofilename: ' + ofilename)
path, ext = os.path.splitext(ofilename)
if odir is None:
logger.fdebug(module + ' No root folder set.')
try:
if odir is None:
logger.fdebug(module + ' No root folder set.')
odir = self.nzb_folder
except:
logger.error(module + ' unable to set root folder. Forcing it due to some error above most likely.')
odir = self.nzb_folder
logger.fdebug(module + ' odir: ' + str(odir))
logger.fdebug(module + ' ofilename: ' + str(ofilename))
@ -791,7 +794,9 @@ class PostProcessor(object):
if ofilename is None:
logger.error(module + ' Aborting PostProcessing - the filename does not exist in the location given. Make sure that ' + str(self.nzb_folder) + ' exists and is the correct location.')
return
self.valreturn.append({"self.log" : self.log,
"mode" : 'stop'})
return self.queue.put(self.valreturn)
self._log("Original Filename: " + ofilename)
self._log("Original Extension: " + ext)
logger.fdebug(module + ' Original Filname: ' + str(ofilename))

View File

@ -276,6 +276,7 @@ CMTAGGER_PATH = None
CT_TAG_CR = 1
CT_TAG_CBL = 1
CT_CBZ_OVERWRITE = 0
UNRAR_CMD = None
ENABLE_RSS = 0
RSS_CHECKINTERVAL = 20
@ -365,7 +366,7 @@ def initialize():
USE_NZBGET, NZBGET_HOST, NZBGET_PORT, NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_PRIORITY, NZBGET_DIRECTORY, NZBSU, NZBSU_UID, NZBSU_APIKEY, DOGNZB, DOGNZB_UID, DOGNZB_APIKEY, \
NEWZNAB, NEWZNAB_NAME, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_UID, NEWZNAB_ENABLED, EXTRA_NEWZNABS, NEWZNAB_EXTRA, \
RAW, RAW_PROVIDER, RAW_USERNAME, RAW_PASSWORD, RAW_GROUPS, EXPERIMENTAL, ALTEXPERIMENTAL, \
ENABLE_META, CMTAGGER_PATH, CT_TAG_CR, CT_TAG_CBL, CT_CBZ_OVERWRITE, INDIE_PUB, BIGGIE_PUB, IGNORE_HAVETOTAL, PROVIDER_ORDER, \
ENABLE_META, CMTAGGER_PATH, CT_TAG_CR, CT_TAG_CBL, CT_CBZ_OVERWRITE, UNRAR_CMD, INDIE_PUB, BIGGIE_PUB, IGNORE_HAVETOTAL, PROVIDER_ORDER, \
dbUpdateScheduler, searchScheduler, RSSScheduler, WeeklyScheduler, VersionScheduler, FolderMonitorScheduler, \
ENABLE_TORRENTS, MINSEEDS, TORRENT_LOCAL, LOCAL_WATCHDIR, TORRENT_SEEDBOX, SEEDBOX_HOST, SEEDBOX_PORT, SEEDBOX_USER, SEEDBOX_PASS, SEEDBOX_WATCHDIR, \
ENABLE_RSS, RSS_CHECKINTERVAL, RSS_LASTRUN, FAILED_DOWNLOAD_HANDLING, FAILED_AUTO, ENABLE_TORRENT_SEARCH, ENABLE_KAT, KAT_PROXY, ENABLE_CBT, CBT_PASSKEY, SNATCHEDTORRENT_NOTIFY, \
@ -541,6 +542,7 @@ def initialize():
CT_TAG_CR = bool(check_setting_int(CFG, 'General', 'ct_tag_cr', 1))
CT_TAG_CBL = bool(check_setting_int(CFG, 'General', 'ct_tag_cbl', 1))
CT_CBZ_OVERWRITE = bool(check_setting_int(CFG, 'General', 'ct_cbz_overwrite', 0))
UNRAR_CMD = check_setting_str(CFG, 'General', 'unrar_cmd', '')
INDIE_PUB = check_setting_str(CFG, 'General', 'indie_pub', '75')
BIGGIE_PUB = check_setting_str(CFG, 'General', 'biggie_pub', '55')
@ -1134,6 +1136,7 @@ def config_write():
new_config['General']['ct_tag_cr'] = int(CT_TAG_CR)
new_config['General']['ct_tag_cbl'] = int(CT_TAG_CBL)
new_config['General']['ct_cbz_overwrite'] = int(CT_CBZ_OVERWRITE)
new_config['General']['unrar_cmd'] = UNRAR_CMD
new_config['General']['indie_pub'] = INDIE_PUB
new_config['General']['biggie_pub'] = BIGGIE_PUB

View File

@ -28,6 +28,7 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None, module
## Set the directory in which comictagger and other external commands are located - IMPORTANT - ##
# ( User may have to modify, depending on their setup, but these are some guesses for now )
if platform.system() == "Windows":
#if it's a source install.
if os.path.isdir(os.path.join(mylar.CMTAGGER_PATH, '.git')):
@ -40,7 +41,10 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None, module
else:
comictagger_cmd = os.path.join(mylar.CMTAGGER_PATH, 'comictagger.exe')
unrar_cmd = "C:\Program Files\WinRAR\UnRAR.exe"
if mylar.UNRAR_CMD is None or mylar.UNRAR_CMD == '':
unrar_cmd = "C:\Program Files\WinRAR\UnRAR.exe"
else:
unrar_cmd = mylar.UNRAR_CMD.strip()
# test for UnRAR
if not os.path.isfile(unrar_cmd):
@ -50,17 +54,30 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None, module
logger.fdebug(module + ' Aborting meta-tagging.')
return "fail"
logger.fdebug(module + ' UNRAR path set to : ' + unrar_cmd)
elif platform.system() == "Darwin": #Mac OS X
comictagger_cmd = os.path.join(mylar.CMTAGGER_PATH, 'comictagger.py')
unrar_cmd = "/usr/local/bin/unrar"
if mylar.UNRAR_CMD is None or mylar.UNRAR_CMD == '':
unrar_cmd = "/usr/local/bin/unrar"
else:
unrar_cmd = mylar.UNRAR_CMD.strip()
logger.fdebug(module + ' UNRAR path set to : ' + unrar_cmd)
else:
#for the 'nix
if 'freebsd' in platform.linux_distribution()[0].lower():
unrar_cmd = "/usr/local/bin/unrar"
if mylar.UNRAR_CMD is None or mylar.UNRAR_CMD == '':
if 'freebsd' in platform.linux_distribution()[0].lower():
unrar_cmd = "/usr/local/bin/unrar"
else:
unrar_cmd = "/usr/bin/unrar"
else:
unrar_cmd = "/usr/bin/unrar"
unrar_cmd = mylar.UNRAR_CMD.strip()
logger.fdebug(module + ' UNRAR path set to : ' + unrar_cmd)
#check for dependencies here - configparser
try:
import configparser
@ -83,8 +100,9 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None, module
logger.fdebug(module + ' WARNING: cannot find the unrar command.')
logger.fdebug(module + ' File conversion and extension fixing not available')
logger.fdebug(module + ' You probably need to edit this script, or install the missing tool, or both!')
file_conversion = False
file_extension_fixing = False
return "fail"
#file_conversion = False
#file_extension_fixing = False
## Sets up other directories ##
@ -266,7 +284,12 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None, module
else:
file_dir = re.sub(issueid, '', comicpath)
file_n = os.path.split(nfilename)[1]
try:
file_n = os.path.split(nfilename)[1]
except:
logger.error(module + ' unable to retrieve filename properly. Check your logs as there is probably an error or misconfiguration indicated (such as unable to locate unrar or configparser)')
return "fail"
logger.fdebug(module + ' Converted directory: ' + str(file_dir))
logger.fdebug(module + ' Converted filename: ' + str(file_n))
logger.fdebug(module + ' Destination path: ' + os.path.join(file_dir,file_n)) #dirName,file_n))

View File

@ -2817,6 +2817,7 @@ class WebInterface(object):
"ct_tag_cr" : helpers.checked(mylar.CT_TAG_CR),
"ct_tag_cbl" : helpers.checked(mylar.CT_TAG_CBL),
"ct_cbz_overwrite" : helpers.checked(mylar.CT_CBZ_OVERWRITE),
"unrar_cmd" : mylar.UNRAR_CMD,
"failed_download_handling" : helpers.checked(mylar.FAILED_DOWNLOAD_HANDLING),
"failed_auto" : helpers.checked(mylar.FAILED_AUTO),
"branch" : version.MYLAR_VERSION,
@ -3000,7 +3001,7 @@ class WebInterface(object):
nzbget_host=None, nzbget_port=None, nzbget_username=None, nzbget_password=None, nzbget_category=None, nzbget_priority=None, nzbget_directory=None,
usenet_retention=None, nzbsu=0, nzbsu_uid=None, nzbsu_apikey=None, dognzb=0, dognzb_uid=None, dognzb_apikey=None, newznab=0, newznab_host=None, newznab_name=None, newznab_apikey=None, newznab_uid=None, newznab_enabled=0,
raw=0, raw_provider=None, raw_username=None, raw_password=None, raw_groups=None, experimental=0, check_folder=None, enable_check_folder=0,
enable_meta=0, cmtagger_path=None, ct_tag_cr=0, ct_tag_cbl=0, ct_cbz_overwrite=0, enable_rss=0, rss_checkinterval=None, failed_download_handling=0, failed_auto=0, enable_torrent_search=0, enable_kat=0, enable_cbt=0, cbt_passkey=None, snatchedtorrent_notify=0,
enable_meta=0, cmtagger_path=None, ct_tag_cr=0, ct_tag_cbl=0, ct_cbz_overwrite=0, unrar_cmd=None, enable_rss=0, rss_checkinterval=None, failed_download_handling=0, failed_auto=0, enable_torrent_search=0, enable_kat=0, enable_cbt=0, cbt_passkey=None, snatchedtorrent_notify=0,
enable_torrents=0, minseeds=0, torrent_local=0, local_watchdir=None, torrent_seedbox=0, seedbox_watchdir=None, seedbox_user=None, seedbox_pass=None, seedbox_host=None, seedbox_port=None,
prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=None, nma_enabled=0, nma_apikey=None, nma_priority=0, nma_onsnatch=0, pushover_enabled=0, pushover_onsnatch=0, pushover_apikey=None, pushover_userkey=None, pushover_priority=None, boxcar_enabled=0, boxcar_onsnatch=0, boxcar_token=None,
pushbullet_enabled=0, pushbullet_apikey=None, pushbullet_deviceid=None, pushbullet_onsnatch=0,
@ -3133,6 +3134,7 @@ class WebInterface(object):
mylar.CT_TAG_CR = ct_tag_cr
mylar.CT_TAG_CBL = ct_tag_cbl
mylar.CT_CBZ_OVERWRITE = ct_cbz_overwrite
mylar.UNRAR_CMD = unrar_cmd
mylar.FAILED_DOWNLOAD_HANDLING = failed_download_handling
mylar.FAILED_AUTO = failed_auto
mylar.LOG_DIR = log_dir