summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorBruno Wagner <bwagner@thoughtworks.com>2014-10-23 11:55:20 +0200
committerBruno Wagner <bwagner@thoughtworks.com>2014-10-23 11:55:53 +0200
commitf43b9625e4bf04a4c03a8949c930d623eced02bd (patch)
tree9d91a3e09fdf7faf48c5b7e04aea0a1f66101022 /service
parent0cca315106906e87ee7694fa860517ca8f248802 (diff)
Removed crochet, and streamlined the reactor shutdown so we shouldn't see errors on user agent start/exit anymore
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/runserver.py41
-rw-r--r--service/setup.py1
-rw-r--r--service/test/unit/runserver_test.py2
3 files changed, 19 insertions, 25 deletions
diff --git a/service/pixelated/runserver.py b/service/pixelated/runserver.py
index 68eaa840..ebcdc622 100644
--- a/service/pixelated/runserver.py
+++ b/service/pixelated/runserver.py
@@ -25,17 +25,15 @@ import pixelated.config.credentials_prompt as credentials_prompt
import pixelated.bitmask_libraries.register as leap_register
import pixelated.config.reactor_manager as reactor_manager
import pixelated.support.ext_protobuf # monkey patch for protobuf in OSX
+from twisted.internet import error
app = Flask(__name__, static_url_path='', static_folder=app_factory.get_static_folder())
def setup():
- try:
- args = input_args.parse()
- debug_enabled = args.debug or os.environ.get('DEBUG', False)
- reactor_manager.start_reactor(logging=debug_enabled)
- crochet.setup()
+ args = input_args.parse()
+ app.config.update({'HOST': args.host, 'PORT': args.port})
debug_enabled = args.debug or os.environ.get('DEBUG', False)
if(not debug_enabled):
@@ -43,26 +41,25 @@ def setup():
logger = logging.getLogger('werkzeug')
logger.setLevel(logging.INFO)
- app.config.update({'HOST': args.host, 'PORT': args.port})
+ reactor_manager.start_reactor(logging=debug_enabled)
+ events_server.ensure_server(port=8090)
- if args.register:
- server_name, username = args.register
- leap_register.register_new_user(username, server_name)
+ if args.register:
+ server_name, username = args.register
+ leap_register.register_new_user(username, server_name)
+ else:
+ if args.dispatcher:
+ raise Exception('Dispatcher mode not implemented yet')
+ elif args.config is not None:
+ config_file = os.path.abspath(os.path.expanduser(args.config))
+ app.config.from_pyfile(config_file)
else:
- if args.dispatcher:
- raise Exception('Dispatcher mode not implemented yet')
- elif args.config is not None:
- config_file = os.path.abspath(os.path.expanduser(args.config))
- app.config.from_pyfile(config_file)
- else:
- provider, user, password = credentials_prompt.run()
- app.config['LEAP_SERVER_NAME'] = provider
- app.config['LEAP_USERNAME'] = user
- app.config['LEAP_PASSWORD'] = password
+ provider, user, password = credentials_prompt.run()
+ app.config['LEAP_SERVER_NAME'] = provider
+ app.config['LEAP_USERNAME'] = user
+ app.config['LEAP_PASSWORD'] = password
- app_factory.create_app(debug_enabled, app)
- finally:
- reactor_manager.stop_reactor_on_exit()
+ app_factory.create_app(debug_enabled, app)
if __name__ == '__main__':
diff --git a/service/setup.py b/service/setup.py
index 3233b266..50c98efe 100644
--- a/service/setup.py
+++ b/service/setup.py
@@ -88,7 +88,6 @@ setup(name='pixelated-user-agent',
'leap.mail==0.3.9-1-gc1f9c92',
'whoosh==2.6.0',
'gunicorn==19.1.1',
- 'crochet==1.3.0'
],
entry_points={
'console_scripts': [
diff --git a/service/test/unit/runserver_test.py b/service/test/unit/runserver_test.py
index 18621ce7..eed21a6c 100644
--- a/service/test/unit/runserver_test.py
+++ b/service/test/unit/runserver_test.py
@@ -19,7 +19,6 @@ import sys
import pixelated.runserver
from mockito import *
-import crochet
import pixelated.config.reactor_manager as reactor_manager
import pixelated.adapter.mail
import os
@@ -31,7 +30,6 @@ class RunserverTest(unittest.TestCase):
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(dict)