예제 #1
0
파일: web.py 프로젝트: VADemon/seesaw-kit
def start_warrior_server(warrior, bind_address="localhost", port_number=8001,
                         http_username=None, http_password=None):
    '''Starts the warrior web interface.'''
    SeesawConnection.warrior = warrior

    warrior.on_projects_loaded += SeesawConnection.handle_projects_loaded
    warrior.on_project_refresh += SeesawConnection.handle_project_refresh
    warrior.on_project_installing += SeesawConnection.handle_project_installing
    warrior.on_project_installed += SeesawConnection.handle_project_installed
    warrior.on_project_installation_failed += \
        SeesawConnection.handle_project_installation_failed
    warrior.on_project_selected += SeesawConnection.handle_project_selected
    warrior.on_broadcast_message_received += SeesawConnection.handle_broadcast_message
    warrior.on_status += SeesawConnection.handle_warrior_status
    warrior.runner.on_pipeline_start_item += SeesawConnection.handle_start_item
    warrior.runner.on_pipeline_finish_item += \
        SeesawConnection.handle_finish_item
    warrior.runner.on_status += SeesawConnection.handle_runner_status

    if not http_username:
        http_username = warrior.http_username
    if not http_password:
        http_password = warrior.http_password

    ioloop.PeriodicCallback(SeesawConnection.broadcast_bandwidth, 1000).start()
    ioloop.PeriodicCallback(SeesawConnection.broadcast_timestamp, 1000).start()
    
    router = SockJSRouter(SeesawConnection)

    application = AuthenticatedApplication(
        router.apply_routes([
            (r"/(.*\.(html|css|js|swf|png|ico))$",
                web.StaticFileHandler, {"path": PUBLIC_PATH}),
            ("/", IndexHandler),
            ("/api/(.+)$", ApiHandler, {"warrior": warrior})]),
        #   flash_policy_port = 843,
        #   flash_policy_file = os.path.join(PUBLIC_PATH, "flashpolicy.xml"),
        socket_io_address=bind_address,
        socket_io_port=port_number,

        # settings for AuthenticatedApplication
        auth_enabled=lambda: (realize(http_password) or "").strip() != "",
        check_auth=lambda r, username, password:
            (
                password == realize(http_password) and
                (realize(http_username) or "").strip() in ["", username]
            ),
        auth_realm="ArchiveTeam Warrior",
        skip_auth=[tornado_url[0] for tornado_url in router.urls]
    )

    application.listen(port_number, bind_address)
예제 #2
0
파일: web.py 프로젝트: VADemon/seesaw-kit
def start_runner_server(project, runner, bind_address="localhost", port_number=8001,
                        http_username=None, http_password=None):
    '''Starts a web interface for a manually run pipeline.

    Unlike :func:`start_warrior_server`, this UI does not contain an
    configuration or project management panel.
    '''
#     if bind_address == "0.0.0.0":
#         bind_address = ""

    SeesawConnection.project = project
    SeesawConnection.runner = runner

    runner.on_pipeline_start_item += SeesawConnection.handle_start_item
    runner.on_pipeline_finish_item += SeesawConnection.handle_finish_item
    runner.on_status += SeesawConnection.handle_runner_status
    
    ioloop.PeriodicCallback(SeesawConnection.broadcast_timestamp, 1000).start()
    
    router = SockJSRouter(SeesawConnection)

    application = AuthenticatedApplication(
        router.apply_routes([
            (r"/(.*\.(html|css|js|swf|png|ico))$",
                web.StaticFileHandler, {"path": PUBLIC_PATH}),
            ("/", IndexHandler),
            ("/api/(.+)$", ApiHandler, {"runner": runner})]),
        #  flash_policy_port = 843,
        #  flash_policy_file=os.path.join(PUBLIC_PATH, "flashpolicy.xml"),
        socket_io_address=bind_address,
        socket_io_port=port_number,

        # settings for AuthenticatedApplication
        auth_enabled=(http_password or "").strip() != "",
        check_auth=lambda r, username, password:
            (
                password == http_password and
                (http_username or "").strip() in ["", username]
            ),
        auth_realm="ArchiveTeam Warrior",
        skip_auth=[r"^/socket\.io/1/websocket/[a-z0-9]+$"]
    )

    application.listen(port_number, bind_address)
