From a2e4f6e4816d4f0d92888b577b76153cf8c65e19 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Wed, 22 Oct 2014 18:26:25 +0200 Subject: Host and port are now user agent switches, not depending on .pixelated file anymore --- service/pixelated/config/args.py | 10 +++++----- service/pixelated/runserver.py | 2 +- service/test/unit/runserver_test.py | 18 ++---------------- 3 files changed, 8 insertions(+), 22 deletions(-) (limited to 'service') diff --git a/service/pixelated/config/args.py b/service/pixelated/config/args.py index 0e830e0a..93453075 100644 --- a/service/pixelated/config/args.py +++ b/service/pixelated/config/args.py @@ -20,12 +20,12 @@ import os def parse(): - default_config_path = os.path.join(os.environ['HOME'], '.pixelated') parser = argparse.ArgumentParser(description='Pixelated user agent.') - parser.add_argument('--debug', action='store_true', - help='DEBUG mode.') + parser.add_argument('--debug', action='store_true', help='DEBUG mode.') + parser.add_argument('--dispatcher', action='store_true', help='run in organization mode, the credentials will be received from the dispatcher this way') parser.add_argument('--register', metavar='username', help='register user with name.') - parser.add_argument('-c', '--config', metavar='configfile', default=default_config_path, - help='use specified config file. Default is ~/.pixelated.') + parser.add_argument('--host', default='127.0.0.1', help='the host to run the user agent on') + parser.add_argument('--port', type=int, default=3333, help='the port to run the user agent on') + parser.add_argument('-c', '--config', metavar='configfile', default=None, help='use specified file for credentials (for test purposes only)') args = parser.parse_args() return args diff --git a/service/pixelated/runserver.py b/service/pixelated/runserver.py index 995796df..92266dba 100644 --- a/service/pixelated/runserver.py +++ b/service/pixelated/runserver.py @@ -43,7 +43,7 @@ def setup(): events_server.ensure_server(port=8090) - app.config.from_pyfile(args.config) + app.config.update({'HOST': args.host, 'PORT': args.port}) if args.register: server_name = app.config['LEAP_SERVER_NAME'] diff --git a/service/test/unit/runserver_test.py b/service/test/unit/runserver_test.py index 1e735bf7..18621ce7 100644 --- a/service/test/unit/runserver_test.py +++ b/service/test/unit/runserver_test.py @@ -28,28 +28,14 @@ import pixelated.config.app_factory as app_factory class RunserverTest(unittest.TestCase): - def test_that_default_config_file_is_home_dot_pixelated(self): - orig_config = pixelated.runserver.app.config - try: - when(crochet).setup().thenReturn(None) - when(reactor_manager).start_reactor().thenReturn(None) - when(app_factory).create_app().thenReturn(None) - pixelated.runserver.app.config = mock() - - sys.argv = ['/tmp/does_not_exist'] - pixelated.runserver.setup() - - verify(pixelated.runserver.app.config).from_pyfile(os.path.join(os.environ['HOME'], '.pixelated')) - finally: - pixelated.runserver.app.config = orig_config - def test_that_config_file_can_be_specified_on_command_line(self): orig_config = pixelated.runserver.app.config try: when(crochet).setup().thenReturn(None) when(reactor_manager).start_reactor().thenReturn(None) when(app_factory).create_app().thenReturn(None) - pixelated.runserver.app.config = mock() + pixelated.runserver.app.config = mock(dict) + pixelated.runserver.app.config.__setitem__ = mock() sys.argv = ['/tmp/does_not_exist', '--config', '/tmp/some/config/file'] pixelated.runserver.setup() -- cgit v1.2.3