From 017e2239a4c31ef16839863a2a16e73398f070e9 Mon Sep 17 00:00:00 2001 From: echel0n Date: Sun, 30 Mar 2014 18:11:51 -0700 Subject: [PATCH 1/4] Fixed process_method issue #296 Fixed bug where it would detect the incorrect fork branch due to improperly set constants Adds ability for user to set process_method from cfg file, leaving it empty defaults to sickbeard's process method from its config. --- autoProcess/autoProcessTV.py | 18 +++++++++++++++--- autoProcess/migratecfg.py | 4 ++-- autoProcess/nzbToMediaEnv.py | 2 +- autoProcessMedia.cfg.sample | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index b7a2d4db..da0abdc0 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -106,6 +106,11 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC except (ConfigParser.NoOptionError, ValueError): nzbExtractionBy = "Downloader" + try: + process_method = config.get(section, "process_method") + except ConfigParser.NoOptionError: + process_method = None + TimeOut = 60 * int(wait_for) # SickBeard needs to complete all moving and renaming before returning the log sequence via url. socket.setdefaulttimeout(int(TimeOut)) #initialize socket timeout. @@ -152,17 +157,24 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC if watch_dir != "" and (not host in ['localhost', '127.0.0.1'] or nzbName == "Manual Run"): dirName = watch_dir + # don't have sickbeard display any output params['quiet'] = 1 for param in copy.copy(params): if param is "failed": - params["failed"] = failed + params[param] = failed if param is "dirName": - params["dirName"] = dirName + params[param] = dirName if param is "dir": - params["dir"] = dirName + params[param] = dirName + + if param is "process_method": + if process_method: + params[param] = process_method + else: + del params[param] if nzbName != None: params['nzbName'] = nzbName diff --git a/autoProcess/migratecfg.py b/autoProcess/migratecfg.py index d1e3e20b..cdd1187f 100644 --- a/autoProcess/migratecfg.py +++ b/autoProcess/migratecfg.py @@ -305,8 +305,8 @@ def addnzbget(): section = "SickBeard" - envKeys = ['CATEGORY', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'DELAY', 'WAIT_FOR'] - cfgKeys = ['sbCategory', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'delay', 'wait_for'] + envKeys = ['CATEGORY', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'DELAY', 'WAIT_FOR', 'PROCESS_METHOD'] + cfgKeys = ['sbCategory', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'delay', 'wait_for', 'process_method'] for index in range(len(envKeys)): key = 'NZBPO_SB' + envKeys[index] if os.environ.has_key(key): diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index 928b7e34..bf5798ca 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -15,7 +15,7 @@ fork_failed_torrent = "failed-torrent" forks = {} forks[fork_default] = {"dir": None, "process": None} -forks[fork_failed] = {"dir": None, "failed": None} +forks[fork_failed] = {"dirName": None, "failed": None} forks[fork_failed_torrent] = {"dir": None, "failed": None, "process_method": None} SICKBEARD_FAILED = [fork_failed, fork_failed_torrent] diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index ede393b5..946a7b2d 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -37,7 +37,7 @@ fork = auto delete_failed = 0 nzbExtractionBy = Downloader Torrent_ForceLink = 1 - +process_method = [HeadPhones] #### autoProcessing for Music From bd68c6f37863f7e1bed47b529a59bf550a1099fe Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 31 Mar 2014 00:24:12 -0700 Subject: [PATCH 2/4] Clean up of misc files --- test.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 test.py diff --git a/test.py b/test.py deleted file mode 100644 index f22f0de3..00000000 --- a/test.py +++ /dev/null @@ -1,24 +0,0 @@ -import copy - -from autoProcess.autoSickBeardFork import autoFork - -fork, params = autoFork() -print fork - -failed = True -for param in copy.copy(params): - if param is "failed": - params["failed"] = failed - - if param is "dirName": - params["dirName"] = "dirName" - - if param is "dir": - params["dir"] = "dirName" - - if param is "process_method": - del param - -params['nzbName'] = "test" - -print params \ No newline at end of file From 3d7228a893c1bd101525074fd7031d40898c624c Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 31 Mar 2014 00:43:04 -0700 Subject: [PATCH 3/4] Added in code to delete params that are not being used before we pass them to SB this way we don't have any potential issues arise from passing a NoneType param --- autoProcess/autoProcessTV.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index bdccdb24..3d5293e3 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -146,8 +146,10 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC if watch_dir != "" and (not host in ['localhost', '127.0.0.1'] or nzbName == "Manual Run"): dirName = watch_dir - # don't have sickbeard display any output + # configure SB params to pass params['quiet'] = 1 + if nzbName is not None: + params['nzbName'] = nzbName for param in copy.copy(params): if param is "failed": @@ -162,8 +164,8 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC else: del params[param] - if nzbName != None: - params['nzbName'] = nzbName + # delete any unused params so we don't pass them to SB by mistake + [params.pop(k) for k,v in params.iteritems() if v is None] if status == 0: Logger.info("The download succeeded. Sending process request to SickBeard's %s branch", fork) From 08bd4584d87e98fe693e07309f0e1bb9ee83b56a Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 31 Mar 2014 02:58:58 -0700 Subject: [PATCH 4/4] Changed autoFork to default to auto-detection if it fails to properly get the config value for fork or one is not set --- autoProcess/autoSickBeardFork.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoProcess/autoSickBeardFork.py b/autoProcess/autoSickBeardFork.py index f4d6d18c..56260579 100644 --- a/autoProcess/autoSickBeardFork.py +++ b/autoProcess/autoSickBeardFork.py @@ -51,7 +51,7 @@ def autoFork(fork=None): try: fork = forks.items()[forks.keys().index(config.get(section, "fork"))] except: - fork = forks.items()[forks.keys().index(fork_default)] + fork = "auto" myOpener = AuthURLOpener(username, password)