Mikhail Korobov avatar Mikhail Korobov committed fe66bf6

Check is django management commands are available. Fix #9.

Comments (0)

Files changed (2)

fab_deploy/__init__.py

 from fab_deploy.deploy import *
 from fab_deploy.virtualenv import pip, pip_install, pip_update
-from fab_deploy.django_commands import migrate, manage, syncdb, compress, test, coverage
+from fab_deploy.django_commands import migrate, manage, syncdb, compress, test, coverage, command_is_available
 from fab_deploy.utils import run_as, update_env, inside_project, inside_virtualenv, delete_pyc, print_env, detect_os
 from fab_deploy.system import create_linux_account, ssh_add_key
 from fab_deploy.crontab import crontab_set, crontab_add, crontab_show, crontab_remove, crontab_update

fab_deploy/django_commands.py

 #coding: utf-8
 from __future__ import with_statement
-from fabric.api import run, settings, env
+from fabric.api import *
 from fab_deploy.mysql import mysqldump
 from fab_deploy.utils import inside_project
 
 @inside_project
+def command_is_available(command):
+    with settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True):
+        output = run('python manage.py help ' + command)
+    return output.succeeded
+
+@inside_project
 def manage(command):
     """ Runs django management command.
     Example::
 
         fab manage:createsuperuser
     """
-    run('python ./manage.py '+ command)
+    if not command_is_available(command):
+        warn('Management command "%s" is not available' % command)
+    else:
+        run('python manage.py '+ command)
 
 def migrate(params='', do_backup=True):
     """ Runs migrate management command. Database backup is performed
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.