Added in error handling to catch connection errors with autoFork.

Logger config now defaults to process.log if no logfile is specified.
This commit is contained in:
echel0n 2014-04-02 04:27:43 -07:00
commit 8573749038
4 changed files with 12 additions and 4 deletions

View file

@ -8,7 +8,6 @@ from autoProcess.autoSickBeardFork import autoFork
from nzbToMediaEnv import *
from nzbToMediaUtil import *
Logger = logging.getLogger()
class AuthURLOpener(urllib.FancyURLopener):

View file

@ -24,7 +24,7 @@ class AuthURLOpener(urllib.FancyURLopener):
self.numTries = 0
return urllib.FancyURLopener.open(self, url)
def autoFork(fork=None):
def autoFork():
# config settings
section = "SickBeard"
@ -62,7 +62,11 @@ def autoFork(fork=None):
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(fork[1])
# attempting to auto-detect fork
urlObj = myOpener.openit(url)
try:
urlObj = myOpener.openit(url)
except IOError, e:
Logger.info("Could not connect to SickBeard to perform auto-fork detection!")
break
if urlObj.getcode() == 200:
detected = True

View file

@ -28,7 +28,9 @@ def safeName(name):
return safename
def nzbtomedia_configure_logging(logfile):
def nzbtomedia_configure_logging(logfile=None):
if not logfile:
logfile = LOG_FILE
logging.config.fileConfig(CONFIG_FILE)
fileHandler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=1048576, backupCount=1, encoding='utf-8', delay=True)
fileHandler.formatter = logging.Formatter('%(asctime)s|%(levelname)-7.7s %(message)s', '%H:%M:%S')

View file

@ -1,3 +1,6 @@
from autoProcess.nzbToMediaUtil import *
from autoProcess.autoSickBeardFork import autoFork
nzbtomedia_configure_logging(LOG_FILE)
fork, params = autoFork()
print fork, params