Author: claudep
Date: 2012-04-26 12:56:20 -0700 (Thu, 26 Apr 2012)
New Revision: 17941
Modified:
django/trunk/django/core/management/commands/flush.py
django/trunk/django/core/management/commands/syncdb.py
Log:
Removed direct print statements from django management commands.
Modified: django/trunk/django/core/management/commands/flush.py
===================================================================
--- django/trunk/django/core/management/commands/flush.py 2012-04-26
18:06:17 UTC (rev 17940)
+++ django/trunk/django/core/management/commands/flush.py 2012-04-26
19:56:20 UTC (rev 17941)
@@ -82,4 +82,4 @@
call_command('loaddata', 'initial_data', **kwargs)
else:
- print "Flush cancelled."
+ self.stdout.write("Flush cancelled.\n")
Modified: django/trunk/django/core/management/commands/syncdb.py
===================================================================
--- django/trunk/django/core/management/commands/syncdb.py 2012-04-26
18:06:17 UTC (rev 17940)
+++ django/trunk/django/core/management/commands/syncdb.py 2012-04-26
19:56:20 UTC (rev 17941)
@@ -1,5 +1,4 @@
from optparse import make_option
-import sys
import traceback
from django.conf import settings
@@ -82,12 +81,12 @@
# 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 @@
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 @@
# 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 @@
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 @@
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:
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.