예제 #3
0
def start_warrior_server(warrior,
                         bind_address="",
                         port_number=8001,
                         http_username=None,
                         http_password=None):
    SeesawConnection.warrior = warrior

    warrior.on_projects_loaded += SeesawConnection.handle_projects_loaded
    warrior.on_project_refresh += SeesawConnection.handle_project_refresh
    warrior.on_project_installing += SeesawConnection.handle_project_installing
    warrior.on_project_installed += SeesawConnection.handle_project_installed
    warrior.on_project_installation_failed += SeesawConnection.handle_project_installation_failed
    warrior.on_project_selected += SeesawConnection.handle_project_selected
    warrior.on_status += SeesawConnection.handle_warrior_status
    warrior.runner.on_pipeline_start_item += SeesawConnection.handle_start_item
    warrior.runner.on_pipeline_finish_item += SeesawConnection.handle_finish_item
    warrior.runner.on_status += SeesawConnection.handle_runner_status

    if not http_username:
        http_username = warrior.http_username
    if not http_password:
        http_password = warrior.http_password

    ioloop.PeriodicCallback(SeesawConnection.broadcast_bandwidth, 1000).start()

    router = TornadioRouter(SeesawConnection)

    application = AuthenticatedApplication(
      router.apply_routes([(r"/(.*\.(html|css|js|swf|png|ico))$",
                            web.StaticFileHandler, {"path": PUBLIC_PATH}),
                           ("/", IndexHandler),
                           ("/api/(.+)$", ApiHandler, {"warrior": warrior})]),
        #   flash_policy_port = 843,
        #   flash_policy_file = os.path.join(PUBLIC_PATH, "flashpolicy.xml"),
      socket_io_address = bind_address,
      socket_io_port = port_number,

      # settings for AuthenticatedApplication
      auth_enabled = lambda: (realize(http_password) or "").strip() != "",
      check_auth = lambda r, username, password: \
          (
            password==realize(http_password) and \
            (realize(http_username) or "").strip() in ["", username]
          ),
      auth_realm = "ArchiveTeam Warrior",
      skip_auth = [ r"^/socket\.io/1/websocket/[a-z0-9]+$" ]
    )
    SocketServer(application, auto_start=False)
예제 #4
0
def start_runner_server(project,
                        runner,
                        bind_address="",
                        port_number=8001,
                        http_username=None,
                        http_password=None):
    if bind_address == "0.0.0.0":
        bind_address = ""

    SeesawConnection.project = project
    SeesawConnection.runner = runner

    runner.on_pipeline_start_item += SeesawConnection.handle_start_item
    runner.on_pipeline_finish_item += SeesawConnection.handle_finish_item
    runner.on_status += SeesawConnection.handle_runner_status

    router = TornadioRouter(SeesawConnection)

    application = AuthenticatedApplication(
      router.apply_routes([(r"/(.*\.(html|css|js|swf|png|ico))$",
                            web.StaticFileHandler, {"path": PUBLIC_PATH}),
                           ("/", IndexHandler),
                           ("/api/(.+)$", ApiHandler, {"runner": runner})]),
        #   flash_policy_port = 843,
        #   flash_policy_file = os.path.join(PUBLIC_PATH, "flashpolicy.xml"),
      socket_io_address = bind_address,
      socket_io_port = port_number,

      # settings for AuthenticatedApplication
      auth_enabled = (http_password or "").strip() != "",
      check_auth = lambda r, username, password: \
          (
            password==http_password and \
            (http_username or "").strip() in ["", username]
          ),
      auth_realm = "ArchiveTeam Warrior",
      skip_auth = [ r"^/socket\.io/1/websocket/[a-z0-9]+$" ]
    )

    SocketServer(application, auto_start=False)