예제 #1
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)
예제 #2
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)