summaryrefslogtreecommitdiff
path: root/django/core/management.py
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2006-06-06 01:21:49 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2006-06-06 01:21:49 +0000
commite976ed1f7910fad03704f88853c5c5b36cbab134 (patch)
treec4c8d32d4298f64ad9ce8e7813084c2f45a9dc40 /django/core/management.py
parent0c341d780ebcde0e81c81eda07e2db3aaa92549b (diff)
multi-auth: Merged to [3085]
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@3086 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/management.py')
-rw-r--r--django/core/management.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/django/core/management.py b/django/core/management.py
index f7bbf29227..931372cc5e 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -1055,7 +1055,9 @@ def run_shell(use_plain=False):
# Don't bother loading IPython, because the user wants plain Python.
raise ImportError
import IPython
- shell = IPython.Shell.IPShell()
+ # Explicitly pass an empty list as arguments, because otherwise IPython
+ # would use sys.argv from this script.
+ shell = IPython.Shell.IPShell(argv=[])
shell.mainloop()
except ImportError:
import code
@@ -1137,7 +1139,11 @@ def print_error(msg, cmd):
sys.stderr.write(style.ERROR('Error: %s' % msg) + '\nRun "%s --help" for help.\n' % cmd)
sys.exit(1)
-def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING):
+def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING, argv=None):
+ # Use sys.argv if we've not passed in a custom argv
+ if argv is None:
+ argv = sys.argv
+
# Parse the command-line arguments. optparse handles the dirty work.
parser = DjangoOptionParser(usage=get_usage(action_mapping), version=get_version())
parser.add_option('--settings',
@@ -1146,7 +1152,7 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING):
help='Lets you manually add a directory the Python path, e.g. "/home/djangoprojects/myproject".')
parser.add_option('--plain', action='store_true', dest='plain',
help='Tells Django to use plain Python, not IPython, for "shell" command.')
- options, args = parser.parse_args()
+ options, args = parser.parse_args(argv[1:])
# Take care of options.
if options.settings:
@@ -1161,7 +1167,7 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING):
except IndexError:
parser.print_usage_and_exit()
if not action_mapping.has_key(action):
- print_error("Your action, %r, was invalid." % action, sys.argv[0])
+ print_error("Your action, %r, was invalid." % action, argv[0])
# Switch to English, because django-admin.py creates database content
# like permissions, and those shouldn't contain any translations.
@@ -1220,7 +1226,7 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING):
if action not in NO_SQL_TRANSACTION:
print style.SQL_KEYWORD("COMMIT;")
-def execute_manager(settings_mod):
+def execute_manager(settings_mod, argv=None):
# Add this project to sys.path so that it's importable in the conventional
# way. For example, if this file (manage.py) lives in a directory
# "myproject", this code would add "/path/to/myproject" to sys.path.
@@ -1247,4 +1253,4 @@ def execute_manager(settings_mod):
action_mapping['startapp'].args = startapp.args
# Run the django-admin.py command.
- execute_from_command_line(action_mapping)
+ execute_from_command_line(action_mapping, argv)