Exemplo n.º 1
0
    def __init__(self):
        base_path = os.path.dirname(__file__)
        settings = {
            'template_path': os.path.join(base_path, 'templates'),
            'static_path': os.path.join(base_path, 'static'),
            'debug': True,
        }

        handlers = [
            U('/conflict', ConflictListHandler, name='Conflict'),
            U('/jobinfo/all', JobInfoHandler, name='allJobInfo'),
            U(r'/jobinfo/pf.*', JobInfoHandler, name='eachJobInfo'),
            U('/summary', JobSummaryHandler, name='summary'),
            U('/index', IndexHandler, name="index"),
            U('/nodesummary/all', NodeSummaryHandler, name="allnodesummary"),
            U(r'/nodesummary/pf.*', NodeSummaryHandler,
              name="eachnodesummary"),
            U('/flowsummary/all', FlowSummaryHandler, name="allflowsummary"),
            U(r'/flowsummary/pf.*', FlowSummaryHandler,
              name="eachflowsummary"),
            U(r'/nodesummary_range.*',
              NodeSummaryDateRange,
              name="nodesummary_range"),

            # U('/summery/update', SummeryEditHandler, name='summery_update'),
            # U('/problem/delete', ProblemDeleteHandler, name='problem_delete'),
            # U('/problem/update', ProblemUpdateHandler, name='problem_update'),
            # U('/extraction/update', ExtractionEditHandler, name='extraction_update'),
            # U('/problem/export', ProblemExportHandler, name='problem_export'),
            # U('/summery/export', SummeryExportHandler, name='summery_export'),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)
Exemplo n.º 2
0
    def __init__(self):
        app_settings = dict(
            cookie_secret=COOKIE_SECRET,
            debug=options.debug,
        )

        test_urls = [
            U(r"/seekplum/test/(?P<node_id>[\d]+)", TestHandler),  # 测试使用
            U(r"/seekplum/test1/(?P<node_id>[\d]+)", Test1Handler),  # 测试使用
        ]

        super(Application, self).__init__(test_urls, **app_settings)
Exemplo n.º 3
0
    def __init__(self, debug=False):
        handlers = [
            U(r'/', IndexHandler, name='index'),
            U(r'/(http|https|uggc|uggcf)/(.+)', FartHandler),
        ]
        template_path = os.path.join(os.path.dirname(__file__), 'templates')
        static_path = os.path.join(os.path.dirname(__file__), 'static')

        super().__init__(
            handlers,
            template_path=template_path,
            static_path=static_path,
            debug=debug,
            xsrf_cookies=True,
            cookie_secret=os.urandom(16),
        )
Exemplo n.º 4
0
    def __init__(self):
        app_settings = dict(cookie_secret=COOKIE_SECRET,
                            debug=options.debug)  # 相关API
        handlers = [
            U(r"/v1/hello", HelloHandler),
            U(r"/v1/httpx/get", HttpxHandler),
            U(r"/v1/requests/get", RequetsHandler),
            U(r"/v1/hello/get", RequetsHandler),
            U(r"/v1/httplib/get", HttplibHandler),
            U(r"/v1/http/get", HttpHandler),
            # U(r"/v1/httpclient/get", HTTPClientlibHandler),
            U(r"/v1/asynchttpclient/get", AsyncHTTPClientlibHandler),
        ]

        super(Application, self).__init__(handlers, **app_settings)
Exemplo n.º 5
0
def make_app(**kwargs):
    """
    Parse the config file and instantiate a tornado app.
    """
    parse_options()

    URLS = [
        U(r"%slogin/" % options.url_prefix, LoginHandler, name="login"),
        U(r"%slogout/" % options.url_prefix, LogoutHandler, name="logout"),
        U(r"%sreload_collector/" % options.url_prefix, CollectorReloadHandler,
          name="reload_collector"),
        U(r"%sserver/select" % options.url_prefix, ServerSelector,
          name="server_selector"),
        U(r"%sdatabase/select" % options.url_prefix, DatabaseSelector,
          name="database_selector"),
        U(r"%s" % options.url_prefix, IndexHandler, name="index"),
        U(r"%sserver/(\d+)/database/([^\/]+)/suggest/" % options.url_prefix,
          IndexSuggestionHandler, name="index_suggestion")
    ]

    for dashboard in (Overview,
                      ServerOverview,
                      DatabaseOverview,
                      QueryOverview,
                      QualOverview,
                      RepositoryConfigOverview,
                      RemoteConfigOverview):
        URLS.extend(dashboard.url_specs(options.url_prefix))

    _cls = Application
    if 'legacy_wsgi' in kwargs:
        from tornado.wsgi import WSGIApplication
        _cls = WSGIApplication

    return _cls(
        URLS,
        ui_modules=ui_modules,
        ui_methods=ui_methods,
        login_url=("%slogin/" % options.url_prefix),
        static_path=os.path.join(POWA_ROOT, "static"),
        static_url_prefix=("%sstatic/" % options.url_prefix),
        cookie_secret=options.cookie_secret,
        template_path=os.path.join(POWA_ROOT, "templates"),
        **kwargs)
Exemplo n.º 6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from tornado import web
from tornado.web import URLSpec as U
from handlers.lottery import LotteryTypeHandler, WinnerHandler
from handlers.sse import SseHandler, PlayerHandler


handlers = [
    U(r"/lottery_type", LotteryTypeHandler),
    U(r"/event", SseHandler),
    U(r"/winners", WinnerHandler),
    U(r"/players", PlayerHandler),
]
Exemplo n.º 7
0
    def __init__(self, database, redis=None, **kwargs):
        self.db = database
        self.redis = redis

        handlers = [
            U(r'/', IndexHandler, name='index'),
            U(r'/admin/', admin.AdminHandler, name='admin.overview'),
            U(r'/admin/banned', admin.BannedHandler, name='admin.banned'),
            U(r'/admin/login', account.LoginHandler, name='admin.login'),
            U(r'/admin/logout', account.LogoutHandler, name='admin.logout'),
            U(r'/admin/results', admin.ResultsHandler, name='admin.results'),
            U(r'/admin/error_reports',
              admin.ErrorReportsListHandler,
              name='admin.error_reports'),
            U(r'/admin/error_reports/delete_all',
              admin.ErrorReportsDeleteAllHandler,
              name='admin.error_reports.delete_all'),
            U(r'/admin/error_reports/delete_one/(.+)',
              admin.ErrorReportsDeleteOneHandler,
              name='admin.error_reports.delete_one'),
            U(r'/admin/error_reports/auto_delete_setting',
              admin.AutoDeleteErrorReportsSettingHandler,
              name='admin.error_reports.auto_delete_setting'),
            U(r'/users/', account.AllUsersHandler, name='users.overview'),
            U(r'/user/([a-z0-9_-]*)',
              account.UserHandler,
              name='user.overview'),
            U(r'/projects/overview',
              project.AllProjectsHandler,
              name='projects.overview'),
            U(r'/project/([a-z0-9_-]*)',
              project.ProjectHandler,
              name='project.overview'),
            U(r'/project/([a-z0-9_-]*)/queue',
              project.QueueHandler,
              name='project.queue'),
            U(r'/project/([a-z0-9_-]*)/claims',
              project.ClaimsHandler,
              name='project.claims'),
            U(r'/project/([a-z0-9_-]*)/settings',
              project.SettingsHandler,
              name='project.settings'),
            U(r'/project/([a-z0-9_-]*)/delete',
              project.DeleteHandler,
              name='project.delete'),
            U(r'/api/live_stats', api.LiveStatsHandler, name='api.live_stats'),
            U(r'/api/project_settings',
              api.ProjectSettingsHandler,
              name='api.project_settings'),
            U(r'/api/get', api.GetHandler, name='api.get'),
            U(r'/api/done', api.DoneHandler, name='api.done'),
            U(r'/api/error', api.ErrorHandler, name='api.error'),
            U(r'/status', StatusHandler, name='index.status'),
            U(r'/calculator', CalculatorHandler, name='index.calculator'),
        ]

        static_path = os.path.join(os.path.dirname(__file__), 'static')
        template_path = os.path.join(os.path.dirname(__file__), 'template')

        ui_modules = {
            'Form': FormUIModule,
        }

        super(Application, self).__init__(handlers,
                                          static_path=static_path,
                                          template_path=template_path,
                                          login_url='/admin/login',
                                          ui_modules=ui_modules,
                                          **kwargs)

        def job_task():
            if self.is_maintenance_in_progress():
                return

            model.Item.release_old(autoqueue_only=True)
            model.Budget.calculate_budgets()

        job_task()

        self._job_timer = tornado.ioloop.PeriodicCallback(job_task, 60 * 1000)
        self._job_timer.start()

        def clean_error_reports():
            if self.is_maintenance_in_progress():
                return

            enabled = GlobalSetting.get_value(
                GlobalSetting.AUTO_DELETE_ERROR_REPORTS)

            if enabled:
                ErrorReport.delete_orphaned()

        clean_error_reports()

        self._clean_error_reports_timer = tornado.ioloop.PeriodicCallback(
            clean_error_reports, 300 * 1000)
        self._clean_error_reports_timer.start()
Exemplo n.º 8
0
from tornado.web import URLSpec as U

from icecat.views import HomeHandler, UpdateHandler, ProductHandler

HANDLERS = [
    U(r'/', HomeHandler, name='home'),
    U(r'/update/', UpdateHandler, name='update'),
    U(r'/product/(?P<product_id>[0-9]*)/', ProductHandler, name='product')
]
Exemplo n.º 9
0
from powa.query import QueryOverview
from powa.qual import QualOverview
from powa.config import ConfigOverview
from powa.wizard import IndexSuggestionHandler


class IndexHandler(AuthHandler):
    """
    Handler for the main page.
    """
    def get(self):
        return self.redirect(options.index_url)


URLS = [
    U(r"/login/", LoginHandler, name="login"),
    U(r"/logout/", LogoutHandler, name="logout"),
    U(r"/database/select", DatabaseSelector, name="database_selector"),
    U(r"/", IndexHandler, name="index"),
    U(r"/database/([^\/]+)/suggest/",
      IndexSuggestionHandler,
      name="index_suggestion")
]

for dashboard in (Overview, DatabaseOverview, QueryOverview, QualOverview,
                  ConfigOverview):
    URLS.extend(dashboard.url_specs())


def make_app(**kwargs):
    """
            send = True
        else:
            pass
        return send, msg

    def post(self):
        # {u'status': u'successful', u'name': u'zhongguoyidong-6.3.0', u'started': u'2019-10-20T18:44:23.692415+00:00', u'traceback': u'', u'friendly_name': u'Project Update', u'created_by': u'None', u'url': u'https://192.168.1.99/#/scm_update/1851', u'finished': u'2019-10-20T18:44:33.629823+00:00', u'id': 1851}
        data = json.loads(self.request.body, strict=False)
        logger.info(data)
        send, msg = self.parse_data(data)
        if send:
            self.render_info(msg)
        return self.write("bbb")

urls = [
    U('/v1/call', GetStatusHandler),
]


class Application(tornado.web.Application):
    def __init__(self):
        app_settings = dict(
            debug=options.debug,
        )
        super(Application, self).__init__(urls, **app_settings)


def main():
    tornado.options.parse_command_line()
    app = Application()
    http_server = tornado.httpserver.HTTPServer(app)
Exemplo n.º 11
0
            pass
        self.write("Hello world, TestHandler2")


class TestHandler3(BaseRequestHandler):
    """测试使用的handler
    """
    @gen.coroutine
    def get(self):
        print(self.executor)
        self.write("Hello world, TestHandler3")


# 相关API
handlers = [
    U(r"/test", TestHandler),
    U(r"/test2", TestHandler2),
    U(r"/test3", TestHandler3),
]


class Application(tornado.web.Application):
    def __init__(self):
        app_settings = dict(cookie_secret=COOKIE_SECRET, debug=options.debug)

        super(Application, self).__init__(handlers, **app_settings)


def main():
    """tornado入口函数
    """
Exemplo n.º 12
0
    def __init__(self, database, debug=False, prefix='/'):
        self.database = database

        handlers = (
            U(prefix + r'', IndexHandler, name='index'),
            U(prefix + r'audit', AuditHandler, name='audit'),
            U(prefix + r'stats', StatsHandler, name='stats'),
            U(prefix + r'domains/(\w?)', DomainsHandler, name='domains'),
            U(prefix + r'domain/([\w.%-]+)', DomainHandler, name='domain'),
            U(prefix + r'items/', ItemsHandler, name='items'),
            U(prefix + r'item/([\w-]+)', ItemHandler, name='item'),
            U(prefix + r'jobs/(\w?)', JobsHandler, name='jobs'),
            U(prefix + r'job/([\w-]+)', JobHandler, name='job'),
            U(prefix + r'costs', CostLeaderboardHandler, name='costs'),

            U(prefix + r'api/v1/search.json', ApiSearchHandler, name='api-search'),
        )

        static_path = os.path.join(
            os.path.dirname(__file__), 'static'
        )
        template_path = os.path.join(
            os.path.dirname(__file__), 'templates'
        )

        super().__init__(
            handlers, static_path=static_path,
            template_path=template_path,
            debug=debug
        )
Exemplo n.º 13
0
from powa.database import DatabaseSelector, DatabaseOverview
from powa.query import QueryOverview
from powa.qual import QualOverview
from powa.config import ConfigOverview


class IndexHandler(AuthHandler):
    """
    Handler for the main page.
    """
    def get(self):
        return self.redirect("/overview/")


URLS = [
    U(r"/login/", LoginHandler, name="login"),
    U(r"/logout/", LogoutHandler, name="logout"),
    U(r"/database/select", DatabaseSelector, name="database_selector"),
    U(r"/", IndexHandler, name="index")
]

for dashboard in (Overview, DatabaseOverview, QueryOverview, QualOverview,
                  ConfigOverview):
    URLS.extend(dashboard.url_specs())


def make_app(**kwargs):
    """
    Parse the config file and instantiate a tornado app.
    """
    parse_options()
Exemplo n.º 14
0
import os.path, asyncio, logging
import signal
from tornado import web
from tornado.web import URLSpec as U
from concurrent.futures import ThreadPoolExecutor
import sentry_sdk
from sentry_sdk.integrations.tornado import TornadoIntegration

import seplis
from seplis.logger import logger
from seplis.io_sighandler import sig_handler
from . import handlers as h

static_path = os.path.join(os.path.dirname(__file__), 'static')
urls = [
    U(r'/(favicon.ico)', web.StaticFileHandler, {'path': os.path.join(static_path, 'favicon.ico')}),
    U(r'/static/(.*)', web.StaticFileHandler, {'path': static_path}),

    U(r'/1/shows', h.show.Handler),
    U(r'/1/shows/externals/([a-z_-]+)/([a-z0-9]+)', h.show.External_handler),            
    U(r'/1/shows/([0-9]+)', h.show.Handler),
    U(r'/1/shows/([0-9,]+)', h.show.Multi_handler),
    U(r'/1/shows/([0-9]+)/user-stats', h.user_show_stats.Handler),
    U(r'/1/shows/([0-9]+)/images', h.image.Handler, {'relation_type': 'show'}),
    U(r'/1/shows/([0-9]+)/images/([0-9]+)', h.image.Handler),
    U(r'/1/shows/([0-9]+)/images/([0-9]+)/data', h.image.Data_handler),
    U(r'/1/shows/([0-9]+)/update', h.show.Update_handler),    
    U(r'/1/shows/([0-9]+)/user-subtitle-lang', h.user_show_subtitle_lang.Handler),
    U(r'/1/shows/([0-9]+)/episodes', h.episode.Handler),
    U(r'/1/shows/([0-9]+)/episodes/to-watch', h.episode_to_watch.Handler),
    U(r'/1/shows/([0-9]+)/episodes/last-watched', h.episode_last_watched.Handler),
Exemplo n.º 15
0
from powa.qual import QualOverview
from powa.config import RepositoryConfigOverview, RemoteConfigOverview
from powa.collector import CollectorReloadHandler
from powa.wizard import IndexSuggestionHandler


class IndexHandler(AuthHandler):
    """
    Handler for the main page.
    """
    def get(self):
        return self.redirect(options.index_url)


URLS = [
    U(r"/login/", LoginHandler, name="login"),
    U(r"/logout/", LogoutHandler, name="logout"),
    U(r"/reload_collector/", CollectorReloadHandler, name="reload_collector"),
    U(r"/server/select", ServerSelector, name="server_selector"),
    U(r"/database/select", DatabaseSelector, name="database_selector"),
    U(r"/", IndexHandler, name="index"),
    U(r"/server/(\d+)/database/([^\/]+)/suggest/",
      IndexSuggestionHandler,
      name="index_suggestion")
]

for dashboard in (Overview, ServerOverview, DatabaseOverview, QueryOverview,
                  QualOverview, RepositoryConfigOverview,
                  RemoteConfigOverview):
    URLS.extend(dashboard.url_specs())