def get_env(self): """Returns an environment object based on the config.""" if self.config.env: return env.Env(self.config.env) host = '{}-dot-{}'.format(self.config.subdomain, self.config.server) config = env.EnvConfig(name='webreview', host=host, scheme='https') return env.Env(config)
def run(host, port, https, debug, browser, update_check, preprocess, ui, pod_path, deployment): """Starts a development server for a single pod.""" root = os.path.abspath(os.path.join(os.getcwd(), pod_path)) scheme = 'https' if https else 'http' config = env.EnvConfig(host=host, port=port, name=env.Name.DEV, scheme=scheme, cached=False, dev=True) environment = env.Env(config) pod = pods.Pod(root, storage=storage.FileStorage, env=environment) if deployment: deployment_obj = pod.get_deployment(deployment) pod.set_env(deployment_obj.config.env) if not ui: pod.disable(pod.FEATURE_UI) try: manager.start(pod, host=host, port=port, open_browser=browser, debug=debug, preprocess=preprocess, update_check=update_check) except pods.Error as e: raise click.ClickException(str(e)) return pod
def run(host, port, debug, browser, skip_sdk_update_check, pod_path): """Starts a development server for a single pod.""" if not skip_sdk_update_check: thread = threading.Thread(target=sdk_utils.check_version, args=(True, )) thread.start() root = os.path.abspath(os.path.join(os.getcwd(), pod_path)) environment = env.Env(env.EnvConfig(host=host, port=port, name='dev')) pod = pods.Pod(root, storage=storage.FileStorage, env=environment) try: manager.start(pod, host=host, port=port, open_browser=browser, debug=debug) except pods.Error as e: raise click.ClickException(str(e))
def get_env(self): """Returns an environment object based on the config.""" if self.config.env: return env.Env(self.config.env) config = env.EnvConfig(host='localhost') return env.Env(config)
def test_constructor_basic(self): config = env.EnvConfig(host='localhost') environment = env.Env(config) self.assertEqual('localhost', environment.host) self.assertEqual(None, environment.scheme) self.assertEqual(None, environment.port)
def test_fingerprint(self): # May be used as {{env.fingerprint}} in templates. config = env.EnvConfig(host='localhost', scheme='http', port=8080) environment = env.Env(config) self.assertTrue(isinstance(environment.fingerprint, str))
def test_url_port_custom(self): config = env.EnvConfig(host='localhost', scheme='http', port=8080) environment = env.Env(config) self.assertEqual('http://localhost:8080/', str(environment.url))
def test_url_port_443_mismatch(self): config = env.EnvConfig(host='localhost', scheme='http', port=443) environment = env.Env(config) self.assertEqual('http://localhost:443/', str(environment.url))
def test_url_port_80_mismatch(self): config = env.EnvConfig(host='localhost', scheme='https', port=80) environment = env.Env(config) self.assertEqual('https://localhost:80/', str(environment.url))
def test_url_host(self): config = env.EnvConfig(host='remotehost') environment = env.Env(config) self.assertEqual('http://remotehost/', str(environment.url))
def test_constructor_full(self): config = env.EnvConfig(host='remotehost', scheme='https', port=443) environment = env.Env(config) self.assertEqual('remotehost', environment.host) self.assertEqual('https', environment.scheme) self.assertEqual(443, environment.port)
def test_url_port_443(self): config = env.EnvConfig(host='localhost', scheme='https', port=443) environment = env.Env(config) self.assertEqual('https://localhost/', environment.url)