ensure forks are ordered and parsed correctly. fixes #294

This commit is contained in:
clinton-hall 2014-03-25 13:47:07 +10:30
commit 8242700032
2 changed files with 13 additions and 13 deletions

View file

@ -63,14 +63,14 @@ def autoFork(fork=None):
Logger.info("Attempting to auto-detect SickBeard fork")
for f in forks.iteritems():
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(f[1])
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(f[1]['params'])
# attempting to auto-detect fork
urlObj = myOpener.openit(url)
if urlObj.getcode() == 200:
Logger.info("SickBeard fork auto-detection successful. Fork set to %s", f[0])
return f[0], f[1]
Logger.info("SickBeard fork auto-detection successful. Fork set to %s", f[1]['name'])
return f[1]['name'], f[1]['params']
# failed to auto-detect fork
Logger.info("SickBeard fork auto-detection failed")
@ -78,9 +78,9 @@ def autoFork(fork=None):
else: #if not fork in "auto"
try:
fork = fork if fork in SICKBEARD_FAILED or fork in SICKBEARD_TORRENT else fork_default
fork = [f for f in forks.iteritems() if f[0] == fork][0]
fork = [f for f in forks.iteritems() if f[1]['name'] == fork][0]
except:
fork = [f for f in forks.iteritems() if f[0] == fork_default][0]
fork = [f for f in forks.iteritems() if f[1]['name'] == fork_default][0]
Logger.info("SickBeard fork set to %s", fork[0])
return fork[0], fork[1]
Logger.info("SickBeard fork set to %s", fork[1]['name'])
return fork[1]['name'], fork[1]['params']

View file

@ -15,12 +15,12 @@ fork_failed = "failed"
fork_failed_new = "failed-new"
fork_failed_torrent = "failed-torrent"
forks = {}
forks[fork_failed_torrent] = {"dir": None, "failed": None, "process_method": None}
forks[fork_failed] = {"dirName": None, "failed": None}
forks[fork_failed_new] = {"dir": None, "failed": None}
forks[fork_default_new] = {"dir": None, "process": None}
forks[fork_default] = {"dir": None}
forks = {} # these need to be in order of most unique params first.
forks[1] = {'name': fork_failed_torrent, 'params': {"dir": None, "failed": None, "process_method": None}}
forks[2] = {'name': fork_failed, 'params': {"dirName": None, "failed": None}}
forks[3] = {'name': fork_failed_new, 'params': {"dir": None, "failed": None}}
forks[4] = {'name': fork_default_new, 'params': {"dir": None, "process": None}}
forks[5] = {'name': fork_default, 'params': {"dir": None}}
SICKBEARD_FAILED = [fork_failed, fork_failed_torrent, fork_failed_new]
SICKBEARD_TORRENT = [fork_failed_torrent]