From 98ff924b1c85ce19773bdf7b279d5110438ce2d0 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 17 Jun 2014 08:36:46 -0700 Subject: [PATCH] Fix for nullhandler issues for py2.6 users, Fix for rsstorrents. --- sickbeard/logger.py | 7 +++-- sickbeard/providers/rsstorrent.py | 2 +- sickbeard/webserve.py | 51 +++++++++++++------------------ 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/sickbeard/logger.py b/sickbeard/logger.py index 368dbf30..25077ace 100644 --- a/sickbeard/logger.py +++ b/sickbeard/logger.py @@ -48,6 +48,10 @@ reverseNames = {u'ERROR': ERROR, u'DEBUG': DEBUG, u'DB': DB} +# send logging to null +class NullHandler(logging.Handler): + def emit(self, record): + pass class SBRotatingLogHandler(object): def __init__(self, log_file, num_files, num_bytes): @@ -143,8 +147,7 @@ class SBRotatingLogHandler(object): logging.getLogger('subliminal').setLevel(log_level) logging.getLogger('imdbpy').setLevel(log_level) - # send logging to null - logging.getLogger('tornado.access').addHandler(logging.NullHandler()) + logging.getLogger('tornado.access').addHandler(NullHandler()) # already logging in new log folder, close the old handler if old_handler: diff --git a/sickbeard/providers/rsstorrent.py b/sickbeard/providers/rsstorrent.py index 7b9f9a47..64d6e64d 100644 --- a/sickbeard/providers/rsstorrent.py +++ b/sickbeard/providers/rsstorrent.py @@ -50,7 +50,7 @@ class TorrentRssProvider(generic.TorrentProvider): if cookies: self.cookies = cookies else: - self.cookies = None + self.cookies = '' def configStr(self): return self.name + '|' + self.url + '|' + self.cookies + '|' + str(int(self.enabled)) + '|' + self.search_mode + '|' + str(int(self.search_fallback)) + '|' + str(int(self.backlog_only)) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index f4f68b65..0a094a05 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -23,6 +23,7 @@ import inspect import os.path import time +import traceback import urllib import re import threading @@ -200,33 +201,27 @@ class IndexHandler(RedirectHandler): if self.request.uri != ('/'): raise HTTPError(404) - def get_response(self): - raise gen.Return('hello') - def get_current_user(self): return self.get_secure_cookie("user") @authenticated @asynchronous - @gen.coroutine def get(self, *args, **kwargs): - try: - resp = yield self.get_response() - self.finish(resp) - except Exception as e: - logger.log(e, logger.ERROR) - self.finish() - - @gen.coroutine - def get_response(self): - raise gen.Return(self._dispatch()) - - def post(self, *args, **kwargs): try: self.finish(self._dispatch()) except Exception as e: - logger.log(e, logger.ERROR) - self.finish() + logger.log(ex(e), logger.ERROR) + logger.log(u"Traceback: " + traceback.format_exc(), logger.DEBUG) + self.finish(ex(e)) + + def post(self, *args, **kwargs): + try: + resp = self._dispatch() + self.finish(resp) + except Exception as e: + logger.log(ex(e), logger.ERROR) + logger.log(u"Traceback: " + traceback.format_exc(), logger.DEBUG) + self.finish(ex(e)) def robots_txt(self, *args, **kwargs): """ Keep web crawlers out """ @@ -550,7 +545,6 @@ def _getEpisode(show, season=None, episode=None, absolute=None): return epObj - def ManageMenu(): manageMenu = [ {'title': 'Backlog Overview', 'path': 'manage/backlogOverview/'}, @@ -625,17 +619,6 @@ class ManageSearches(IndexHandler): self.redirect("/manage/manageSearches/") - - def forceVersionCheck(self, *args, **kwargs): - - # force a check to see if there is a new version - result = sickbeard.versionCheckScheduler.action.check_for_new_version(force=True) # @UndefinedVariable - if result: - logger.log(u"Forcing version check") - - self.redirect("/manage/manageSearches/") - - class Manage(IndexHandler): def index(self, *args, **kwargs): t = PageTemplate(file="manage.tmpl") @@ -2485,6 +2468,14 @@ class HomePostProcess(IndexHandler): return _munge(t) + def forceVersionCheck(self, *args, **kwargs): + + # force a check to see if there is a new version + if sickbeard.versionCheckScheduler.action.check_for_new_version(force=True): + logger.log(u"Forcing version check") + + self.redirect("/home/") + def processEpisode(self, dir=None, nzbName=None, jobName=None, quiet=None, process_method=None, force=None, is_priority=None, failed="0", type="auto"):