c5ca9eba9b0f — Peter Sanchez 12 years ago
Added basic support for multiple arguments to django management commands.
1 files changed, 19 insertions(+), 8 deletions(-)

M djeploy/django.py
M djeploy/django.py +19 -8
@@ 4,7 4,7 @@ from djeploy import djeploy_require, set
 
 
 @task
-def run_manage_command(cmd, extra_path=None):
+def run_manage_command(cmd, *args, **kwargs):
     ''' Run manage.py syncdb
     '''
     opts = get_env('release_path', 'virtual_env_path', 'scm_repo_name')

          
@@ 13,29 13,40 @@ def run_manage_command(cmd, extra_path=N
     scm_repo_name = opts['scm_repo_name']
     python_path = os.path.join(virtual_env_path, 'bin', 'python')
     manage_path = os.path.join(release_path, scm_repo_name)
+
+    # Check for extra_path
+    extra_path = kwargs.get('extra_path', None)
     if extra_path is not None:
         manage_path = os.path.join(manage_path, extra_path)
 
+    run_cmd = '%s ./manage.py %s' % (python_path, cmd)
+    if len(args):
+        run_cmd += ' %s' % ' '.join(args)
+
     with command.cd(manage_path):
-        command.run('%s ./manage.py %s' % (python_path, cmd))
+        command.run(run_cmd)
 
 
 @task
-def django_syncdb(extra_path=None):
+def django_syncdb(*args, **kwargs):
     ''' Run manage.py syncdb
     '''
-    run_manage_command('syncdb --noinput', extra_path)
+    if not args:
+        args = ['--noinput']
+    run_manage_command('syncdb', *args, **kwargs)
 
 
 @task
-def django_migrate(extra_path=None):
+def django_migrate(*args, **kwargs):
     ''' Run manage.py migrate (requires South)
     '''
-    run_manage_command('migrate', extra_path)
+    run_manage_command('migrate', *args, **kwargs)
 
 
 @task
-def django_collectstatic(extra_path=None):
+def django_collectstatic(*args, **kwargs):
     ''' Run manage.py collectstatic
     '''
-    run_manage_command('collectstatic --noinput', extra_path)
+    if not args:
+        args = ['--noinput']
+    run_manage_command('collectstatic', *args, **kwargs)