mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 10:36:52 -07:00
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:
parent
8655082503
commit
8573749038
4 changed files with 12 additions and 4 deletions
|
@ -8,7 +8,6 @@ from autoProcess.autoSickBeardFork import autoFork
|
|||
from nzbToMediaEnv import *
|
||||
from nzbToMediaUtil import *
|
||||
|
||||
|
||||
Logger = logging.getLogger()
|
||||
|
||||
class AuthURLOpener(urllib.FancyURLopener):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
from autoProcess.nzbToMediaUtil import *
|
||||
from autoProcess.autoSickBeardFork import autoFork
|
||||
nzbtomedia_configure_logging(LOG_FILE)
|
||||
|
||||
fork, params = autoFork()
|
||||
print fork, params
|
Loading…
Add table
Add a link
Reference in a new issue