From acadce4d963fd902945768ca948ebefee7601a48 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 19 Jun 2014 01:37:44 -0700 Subject: [PATCH] Fix for setting status via episode status manager --- sickbeard/webapi.py | 4 +-- sickbeard/webserve.py | 54 +++++++++++++++++++++++---------------- sickbeard/webserveInit.py | 2 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index c149cd99..226f5662 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -64,7 +64,7 @@ result_type_map = {RESULT_SUCCESS: "success", } # basically everything except RESULT_SUCCESS / success is bad -class Api(webserve.IndexHandler): +class Api(webserve.MainHandler): """ api class that returns json results """ version = 4 # use an int since float-point is unpredictible intent = 4 @@ -296,7 +296,7 @@ def filter_params(cmd, args, kwargs): return curArgs, curKwargs -class ApiCall(webserve.IndexHandler): +class ApiCall(webserve.MainHandler): _help = {"desc": "No help message available. Please tell the devs that a help msg is missing for this cmd"} def __init__(self, args, kwargs): diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 333dc257..9024c8c1 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -129,9 +129,9 @@ def authenticated(handler_class): @authenticated -class IndexHandler(RequestHandler): +class MainHandler(RequestHandler): def __init__(self, application, request, **kwargs): - super(IndexHandler, self).__init__(application, request, **kwargs) + super(MainHandler, self).__init__(application, request, **kwargs) global req_headers sickbeard.REMOTE_IP = self.request.remote_ip @@ -161,7 +161,7 @@ class IndexHandler(RequestHandler): elif status_code == 401: self.finish(self.http_error_401_handler()) else: - super(IndexHandler, self).write_error(status_code, **kwargs) + super(MainHandler, self).write_error(status_code, **kwargs) def _dispatch(self): @@ -208,7 +208,7 @@ class IndexHandler(RequestHandler): def redirect(self, url, permanent=False, status=None): self._transforms = [] - super(IndexHandler, self).redirect(sickbeard.WEB_ROOT + url, permanent, status) + super(MainHandler, self).redirect(sickbeard.WEB_ROOT + url, permanent, status) @asynchronous @gen.engine @@ -497,7 +497,7 @@ class PageTemplate(Template): ] -class IndexerWebUI(IndexHandler): +class IndexerWebUI(MainHandler): def __init__(self, config, log=None): self.config = config self.log = log @@ -565,7 +565,7 @@ def ManageMenu(): return manageMenu -class ManageSearches(IndexHandler): +class ManageSearches(MainHandler): def index(self, *args, **kwargs): t = PageTemplate(file="manage_manageSearches.tmpl") # t.backlogPI = sickbeard.backlogSearchScheduler.action.getProgressIndicator() @@ -620,7 +620,7 @@ class ManageSearches(IndexHandler): return self.redirect("/manage/manageSearches/") -class Manage(IndexHandler): +class Manage(MainHandler): def index(self, *args, **kwargs): t = PageTemplate(file="manage.tmpl") t.submenu = ManageMenu() @@ -728,7 +728,7 @@ class Manage(IndexHandler): all_eps = [str(x["season"]) + 'x' + str(x["episode"]) for x in all_eps_results] to_change[cur_indexer_id] = all_eps - Home.setStatus(cur_indexer_id, '|'.join(to_change[cur_indexer_id]), newStatus, direct=True) + Home(self.application, self.request).setStatus(cur_indexer_id, '|'.join(to_change[cur_indexer_id]), newStatus, direct=True) return self.redirect('/manage/episodeStatuses/') @@ -1226,7 +1226,7 @@ class Manage(IndexHandler): return _munge(t) -class History(IndexHandler): +class History(MainHandler): def index(self, limit=100): # sqlResults = myDB.select("SELECT h.*, show_name, name FROM history h, tv_shows s, tv_episodes e WHERE h.showid=s.indexer_id AND h.showid=e.showid AND h.season=e.season AND h.episode=e.episode ORDER BY date DESC LIMIT "+str(numPerPage*(p-1))+", "+str(numPerPage)) @@ -1328,7 +1328,7 @@ ConfigMenu = [ ] -class ConfigGeneral(IndexHandler): +class ConfigGeneral(MainHandler): def index(self, *args, **kwargs): t = PageTemplate(file="config_general.tmpl") @@ -1474,7 +1474,7 @@ class ConfigGeneral(IndexHandler): ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) -class ConfigSearch(IndexHandler): +class ConfigSearch(MainHandler): def index(self, *args, **kwargs): t = PageTemplate(file="config_search.tmpl") @@ -1557,7 +1557,8 @@ class ConfigSearch(IndexHandler): ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) -class ConfigPostProcessing(IndexHandler): +class ConfigPostProcessing(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="config_postProcessing.tmpl") @@ -1728,7 +1729,8 @@ class ConfigPostProcessing(IndexHandler): return 'not supported' -class ConfigProviders(IndexHandler): +class ConfigProviders(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="config_providers.tmpl") t.submenu = ConfigMenu @@ -2098,7 +2100,8 @@ class ConfigProviders(IndexHandler): ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) -class ConfigNotifications(IndexHandler): +class ConfigNotifications(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="config_notifications.tmpl") t.submenu = ConfigMenu @@ -2299,7 +2302,8 @@ class ConfigNotifications(IndexHandler): ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) -class ConfigSubtitles(IndexHandler): +class ConfigSubtitles(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="config_subtitles.tmpl") t.submenu = ConfigMenu @@ -2356,7 +2360,8 @@ class ConfigSubtitles(IndexHandler): ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) -class ConfigAnime(IndexHandler): +class ConfigAnime(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="config_anime.tmpl") @@ -2401,7 +2406,8 @@ class ConfigAnime(IndexHandler): ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) -class Config(IndexHandler): +class Config(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="config.tmpl") t.submenu = ConfigMenu @@ -2447,7 +2453,8 @@ def HomeMenu(): ] -class HomePostProcess(IndexHandler): +class HomePostProcess(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="home_postprocess.tmpl") @@ -2493,7 +2500,8 @@ class HomePostProcess(IndexHandler): return _genericMessage("Postprocessing results", result) -class NewHomeAddShows(IndexHandler): +class NewHomeAddShows(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="home_addShows.tmpl") @@ -2878,7 +2886,8 @@ ErrorLogsMenu = [ ] -class ErrorLogs(IndexHandler): +class ErrorLogs(MainHandler): + def index(self, *args, **kwargs): t = PageTemplate(file="errorlogs.tmpl") @@ -2946,7 +2955,8 @@ class ErrorLogs(IndexHandler): return _munge(t) -class Home(IndexHandler): +class Home(MainHandler): + def is_alive(self, *args, **kwargs): if 'callback' in kwargs and '_' in kwargs: callback, _ = kwargs['callback'], kwargs['_'] @@ -4193,7 +4203,7 @@ class Home(IndexHandler): return json.dumps({'result': 'failure'}) -class UI(IndexHandler): +class UI(MainHandler): def add_message(self, *args, **kwargs): ui.notifications.message('Test 1', 'This is test number 1') ui.notifications.error('Test 2', 'This is test number 2') diff --git a/sickbeard/webserveInit.py b/sickbeard/webserveInit.py index 0424aa6e..7a95e240 100644 --- a/sickbeard/webserveInit.py +++ b/sickbeard/webserveInit.py @@ -75,7 +75,7 @@ def initWebServer(options={}): app.add_handlers(".*$", [ (r"/", RedirectHandler, {'url': '%s/home/' % options['web_root']}), (r'%s/api/(.*)(/?)' % options['web_root'], webapi.Api), - (r'%s/(.*)(/?)' % options['web_root'], webserve.IndexHandler) + (r'%s/(.*)(/?)' % options['web_root'], webserve.MainHandler) ]) # Static Path Handler