forked from skylines-project/skylines
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
manage.py: Moved code into commands package
- Loading branch information
Showing
2 changed files
with
30 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,6 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
from flask import current_app | ||
from flask.ext.script import Manager, Shell | ||
|
||
from skylines.app import create_app | ||
from skylines import model | ||
from skylines.commands import ( | ||
tracking_manager, celery_manager, ImportSRTM, Server | ||
) | ||
from config import to_envvar | ||
|
||
|
||
def _create_app(config): | ||
if not to_envvar(config): | ||
print 'Config file "{}" not found.'.format(config) | ||
sys.exit(1) | ||
|
||
return create_app() | ||
|
||
|
||
def _make_context(): | ||
return dict(app=current_app, model=model, db=model.db) | ||
|
||
|
||
manager = Manager(_create_app) | ||
manager.add_option('-c', '--config', dest='config', required=False) | ||
manager.add_command("shell", Shell(make_context=_make_context)) | ||
manager.add_command("runserver", Server()) | ||
manager.add_command("tracking", tracking_manager) | ||
manager.add_command("celery", celery_manager) | ||
manager.add_command("import-srtm", ImportSRTM()) | ||
from skylines.commands import manager | ||
|
||
if __name__ == "__main__": | ||
manager.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,34 @@ | ||
# flake8: noqa | ||
import sys | ||
|
||
from flask import current_app | ||
from flask.ext.script import Manager, Shell | ||
|
||
from .celery import manager as celery_manager | ||
from .tracking import manager as tracking_manager | ||
from .import_srtm import ImportSRTM | ||
from .server import Server | ||
|
||
from skylines.app import create_app | ||
from skylines import model | ||
from config import to_envvar | ||
|
||
|
||
def _create_app(config): | ||
if not to_envvar(config): | ||
print 'Config file "{}" not found.'.format(config) | ||
sys.exit(1) | ||
|
||
return create_app() | ||
|
||
|
||
def _make_context(): | ||
return dict(app=current_app, model=model, db=model.db) | ||
|
||
|
||
manager = Manager(_create_app) | ||
manager.add_option('-c', '--config', dest='config', required=False) | ||
manager.add_command("shell", Shell(make_context=_make_context)) | ||
manager.add_command("runserver", Server()) | ||
manager.add_command("tracking", tracking_manager) | ||
manager.add_command("celery", celery_manager) | ||
manager.add_command("import-srtm", ImportSRTM()) |