From b3f25b82e6078ebf22282365fc1abb6f80c9680c Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Mar 2018 11:33:51 +0800 Subject: [PATCH] change HTTP_PORT -> PORT --- src/os_tornado/VERSION | 2 +- .../commands/project_template/app/settings.py.tpl | 2 +- src/os_tornado/commands/runserver.py | 10 +++++----- src/os_tornado/runner.py | 8 ++++---- src/os_tornado/settings/default_settings.py | 2 +- tests/test_commands/test_cmd.py | 6 +++--- tests/test_settings.py | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/os_tornado/VERSION b/src/os_tornado/VERSION index 1180819..0ea3a94 100644 --- a/src/os_tornado/VERSION +++ b/src/os_tornado/VERSION @@ -1 +1 @@ -0.1.7 +0.2.0 diff --git a/src/os_tornado/commands/project_template/app/settings.py.tpl b/src/os_tornado/commands/project_template/app/settings.py.tpl index 54e19b8..d5a30ff 100644 --- a/src/os_tornado/commands/project_template/app/settings.py.tpl +++ b/src/os_tornado/commands/project_template/app/settings.py.tpl @@ -3,7 +3,7 @@ TORNADO_APP_SETTINGS_COOKIE_SECRET = "__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__" LOG_LEVEL = "DEBUG" -HTTP_PORT = 8080 +PORT = 8080 EXTENSIONS = [ { diff --git a/src/os_tornado/commands/runserver.py b/src/os_tornado/commands/runserver.py index 260b9ec..56df743 100644 --- a/src/os_tornado/commands/runserver.py +++ b/src/os_tornado/commands/runserver.py @@ -13,14 +13,14 @@ def short_desc(self): def add_options(self, parser): super(RunserverCommand, self).add_options(parser) - default_port = self.settings["HTTP_PORT"] - parser.add_option("-p", "--port", action="store", dest="http_port", - type=int, help="set http port (default: %s)" % str(default_port)) + default_port = self.settings["PORT"] + parser.add_option("-p", "--port", action="store", dest="port", + type=int, help="set listen port (default: %s)" % str(default_port)) def process_options(self, args, opts): super(RunserverCommand, self).process_options(args, opts) - if opts.http_port: - self.settings["HTTP_PORT"] = opts.http_port + if opts.port: + self.settings["PORT"] = opts.port def run(self, args, opts): manager = ComponentManager(self.settings) diff --git a/src/os_tornado/runner.py b/src/os_tornado/runner.py index 9dab3bf..70a7a90 100644 --- a/src/os_tornado/runner.py +++ b/src/os_tornado/runner.py @@ -39,7 +39,7 @@ def run(self): self._logger.info('[SETUP] extensions') self._manager.setup_extensions() - if self.settings["HTTP_PORT"]: + if self.settings["PORT"]: self._logger.info('[LOAD] request handlers') self._manager.load_request_handlers() app = tornado.web.Application( @@ -48,14 +48,14 @@ def run(self): transforms=None, **get_tornado_app_settings(self.settings)) app.manager = self._manager - port = self.settings.get_int("HTTP_PORT") + port = self.settings.get_int("PORT") bind_address = self.settings.get('BIND_ADDRESS', '') server_settings = get_tornado_server_settings(self.settings) app.listen(port, bind_address, **server_settings) self._logger.info('listen port %d', port) else: - self._logger.warn('no http interface, HTTP_PORT: %s', - str(self.settings['HTTP_PORT'])) + self._logger.warn('no http interface, PORT: %s', + str(self.settings['PORT'])) self._logger.info('[RUN] extensions') self._manager.run_extensions() diff --git a/src/os_tornado/settings/default_settings.py b/src/os_tornado/settings/default_settings.py index 5599820..b1d56eb 100644 --- a/src/os_tornado/settings/default_settings.py +++ b/src/os_tornado/settings/default_settings.py @@ -7,6 +7,6 @@ LOG_FORMAT = '[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s' LOG_DATEFORMAT = '%Y-%m-%d %H:%M:%S' -HTTP_PORT = 8080 +PORT = 8080 BIND_ADDRESS = '' DEFAULT_HOST = '' diff --git a/tests/test_commands/test_cmd.py b/tests/test_commands/test_cmd.py index af0a6f6..f7135f5 100644 --- a/tests/test_commands/test_cmd.py +++ b/tests/test_commands/test_cmd.py @@ -53,7 +53,7 @@ def test_cmdline(): assert cmd in result -@pytest.mark.skip(reason="tornado do not support get_unused_port") +@pytest.mark.skip(reason="tornado do not support get_unused_port anymore") def test_runserver(): port = tornado.testing.get_unused_port() env = os.environ.copy() @@ -70,10 +70,10 @@ def test_runserver(): assert 'STOP SUCC' in stdout port = tornado.testing.get_unused_port() - stdout, stderr = run('runserver -s HTTP_PORT=%d' % port, env=env) + stdout, stderr = run('runserver -s PORT=%d' % port, env=env) assert 'listen port %d' % port in stderr port1 = tornado.testing.get_unused_port() - stdout, stderr = run('runserver -s HTTP_PORT=%d -p %d' % + stdout, stderr = run('runserver -s PORT=%d -p %d' % (port, port1), env=env) assert 'listen port %d' % port1 in stderr diff --git a/tests/test_settings.py b/tests/test_settings.py index 6309869..28eab2d 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -22,7 +22,7 @@ def test_iter_overridden_settings(settings): for key, value in iter_overridden_settings(settings): count += 1 assert count == 0 - settings["HTTP_PORT"] = 8000 + settings["PORT"] = 8000 settings["LOG_ENABLE"] = True count = 0 for key, value in iter_overridden_settings(settings):