redash/manage.py

50 lines
1.2 KiB
Python
Raw Normal View History

2014-01-17 09:36:44 +00:00
#!/usr/bin/env python
2013-10-27 16:15:35 +00:00
"""
2014-01-17 09:14:15 +00:00
CLI to manage redash.
2013-10-27 16:15:35 +00:00
"""
from flask.ext.script import Manager
2013-10-25 07:26:07 +00:00
from redash import settings, models, __version__
from redash.wsgi import app
from redash.import_export import import_manager
from redash.cli import users, database, data_sources
2014-02-09 15:09:07 +00:00
manager = Manager(app)
manager.add_command("database", database.manager)
manager.add_command("users", users.manager)
manager.add_command("import", import_manager)
manager.add_command("ds", data_sources.manager)
2014-02-09 15:09:07 +00:00
@manager.command
def version():
"""Displays re:dash version."""
print __version__
2014-02-09 15:09:07 +00:00
@manager.command
def runworkers():
"""Start workers (deprecated)."""
2014-05-16 14:57:43 +00:00
print "** This command is deprecated. Please use Celery's CLI to control the workers. **"
2013-10-25 07:26:07 +00:00
2014-02-09 15:09:07 +00:00
@manager.shell
def make_shell_context():
from redash.models import db
2014-02-09 15:09:07 +00:00
return dict(app=app, db=db, models=models)
2013-10-25 07:26:07 +00:00
@manager.command
def check_settings():
"""Show the settings as re:dash sees them (useful for debugging)."""
from types import ModuleType
for name in dir(settings):
item = getattr(settings, name)
if not callable(item) and not name.startswith("__") and not isinstance(item, ModuleType):
print "{} = {}".format(name, item)
2014-04-19 14:06:47 +00:00
2013-10-25 07:26:07 +00:00
if __name__ == '__main__':
manager.run()