Permalink
Browse files

Move CLI logic into redash.cli and uses manager for tests.

Otherwise the Flask wasn't created and tests were failing.
  • Loading branch information...
1 parent b9024b1 commit a84c3e25f5a044b5bb3ef581f0a218d678e2af82 @arikfr arikfr committed Dec 7, 2016
Showing with 119 additions and 129 deletions.
  1. +1 −68 manage.py
  2. +63 −0 redash/cli/__init__.py
  3. +55 −61 tests/test_cli.py
View
@@ -2,75 +2,8 @@
"""
CLI to manage redash.
"""
-import json
-
-
-import click
-from flask.cli import FlaskGroup, run_command
-
-from redash import create_app, settings, __version__
-from redash.cli import users, groups, database, data_sources, organization
-from redash.monitor import get_status
-
-
-def create(group):
- app = create_app()
- group.app = app
- return app
-
-
-@click.group(cls=FlaskGroup, create_app=create)
-def manager():
- "Management script for redash"
-
-
-manager.add_command(database.manager, "database")
-manager.add_command(users.manager, "users")
-manager.add_command(groups.manager, "groups")
-manager.add_command(data_sources.manager, "ds")
-manager.add_command(organization.manager, "org")
-manager.add_command(run_command, "runserver")
-
-
-@manager.command()
-def version():
- """Displays re:dash version."""
- print __version__
-
-
-@manager.command()
-def status():
- print json.dumps(get_status(), indent=2)
-
-
-@manager.command()
-def runworkers():
- """Start workers (deprecated)."""
- print "** This command is deprecated. Please use Celery's CLI to control the workers. **"
-
-
-@manager.command()
-def check_settings():
- """Show the settings as re:dash sees them (useful for debugging)."""
- for name, item in settings.all_settings().iteritems():
- print "{} = {}".format(name, item)
-
-
-@manager.command()
-@click.argument('email', default=settings.MAIL_DEFAULT_SENDER, required=False)
-def send_test_mail(email=None):
- """
- Send test message to EMAIL (default: the address you defined in MAIL_DEFAULT_SENDER)
- """
- from redash import mail
- from flask_mail import Message
-
- if email is None:
- email = settings.MAIL_DEFAULT_SENDER
-
- mail.send(Message(subject="Test Message from re:dash", recipients=[email],
- body="Test message."))
+from redash.cli import manager
if __name__ == '__main__':
manager()
@@ -0,0 +1,63 @@
+import json
+
+
+import click
+from flask.cli import FlaskGroup, run_command
+
+from redash import create_app, settings, __version__
+from redash.cli import users, groups, database, data_sources, organization
+from redash.monitor import get_status
+
+
+def create(group):
+ app = create_app()
+ group.app = app
+ return app
+
+
+@click.group(cls=FlaskGroup, create_app=create)
+def manager():
+ """Management script for Redash"""
+
+
+manager.add_command(database.manager, "database")
+manager.add_command(users.manager, "users")
+manager.add_command(groups.manager, "groups")
+manager.add_command(data_sources.manager, "ds")
+manager.add_command(organization.manager, "org")
+manager.add_command(run_command, "runserver")
+
+
+@manager.command()
+def version():
+ """Displays Redash version."""
+ print __version__
+
+
+@manager.command()
+def status():
+ print json.dumps(get_status(), indent=2)
+
+
+@manager.command()
+def check_settings():
+ """Show the settings as Redash sees them (useful for debugging)."""
+ for name, item in settings.all_settings().iteritems():
+ print "{} = {}".format(name, item)
+
+
+@manager.command()
+@click.argument('email', default=settings.MAIL_DEFAULT_SENDER, required=False)
+def send_test_mail(email=None):
+ """
+ Send test message to EMAIL (default: the address you defined in MAIL_DEFAULT_SENDER)
+ """
+ from redash import mail
+ from flask_mail import Message
+
+ if email is None:
+ email = settings.MAIL_DEFAULT_SENDER
+
+ mail.send(Message(subject="Test Message from Redash", recipients=[email],
+ body="Test message."))
+
Oops, something went wrong.

0 comments on commit a84c3e2

Please sign in to comment.