mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Rationalized the verbosity levels (including introducing a new super-verbose level) for syncdb, test and loaddata.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13539 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -118,7 +118,7 @@ class BaseCommand(object):
|
||||
# Metadata about this command.
|
||||
option_list = (
|
||||
make_option('-v', '--verbosity', action='store', dest='verbosity', default='1',
|
||||
type='choice', choices=['0', '1', '2'],
|
||||
type='choice', choices=['0', '1', '2', '3'],
|
||||
help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
|
||||
make_option('--settings',
|
||||
help='The Python path to a settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.'),
|
||||
|
||||
@@ -111,7 +111,7 @@ class Command(BaseCommand):
|
||||
formats = []
|
||||
|
||||
if formats:
|
||||
if verbosity > 1:
|
||||
if verbosity >= 2:
|
||||
self.stdout.write("Loading '%s' fixtures...\n" % fixture_name)
|
||||
else:
|
||||
sys.stderr.write(
|
||||
@@ -127,7 +127,7 @@ class Command(BaseCommand):
|
||||
fixture_dirs = app_fixtures + list(settings.FIXTURE_DIRS) + ['']
|
||||
|
||||
for fixture_dir in fixture_dirs:
|
||||
if verbosity > 1:
|
||||
if verbosity >= 2:
|
||||
self.stdout.write("Checking %s for fixtures...\n" % humanize(fixture_dir))
|
||||
|
||||
label_found = False
|
||||
@@ -140,7 +140,7 @@ class Command(BaseCommand):
|
||||
if p
|
||||
)
|
||||
|
||||
if verbosity > 1:
|
||||
if verbosity >= 3:
|
||||
self.stdout.write("Trying %s for %s fixture '%s'...\n" % \
|
||||
(humanize(fixture_dir), file_name, fixture_name))
|
||||
full_path = os.path.join(fixture_dir, file_name)
|
||||
@@ -157,7 +157,7 @@ class Command(BaseCommand):
|
||||
else:
|
||||
fixture_count += 1
|
||||
objects_in_fixture = 0
|
||||
if verbosity > 0:
|
||||
if verbosity >= 2:
|
||||
self.stdout.write("Installing %s fixture '%s' from %s.\n" % \
|
||||
(format, fixture_name, humanize(fixture_dir)))
|
||||
try:
|
||||
@@ -197,7 +197,7 @@ class Command(BaseCommand):
|
||||
return
|
||||
|
||||
except Exception, e:
|
||||
if verbosity > 1:
|
||||
if verbosity >= 2:
|
||||
self.stdout.write("No %s fixture '%s' in %s.\n" % \
|
||||
(format, fixture_name, humanize(fixture_dir)))
|
||||
|
||||
@@ -206,7 +206,7 @@ class Command(BaseCommand):
|
||||
if object_count > 0:
|
||||
sequence_sql = connection.ops.sequence_reset_sql(self.style, models)
|
||||
if sequence_sql:
|
||||
if verbosity > 1:
|
||||
if verbosity >= 2:
|
||||
self.stdout.write("Resetting sequences\n")
|
||||
for line in sequence_sql:
|
||||
cursor.execute(line)
|
||||
@@ -216,10 +216,10 @@ class Command(BaseCommand):
|
||||
transaction.leave_transaction_management(using=using)
|
||||
|
||||
if object_count == 0:
|
||||
if verbosity > 0:
|
||||
if verbosity >= 1:
|
||||
self.stdout.write("No fixtures found.\n")
|
||||
else:
|
||||
if verbosity > 0:
|
||||
if verbosity >= 1:
|
||||
self.stdout.write("Installed %d object(s) from %d fixture(s)\n" % (object_count, fixture_count))
|
||||
|
||||
# Close the DB connection. This is required as a workaround for an
|
||||
|
||||
@@ -76,10 +76,12 @@ class Command(NoArgsCommand):
|
||||
)
|
||||
|
||||
# Create the tables for each model
|
||||
if verbosity >= 1:
|
||||
print "Creating tables ..."
|
||||
for app_name, model_list in manifest.items():
|
||||
for model in model_list:
|
||||
# Create the model's database table, if it doesn't already exist.
|
||||
if verbosity >= 2:
|
||||
if verbosity >= 3:
|
||||
print "Processing %s.%s model" % (app_name, model._meta.object_name)
|
||||
sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
|
||||
seen_models.add(model)
|
||||
@@ -107,12 +109,14 @@ class Command(NoArgsCommand):
|
||||
|
||||
# Install custom SQL for the app (but only if this
|
||||
# is a model we've just created)
|
||||
if verbosity >= 1:
|
||||
print "Installing custom SQL ..."
|
||||
for app_name, model_list in manifest.items():
|
||||
for model in model_list:
|
||||
if model in created_models:
|
||||
custom_sql = custom_sql_for_model(model, self.style, connection)
|
||||
if custom_sql:
|
||||
if verbosity >= 1:
|
||||
if verbosity >= 2:
|
||||
print "Installing custom SQL for %s.%s model" % (app_name, model._meta.object_name)
|
||||
try:
|
||||
for sql in custom_sql:
|
||||
@@ -127,16 +131,18 @@ class Command(NoArgsCommand):
|
||||
else:
|
||||
transaction.commit_unless_managed(using=db)
|
||||
else:
|
||||
if verbosity >= 2:
|
||||
if verbosity >= 3:
|
||||
print "No custom SQL for %s.%s model" % (app_name, model._meta.object_name)
|
||||
|
||||
if verbosity >= 1:
|
||||
print "Installing indexes ..."
|
||||
# Install SQL indicies for all newly created models
|
||||
for app_name, model_list in manifest.items():
|
||||
for model in model_list:
|
||||
if model in created_models:
|
||||
index_sql = connection.creation.sql_indexes_for_model(model, self.style)
|
||||
if index_sql:
|
||||
if verbosity >= 1:
|
||||
if verbosity >= 2:
|
||||
print "Installing index for %s.%s model" % (app_name, model._meta.object_name)
|
||||
try:
|
||||
for sql in index_sql:
|
||||
|
||||
Reference in New Issue
Block a user