|
@@ -112,10 +112,10 @@ class Command(BaseCommand):
|
|
|
|
|
|
if formats:
|
|
|
if verbosity > 1:
|
|
|
- print "Loading '%s' fixtures..." % fixture_name
|
|
|
+ self.stdout.write("Loading '%s' fixtures...\n" % fixture_name)
|
|
|
else:
|
|
|
sys.stderr.write(
|
|
|
- self.style.ERROR("Problem installing fixture '%s': %s is not a known serialization format." %
|
|
|
+ self.style.ERROR("Problem installing fixture '%s': %s is not a known serialization format.\n" %
|
|
|
(fixture_name, format)))
|
|
|
transaction.rollback(using=using)
|
|
|
transaction.leave_transaction_management(using=using)
|
|
@@ -128,7 +128,7 @@ class Command(BaseCommand):
|
|
|
|
|
|
for fixture_dir in fixture_dirs:
|
|
|
if verbosity > 1:
|
|
|
- print "Checking %s for fixtures..." % humanize(fixture_dir)
|
|
|
+ self.stdout.write("Checking %s for fixtures...\n" % humanize(fixture_dir))
|
|
|
|
|
|
label_found = False
|
|
|
for combo in product([using, None], formats, compression_formats):
|
|
@@ -141,16 +141,16 @@ class Command(BaseCommand):
|
|
|
)
|
|
|
|
|
|
if verbosity > 1:
|
|
|
- print "Trying %s for %s fixture '%s'..." % \
|
|
|
- (humanize(fixture_dir), file_name, fixture_name)
|
|
|
+ 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)
|
|
|
open_method = compression_types[compression_format]
|
|
|
try:
|
|
|
fixture = open_method(full_path, 'r')
|
|
|
if label_found:
|
|
|
fixture.close()
|
|
|
- print self.style.ERROR("Multiple fixtures named '%s' in %s. Aborting." %
|
|
|
- (fixture_name, humanize(fixture_dir)))
|
|
|
+ self.stderr.write(self.style.ERROR("Multiple fixtures named '%s' in %s. Aborting.\n" %
|
|
|
+ (fixture_name, humanize(fixture_dir))))
|
|
|
transaction.rollback(using=using)
|
|
|
transaction.leave_transaction_management(using=using)
|
|
|
return
|
|
@@ -158,8 +158,8 @@ class Command(BaseCommand):
|
|
|
fixture_count += 1
|
|
|
objects_in_fixture = 0
|
|
|
if verbosity > 0:
|
|
|
- print "Installing %s fixture '%s' from %s." % \
|
|
|
- (format, fixture_name, humanize(fixture_dir))
|
|
|
+ self.stdout.write("Installing %s fixture '%s' from %s.\n" % \
|
|
|
+ (format, fixture_name, humanize(fixture_dir)))
|
|
|
try:
|
|
|
objects = serializers.deserialize(format, fixture, using=using)
|
|
|
for obj in objects:
|
|
@@ -190,7 +190,7 @@ class Command(BaseCommand):
|
|
|
# error was encountered during fixture loading.
|
|
|
if objects_in_fixture == 0:
|
|
|
sys.stderr.write(
|
|
|
- self.style.ERROR("No fixture data found for '%s'. (File format may be invalid.)" %
|
|
|
+ self.style.ERROR("No fixture data found for '%s'. (File format may be invalid.)\n" %
|
|
|
(fixture_name)))
|
|
|
transaction.rollback(using=using)
|
|
|
transaction.leave_transaction_management(using=using)
|
|
@@ -198,8 +198,8 @@ class Command(BaseCommand):
|
|
|
|
|
|
except Exception, e:
|
|
|
if verbosity > 1:
|
|
|
- print "No %s fixture '%s' in %s." % \
|
|
|
- (format, fixture_name, humanize(fixture_dir))
|
|
|
+ self.stdout.write("No %s fixture '%s' in %s.\n" % \
|
|
|
+ (format, fixture_name, humanize(fixture_dir)))
|
|
|
|
|
|
# If we found even one object in a fixture, we need to reset the
|
|
|
# database sequences.
|
|
@@ -207,7 +207,7 @@ class Command(BaseCommand):
|
|
|
sequence_sql = connection.ops.sequence_reset_sql(self.style, models)
|
|
|
if sequence_sql:
|
|
|
if verbosity > 1:
|
|
|
- print "Resetting sequences"
|
|
|
+ self.stdout.write("Resetting sequences\n")
|
|
|
for line in sequence_sql:
|
|
|
cursor.execute(line)
|
|
|
|
|
@@ -217,10 +217,10 @@ class Command(BaseCommand):
|
|
|
|
|
|
if object_count == 0:
|
|
|
if verbosity > 0:
|
|
|
- print "No fixtures found."
|
|
|
+ self.stdout.write("No fixtures found.\n")
|
|
|
else:
|
|
|
if verbosity > 0:
|
|
|
- print "Installed %d object(s) from %d fixture(s)" % (object_count, fixture_count)
|
|
|
+ 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
|
|
|
# edge case in MySQL: if the same connection is used to
|