Example #1
0
    def __enter__(self):
        self.stash.__enter__()
        self.ssl_env.__enter__()
        self.cache_manager.__enter__()

        self.config = self.load_config()
        self.setup_server_logging()
        ports = serve.get_ports(self.config, self.ssl_env)
        self.config = serve.normalise_config(self.config, ports)

        assert self.env_extras_cms is None, (
            "A TestEnvironment object cannot be nested")

        self.env_extras_cms = []

        for env in self.env_extras:
            cm = env(self.options, self.config)
            cm.__enter__()
            self.env_extras_cms.append(cm)

        self.servers = serve.start(self.config, self.ssl_env,
                                   self.get_routes())
        if self.options.get("supports_debugger") and self.debug_info and self.debug_info.interactive:
            self.ignore_interrupts()
        return self
    def __enter__(self):
        self.stash.__enter__()
        self.ssl_env.__enter__()
        self.cache_manager.__enter__()

        self.config = self.load_config()
        self.setup_server_logging()
        ports = serve.get_ports(self.config, self.ssl_env)
        self.config = serve.normalise_config(self.config, ports)

        assert self.env_extras_cms is None, (
            "A TestEnvironment object cannot be nested")

        self.env_extras_cms = []

        for env in self.env_extras:
            cm = env(self.options, self.config)
            cm.__enter__()
            self.env_extras_cms.append(cm)

        self.servers = serve.start(self.config, self.ssl_env,
                                   self.get_routes())
        if self.options.get("supports_debugger") and self.debug_info and self.debug_info.interactive:
            self.ignore_interrupts()
        return self
Example #3
0
def main(argv, stdout, stderr):
    # This is a copy of serve.py main function, except for the wait step
    config = WebPlatformTestServer.load_config("config.default.json",
                                               "config.json")
    WebPlatformTestServer.setup_logger(config["log_level"])
    logged_servers = []

    with stash.StashServer(
        (config["browser_host"], WebPlatformTestServer.get_port()),
            authkey=str(uuid.uuid4())):
        with WebPlatformTestServer.get_ssl_environment(config) as ssl_env:
            ports = WebPlatformTestServer.get_ports(config, ssl_env)
            config_ = WebPlatformTestServer.normalise_config(config, ports)
            started_servers = WebPlatformTestServer.start(
                config_, ssl_env, build_routes(config["aliases"]))

            for protocol, servers in started_servers.items():
                for port, process in servers:
                    logged_servers.append({
                        "protocol": protocol,
                        "port": port,
                        "pid": process.proc.pid
                    })
                    logger.info("%s, port:%d, pid:%d" %
                                (protocol, port, process.proc.pid))

            # Write pids in a file in case abrupt shutdown is needed
            with open(argv[0], "wb") as servers_file:
                json.dump(logged_servers, servers_file)

            sys.stdin.read(1)
Example #4
0
 def __enter__(self):
     self.stash.__enter__()
     self.ssl_env.__enter__()
     self.cache_manager.__enter__()
     for cm in self.env_extras:
         cm.__enter__(self.options)
     self.setup_server_logging()
     self.config = self.load_config()
     ports = serve.get_ports(self.config, self.ssl_env)
     self.config = serve.normalise_config(self.config, ports)
     self.servers = serve.start(self.config, self.ssl_env,
                                self.get_routes())
     if self.options.get("supports_debugger") and self.debug_info and self.debug_info.interactive:
         self.ignore_interrupts()
     return self
Example #5
0
 def __enter__(self):
     self.stash.__enter__()
     self.ssl_env.__enter__()
     self.cache_manager.__enter__()
     for cm in self.env_extras:
         cm.__enter__(self.options)
     self.setup_server_logging()
     self.config = self.load_config()
     ports = serve.get_ports(self.config, self.ssl_env)
     self.config = serve.normalise_config(self.config, ports)
     self.servers = serve.start(self.config, self.ssl_env,
                                self.get_routes())
     if self.options.get(
             "supports_debugger"
     ) and self.debug_info and self.debug_info.interactive:
         self.ignore_interrupts()
     return self