Commit 98396dc7 authored by echel0n's avatar echel0n
Browse files

Refactored web handlers to return data and call tornado finish on resp from run_async method

Merged base handler render_string and render methods into render method
Refactored base handlers for API v1 and v2
Fixed redirect issues for auth handlers
parent a7bffda5
......@@ -39,7 +39,7 @@ from sickrage.core.helpers import create_https_certificates
from sickrage.core.webserver.handlers.account import AccountLinkHandler, AccountUnlinkHandler, AccountIsLinkedHandler
from sickrage.core.webserver.handlers.announcements import AnnouncementsHandler, MarkAnnouncementSeenHandler, AnnouncementCountHandler
from sickrage.core.webserver.handlers.api import ApiSwaggerDotJsonHandler, ApiPingHandler, ApiProfileHandler
from sickrage.core.webserver.handlers.api.v1 import ApiV1BaseHandler
from sickrage.core.webserver.handlers.api.v1 import ApiV1Handler
from sickrage.core.webserver.handlers.api.v2 import ApiV2RetrieveSeriesMetadataHandler
from sickrage.core.webserver.handlers.api.v2.config import ApiV2ConfigHandler
from sickrage.core.webserver.handlers.api.v2.file_browser import ApiV2FileBrowserHandler
......@@ -204,7 +204,7 @@ class WebServer(object):
# API v1 Handlers
self.handlers['api_v1_handlers'] = [
# api
(fr'{self.api_v1_root}(/?.*)', ApiV1BaseHandler),
(fr'{self.api_v1_root}(/?.*)', ApiV1Handler),
# api builder
(fr'{}/api/builder', RedirectHandler,
......@@ -23,7 +23,6 @@ import datetime
import functools
import os
import re
import threading
import time
import traceback
import types
......@@ -84,12 +83,12 @@ class ApiV1BaseHandler(RequestHandler):
version = 5 # use an int since float-point is unpredictable
def __init__(self, application, request, **kwargs):
super(RequestHandler, self).__init__(application, request, **kwargs)
super(ApiV1BaseHandler, self).__init__(application, request, **kwargs)
self.executor = ThreadPoolExecutor(thread_name_prefix='APIv1-Thread')
def prepare(self, *args, **kwargs):
class ApiV1Handler(ApiV1BaseHandler):
def prepare(self, *args, **kwargs):
# set the output callback
# default json
output_callback_dict = {
......@@ -275,7 +274,7 @@ class ApiV1BaseHandler(RequestHandler):
return curArgs, curKwargs
class ApiCall(ApiV1BaseHandler):
class ApiCall(ApiV1Handler):
_help = {"desc": "This command is not documented. Please report this to the developers."}
def __init__(self, application, request, *args, **kwargs):
......@@ -27,7 +27,7 @@ from sickrage.core.webserver.handlers.api import APIBaseHandler
class ApiV2BaseHandler(APIBaseHandler):
def __init__(self, application, request, **kwargs):
super(APIBaseHandler, self).__init__(application, request, **kwargs)
super(ApiV2BaseHandler, self).__init__(application, request, **kwargs)
self.executor = ThreadPoolExecutor(thread_name_prefix='APIv2-Thread')
......@@ -34,7 +34,7 @@ from sickrage.core.helpers import remove_article
from import series_image, SeriesImageType
from import ComingEpisodes, ComingEpsLayout, ComingEpsSortBy
from import get_show_list, find_show
from sickrage.core.webserver import ApiV1BaseHandler
from sickrage.core.webserver.handlers.api.v1 import ApiV1Handler
from sickrage.core.webserver.handlers.base import BaseHandler
......@@ -84,7 +84,7 @@ class APIBulderHandler(BaseHandler):
apikey = _('API Key not generated')
api_commands = {}
for command, api_call in ApiV1BaseHandler(self.application, self.request).api_calls.items():
for command, api_call in ApiV1Handler(self.application, self.request).api_calls.items():
api_commands[command] = api_call(self.application, self.request, **{'help': 1}).run()
return self.render('api_builder.mako',
......@@ -3,7 +3,6 @@
import json
from collections import OrderedDict
from sickrage.core.webserver.handlers.api.v1 import ApiV1BaseHandler
<%block name="metas">
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment