From 3f29439ff36980f7e17623dca30b7f045801d501 Mon Sep 17 00:00:00 2001 From: echel0n Date: Fri, 12 Dec 2014 08:46:03 -0800 Subject: [PATCH] Fixed issues with network timezone downloads crashing on a empty return. Changed version checker url. --- .../default/manage_manageSearches.tmpl | 4 -- sickbeard/network_timezones.py | 20 ++++--- sickbeard/providers/kat.py | 4 +- sickbeard/webserve.py | 54 ++++++++++--------- 4 files changed, 44 insertions(+), 38 deletions(-) diff --git a/gui/slick/interfaces/default/manage_manageSearches.tmpl b/gui/slick/interfaces/default/manage_manageSearches.tmpl index a3de9033..f8d0e8b3 100644 --- a/gui/slick/interfaces/default/manage_manageSearches.tmpl +++ b/gui/slick/interfaces/default/manage_manageSearches.tmpl @@ -47,10 +47,6 @@ In Progress
#end if
-

Version Check:

- Force Check -

-

Search Queue:

Backlog: $queueLength['backlog'] pending items
Daily: $queueLength['daily'] pending items
diff --git a/sickbeard/network_timezones.py b/sickbeard/network_timezones.py index cdf0f292..57a145d4 100644 --- a/sickbeard/network_timezones.py +++ b/sickbeard/network_timezones.py @@ -75,19 +75,23 @@ def _update_zoneinfo(): # now check if the zoneinfo needs update url_zv = 'https://raw.githubusercontent.com/Prinz23/sb_network_timezones/master/zoneinfo.txt' - url_data = helpers.getURL(url_zv) - if url_data is None: + try: + url_data = helpers.getURL(url_zv) + if not url_data: + raise + + if lib.dateutil.zoneinfo.ZONEINFOFILE is not None: + cur_zoneinfo = ek.ek(basename, lib.dateutil.zoneinfo.ZONEINFOFILE) + else: + cur_zoneinfo = None + + (new_zoneinfo, zoneinfo_md5) = url_data.decode('utf-8').strip().rsplit(u' ') + except: # When urlData is None, trouble connecting to github logger.log(u'Loading zoneinfo.txt failed, this can happen from time to time. Unable to get URL: %s' % url_zv, logger.WARNING) return - if lib.dateutil.zoneinfo.ZONEINFOFILE is not None: - cur_zoneinfo = ek.ek(basename, lib.dateutil.zoneinfo.ZONEINFOFILE) - else: - cur_zoneinfo = None - (new_zoneinfo, zoneinfo_md5) = url_data.decode('utf-8').strip().rsplit(u' ') - if (cur_zoneinfo is not None) and (new_zoneinfo == cur_zoneinfo): return diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 40202a7b..538c69e9 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -234,7 +234,7 @@ class KATProvider(generic.TorrentProvider): logger.log(u"Search string: " + searchURL, logger.DEBUG) entries = self.cache.getRSSFeed(url, items=['entries', 'feed'])['entries'] - if entries and len(entries) > 0: + if entries: break try: @@ -361,7 +361,7 @@ class KATCache(tvcache.TVCache): logger.log(u"KAT cache update URL: " + searchURL, logger.DEBUG) data = self.getRSSFeed(url, items=['entries', 'feed']) - if data and len(data) > 0: + if data['entries']: break return data diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index bdac89e2..cffbdf9f 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -145,6 +145,8 @@ class BaseHandler(RequestHandler): self.redirect(url) else: self.write('Wrong API key used') + self.finish() + elif self.settings.get("debug") and "exc_info" in kwargs: exc_info = kwargs["exc_info"] trace_info = ''.join(["%s
" % line for line in traceback.format_exception(*exc_info)]) @@ -196,8 +198,11 @@ class WebHandler(BaseHandler): # process request async self.async_worker(method, self.async_done) except: + logger.log('Failed doing webui request "%s": %s' % (route, traceback.format_exc()), logger.ERROR) raise HTTPError(404) + def post(self, route, *args, **kwargs): + super(WebHandler, self).get(route, *args, **kwargs) @run_on_executor def async_worker(self, method, callback): @@ -207,22 +212,25 @@ class WebHandler(BaseHandler): kwargs[arg] = value[0] try: - callback(method(**kwargs)) - except Exception as e: + res = method(**kwargs) + callback(res) + except: + logger.log('Failed doing webui callback: %s' % (traceback.format_exc()), logger.ERROR) callback() def async_done(self, result=None): - if result: - try: - result = ek.ss(result).encode('utf-8', 'xmlcharrefreplace') - except: - result = str(result) + try: + result = ek.ss(result).encode('utf-8', 'xmlcharrefreplace') + except: + result = str(result) - try: - self.write(result) - self.finish() - except: - pass + try: + self.write(result) + self.finish() + except: + logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG) + try:self.finish() + except:pass def _genericMessage(self, subject, message): t = PageTemplate(rh=self, file="genericMessage.tmpl") @@ -266,9 +274,6 @@ class WebHandler(BaseHandler): else: return False - # post and get use same method - post = get - class LoginHandler(BaseHandler): def get(self, *args, **kwargs): @@ -614,7 +619,6 @@ class WebRoot(WebHandler): return ical - @route('/ui/(.*)(/?)') class UI(WebRoot): def add_message(self, *args, **kwargs): @@ -658,8 +662,6 @@ class Home(WebRoot): {'title': 'Update KODI', 'path': 'home/updateKODI/', 'requires': self.haveKODI}, {'title': 'Update Plex', 'path': 'home/updatePLEX/', 'requires': self.havePLEX}, {'title': 'Manage Torrents', 'path': 'manage/manageTorrents', 'requires': self.haveTORRENT}, - {'title': 'Restart', 'path': 'home/restart/?pid=' + str(sickbeard.PID), 'confirm': True}, - {'title': 'Shutdown', 'path': 'home/shutdown/?pid=' + str(sickbeard.PID), 'confirm': True}, ] return menu @@ -1003,14 +1005,18 @@ class Home(WebRoot): updated = sickbeard.versionCheckScheduler.action.update() # @UndefinedVariable if updated: - # do a hard restart - sickbeard.events.put(sickbeard.events.SystemEvent.RESTART) + # do a hard restart + sickbeard.events.put(sickbeard.events.SystemEvent.RESTART) - t = PageTemplate(rh=self, file="restart_bare.tmpl") - return t + t = PageTemplate(rh=self, file="restart_bare.tmpl") + return t else: - return self._genericMessage("Update Failed", - "Update wasn't successful, not restarting. Check your log for more information.") + if do_update: + return self._genericMessage("Update Failed", + "Update wasn't successful, not restarting. Check your log for more information.") + + if force: + self.redirect("/home/") def branchCheckout(self, branch): sickbeard.BRANCH = branch