Skip to content

Commit

Permalink
change HTTP_PORT -> PORT
Browse files Browse the repository at this point in the history
  • Loading branch information
cfhamlet committed Mar 13, 2018
1 parent 4b1e8ab commit b3f25b8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/os_tornado/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.7
0.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
10 changes: 5 additions & 5 deletions src/os_tornado/commands/runserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/os_tornado/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/os_tornado/settings/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
6 changes: 3 additions & 3 deletions tests/test_commands/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
2 changes: 1 addition & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b3f25b8

Please sign in to comment.