Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed direct print statements from django management commands.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17941 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c34d069a75dc3486b984928745b06b8d39767475 1 parent 8aca3d1
@claudep claudep authored
View
2  django/core/management/commands/flush.py
@@ -82,4 +82,4 @@ def handle_noargs(self, **options):
call_command('loaddata', 'initial_data', **kwargs)
else:
- print "Flush cancelled."
+ self.stdout.write("Flush cancelled.\n")
View
21 django/core/management/commands/syncdb.py
@@ -1,5 +1,4 @@
from optparse import make_option
-import sys
import traceback
from django.conf import settings
@@ -82,12 +81,12 @@ def model_installed(model):
# Create the tables for each model
if verbosity >= 1:
- print "Creating tables ..."
+ self.stdout.write("Creating tables ...\n")
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 >= 3:
- print "Processing %s.%s model" % (app_name, model._meta.object_name)
+ self.stdout.write("Processing %s.%s model\n" % (app_name, model._meta.object_name))
sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
seen_models.add(model)
created_models.add(model)
@@ -97,7 +96,7 @@ def model_installed(model):
sql.extend(connection.creation.sql_for_pending_references(refto, self.style, pending_references))
sql.extend(connection.creation.sql_for_pending_references(model, self.style, pending_references))
if verbosity >= 1 and sql:
- print "Creating table %s" % model._meta.db_table
+ self.stdout.write("Creating table %s\n" % model._meta.db_table)
for statement in sql:
cursor.execute(statement)
tables.append(connection.introspection.table_name_converter(model._meta.db_table))
@@ -115,19 +114,19 @@ def model_installed(model):
# Install custom SQL for the app (but only if this
# is a model we've just created)
if verbosity >= 1:
- print "Installing custom SQL ..."
+ self.stdout.write("Installing custom SQL ...\n")
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 >= 2:
- print "Installing custom SQL for %s.%s model" % (app_name, model._meta.object_name)
+ self.stdout.write("Installing custom SQL for %s.%s model\n" % (app_name, model._meta.object_name))
try:
for sql in custom_sql:
cursor.execute(sql)
except Exception, e:
- sys.stderr.write("Failed to install custom SQL for %s.%s model: %s\n" % \
+ self.stderr.write("Failed to install custom SQL for %s.%s model: %s\n" % \
(app_name, model._meta.object_name, e))
if show_traceback:
traceback.print_exc()
@@ -136,10 +135,10 @@ def model_installed(model):
transaction.commit_unless_managed(using=db)
else:
if verbosity >= 3:
- print "No custom SQL for %s.%s model" % (app_name, model._meta.object_name)
+ self.stdout.write("No custom SQL for %s.%s model\n" % (app_name, model._meta.object_name))
if verbosity >= 1:
- print "Installing indexes ..."
+ self.stdout.write("Installing indexes ...\n")
# Install SQL indices for all newly created models
for app_name, model_list in manifest.items():
for model in model_list:
@@ -147,12 +146,12 @@ def model_installed(model):
index_sql = connection.creation.sql_indexes_for_model(model, self.style)
if index_sql:
if verbosity >= 2:
- print "Installing index for %s.%s model" % (app_name, model._meta.object_name)
+ self.stdout.write("Installing index for %s.%s model\n" % (app_name, model._meta.object_name))
try:
for sql in index_sql:
cursor.execute(sql)
except Exception, e:
- sys.stderr.write("Failed to install index for %s.%s model: %s\n" % \
+ self.stderr.write("Failed to install index for %s.%s model: %s\n" % \
(app_name, model._meta.object_name, e))
transaction.rollback_unless_managed(using=db)
else:
Please sign in to comment.
Something went wrong with that request. Please try again.