Commits

Mikhail Korobov  committed fe66bf6

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

  • Participants
  • Parent commits 8999fe0

Comments (0)

Files changed (2)

File 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

File 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