# HG changeset patch # User Peter Sanchez # Date 1334279380 25200 # Thu Apr 12 18:09:40 2012 -0700 # Node ID c5ca9eba9b0f03e6feb33f201de019c9ae6a9a47 # Parent 02409d6d21a8a95d2a8ae806251a6d70541cadeb Added basic support for multiple arguments to django management commands. diff --git a/djeploy/django.py b/djeploy/django.py --- a/djeploy/django.py +++ b/djeploy/django.py @@ -4,7 +4,7 @@ @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 @@ 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)