blob: 840d6621b423dfa1b38d926f2fd493e06c86b2b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import os
import os.path
import crochet
from flask import Flask
from pixelated.config import app_factory
import pixelated.config.args as input_args
import pixelated.bitmask_libraries.register as leap_register
import pixelated.config.reactor_manager as reactor_manager
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()
app.config.from_pyfile(args.config)
if args.register:
server_name = app.config['LEAP_SERVER_NAME']
leap_register.register_new_user(args.register, server_name)
else:
app_factory.create_app(debug_enabled, app)
finally:
reactor_manager.stop_reactor_on_exit()
if __name__ == '__main__':
setup()
|