annotate wikked/commands/web.py @ 315:e07eee5e101a

Consistent Flask config variables. Set that config before creating the app.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 08 Oct 2014 23:22:44 -0700
parents 6bd9d44fc535
children 566d229d1b30
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
175
a971deb123d7 Fixed missing import.
Ludovic Chabant <ludovic@chabant.com>
parents: 174
diff changeset
1 import os
243
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
2 import os.path
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
3 import imp
168
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4 import logging
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 from wikked.commands.base import WikkedCommand, register_command
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 logger = logging.getLogger(__name__)
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10
303
6bd9d44fc535 Wiki updater cleanup and improvements.
Ludovic Chabant <ludovic@chabant.com>
parents: 291
diff changeset
11 def autoreload_wiki_updater(wiki, url):
6bd9d44fc535 Wiki updater cleanup and improvements.
Ludovic Chabant <ludovic@chabant.com>
parents: 291
diff changeset
12 wiki.db.uncachePages(except_url=url, only_required=True)
6bd9d44fc535 Wiki updater cleanup and improvements.
Ludovic Chabant <ludovic@chabant.com>
parents: 291
diff changeset
13
6bd9d44fc535 Wiki updater cleanup and improvements.
Ludovic Chabant <ludovic@chabant.com>
parents: 291
diff changeset
14
168
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15 @register_command
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 class RunServerCommand(WikkedCommand):
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 def __init__(self):
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 super(RunServerCommand, self).__init__()
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 self.name = 'runserver'
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20 self.description = ("Runs the wiki in a local web server.")
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22 def setupParser(self, parser):
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 parser.add_argument('--host',
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 help="The host to use",
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25 default='127.0.0.1')
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
26 parser.add_argument('--port',
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
27 help="The port to use",
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
28 default=5000)
243
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
29 parser.add_argument('--usetasks',
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
30 help="Use background tasks for updating the wiki after a "
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
31 "page has been edited. You will have to run "
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
32 "`wk runtasks` at the same time as `wk runserver`.",
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
33 action='store_true')
208
1e3275ff5dfc Make `--debug` only for debug logging. Use `--dev` for using dev assets.
Ludovic Chabant <ludovic@chabant.com>
parents: 177
diff changeset
34 parser.add_argument('-d', '--dev',
222
31ac8bd02ddd Still tweaking the arguments to the damn `wk runserver` command.
Ludovic Chabant <ludovic@chabant.com>
parents: 208
diff changeset
35 help="Use development mode. "
31ac8bd02ddd Still tweaking the arguments to the damn `wk runserver` command.
Ludovic Chabant <ludovic@chabant.com>
parents: 208
diff changeset
36 "This makes Wikked use development assets (separate and "
31ac8bd02ddd Still tweaking the arguments to the damn `wk runserver` command.
Ludovic Chabant <ludovic@chabant.com>
parents: 208
diff changeset
37 "uncompressed scripts and stylesheets), along with using "
31ac8bd02ddd Still tweaking the arguments to the damn `wk runserver` command.
Ludovic Chabant <ludovic@chabant.com>
parents: 208
diff changeset
38 "code reloading and debugging.",
208
1e3275ff5dfc Make `--debug` only for debug logging. Use `--dev` for using dev assets.
Ludovic Chabant <ludovic@chabant.com>
parents: 177
diff changeset
39 action='store_true')
259
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
40 parser.add_argument('--noupdate',
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
41 help="Don't auto-update the wiki if a page file has been "
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
42 "touched (which means you can refresh a locally modified "
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
43 "page with F5)",
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
44 action='store_true')
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
45 parser.add_argument('-c', '--config',
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
46 help="Pass some configuration value to the Flask application. "
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
47 "This must be of the form: name=value",
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
48 nargs="*")
168
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
49
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
50 def run(self, ctx):
174
298b9f5ccdac Common code for fallback when Bcrypt is not available.
Ludovic Chabant <ludovic@chabant.com>
parents: 171
diff changeset
51 # Change working directory because the Flask app can currently
298b9f5ccdac Common code for fallback when Bcrypt is not available.
Ludovic Chabant <ludovic@chabant.com>
parents: 171
diff changeset
52 # only initialize itself relative to that...
298b9f5ccdac Common code for fallback when Bcrypt is not available.
Ludovic Chabant <ludovic@chabant.com>
parents: 171
diff changeset
53 # TODO: make the Flask initialization more clever.
298b9f5ccdac Common code for fallback when Bcrypt is not available.
Ludovic Chabant <ludovic@chabant.com>
parents: 171
diff changeset
54 os.chdir(ctx.params.root)
298b9f5ccdac Common code for fallback when Bcrypt is not available.
Ludovic Chabant <ludovic@chabant.com>
parents: 171
diff changeset
55
243
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
56 # Setup some settings that need to be set before the app is created.
259
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
57 import wikked.settings
243
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
58 if ctx.args.usetasks:
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
59 wikked.settings.WIKI_ASYNC_UPDATE = True
261
6f51757e7da1 Fix a crash when setting up the Flask app.
Ludovic Chabant <ludovic@chabant.com>
parents: 259
diff changeset
60 if ctx.args.config:
6f51757e7da1 Fix a crash when setting up the Flask app.
Ludovic Chabant <ludovic@chabant.com>
parents: 259
diff changeset
61 for cv in ctx.args.config:
6f51757e7da1 Fix a crash when setting up the Flask app.
Ludovic Chabant <ludovic@chabant.com>
parents: 259
diff changeset
62 cname, cval = cv.split('=')
6f51757e7da1 Fix a crash when setting up the Flask app.
Ludovic Chabant <ludovic@chabant.com>
parents: 259
diff changeset
63 if cval in ['true', 'True', 'TRUE']:
6f51757e7da1 Fix a crash when setting up the Flask app.
Ludovic Chabant <ludovic@chabant.com>
parents: 259
diff changeset
64 setattr(wikked.settings, cname, True)
6f51757e7da1 Fix a crash when setting up the Flask app.
Ludovic Chabant <ludovic@chabant.com>
parents: 259
diff changeset
65 else:
6f51757e7da1 Fix a crash when setting up the Flask app.
Ludovic Chabant <ludovic@chabant.com>
parents: 259
diff changeset
66 setattr(wikked.settings, cname, cval)
243
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
67
291
035c7a58e9aa Don't duplicate logging when running the server in command-line.
Ludovic Chabant <ludovic@chabant.com>
parents: 261
diff changeset
68 # Remove Flask's default logging handler. Since the app is under the
035c7a58e9aa Don't duplicate logging when running the server in command-line.
Ludovic Chabant <ludovic@chabant.com>
parents: 261
diff changeset
69 # overall Wikked package, logging is handled by the root logger
035c7a58e9aa Don't duplicate logging when running the server in command-line.
Ludovic Chabant <ludovic@chabant.com>
parents: 261
diff changeset
70 # already.
315
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
71 wikked.settings.WIKI_NO_FLASK_LOGGER = True
291
035c7a58e9aa Don't duplicate logging when running the server in command-line.
Ludovic Chabant <ludovic@chabant.com>
parents: 261
diff changeset
72
315
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
73 # When running from the command line, we only have one web server
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
74 # so make it also serve static files.
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
75 wikked.settings.WIKI_SERVE_FILES = True
208
1e3275ff5dfc Make `--debug` only for debug logging. Use `--dev` for using dev assets.
Ludovic Chabant <ludovic@chabant.com>
parents: 177
diff changeset
76 if ctx.args.dev:
315
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
77 wikked.settings.WIKI_DEV_ASSETS = True
259
c94a3b37f710 Add more options to `wk runserver`.
Ludovic Chabant <ludovic@chabant.com>
parents: 244
diff changeset
78 if not ctx.args.noupdate:
315
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
79 wikked.settings.WIKI_AUTO_RELOAD = True
303
6bd9d44fc535 Wiki updater cleanup and improvements.
Ludovic Chabant <ludovic@chabant.com>
parents: 291
diff changeset
80 ctx.params.wiki_updater = autoreload_wiki_updater
208
1e3275ff5dfc Make `--debug` only for debug logging. Use `--dev` for using dev assets.
Ludovic Chabant <ludovic@chabant.com>
parents: 177
diff changeset
81
315
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
82 # Create/import the app.
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
83 from wikked.web import app
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
84
303
6bd9d44fc535 Wiki updater cleanup and improvements.
Ludovic Chabant <ludovic@chabant.com>
parents: 291
diff changeset
85 app.wiki_params = ctx.params
315
e07eee5e101a Consistent Flask config variables. Set that config before creating the app.
Ludovic Chabant <ludovic@chabant.com>
parents: 303
diff changeset
86 if bool(app.config.get('WIKI_UPDATE_ON_START')):
239
0e87dc411fe9 Better way to manage updating the wiki.
Ludovic Chabant <ludovic@chabant.com>
parents: 222
diff changeset
87 ctx.wiki.updateAll()
168
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
88
208
1e3275ff5dfc Make `--debug` only for debug logging. Use `--dev` for using dev assets.
Ludovic Chabant <ludovic@chabant.com>
parents: 177
diff changeset
89 # Run!
222
31ac8bd02ddd Still tweaking the arguments to the damn `wk runserver` command.
Ludovic Chabant <ludovic@chabant.com>
parents: 208
diff changeset
90 debug_mode = ctx.args.dev or app.config.get('DEBUG', False)
168
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
91 app.run(
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
92 host=ctx.args.host,
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
93 port=ctx.args.port,
177
528778a7421f Less confusing debug vs. production difference.
Ludovic Chabant <ludovic@chabant.com>
parents: 175
diff changeset
94 debug=debug_mode,
528778a7421f Less confusing debug vs. production difference.
Ludovic Chabant <ludovic@chabant.com>
parents: 175
diff changeset
95 use_debugger=debug_mode,
528778a7421f Less confusing debug vs. production difference.
Ludovic Chabant <ludovic@chabant.com>
parents: 175
diff changeset
96 use_reloader=debug_mode)
168
a71822a4beed Refactoring to not better use Flask, only when needed:
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
97
243
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
98
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
99 @register_command
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
100 class RunTasksCommand(WikkedCommand):
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
101 def __init__(self):
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
102 super(RunTasksCommand, self).__init__()
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
103 self.name = 'runtasks'
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
104 self.description = "Runs the tasks to update the wiki in the background."
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
105
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
106 def setupParser(self, parser):
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
107 pass
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
108
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
109 def run(self, ctx):
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
110 # Import the Celery app and update its configuration with the same
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
111 # stuff as what the Flask app got.
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
112 from wikked.tasks import celery_app
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
113
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
114 celery_app.conf.update(BROKER_URL='sqla+sqlite:///%(root)s/.wiki/broker.db')
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
115 config_path = os.path.join(ctx.params.root, '.wiki', 'app.cfg')
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
116 if os.path.isfile(config_path):
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
117 obj = self._loadConfig(config_path)
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
118 celery_app.conf.update(obj.__dict__)
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
119 celery_app.conf.BROKER_URL = celery_app.conf.BROKER_URL % (
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
120 { 'root': ctx.params.root })
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
121
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
122 os.chdir(os.path.join(os.path.dirname(__file__), '..', '..'))
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
123 argv = ['celery', 'worker', '-A', 'wikked.tasks']
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
124 if ctx.args.debug:
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
125 argv += ['-l', 'DEBUG']
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
126 celery_app.start(argv)
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
127
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
128 def _loadConfig(self, path):
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
129 d = imp.new_module('config')
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
130 d.__file__ = path
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
131 try:
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
132 with open(path) as config_file:
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
133 exec(compile(config_file.read(), path, 'exec'), d.__dict__)
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
134 except IOError as e:
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
135 e.strerror = 'Unable to load Flask/Celery configuration file (%s)' % e.strerror
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
136 raise
c6ec6096bd95 Simpler out-of-the-box support for background updates.
Ludovic Chabant <ludovic@chabant.com>
parents: 240
diff changeset
137 return d