summaryrefslogtreecommitdiff
path: root/django/core/management/commands/compilemessages.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2018-06-06 11:24:25 +0200
committerClaude Paroz <claude@2xlibre.net>2018-06-13 21:09:02 +0200
commita77f21880dfb0631ea0adb22d47909915cbfc3a9 (patch)
tree17b0aa1fb776da85a1901d5275aeba025126f6e5 /django/core/management/commands/compilemessages.py
parentb30f9b131c9489b9d9f21c311ecb46d0aea91381 (diff)
Fixed #24384 -- Allowed compilemessages to continue running after nonfatal errors.
Thanks Aymeric Augustin for the report and Carlton Gibson and Tim Graham for the reviews.
Diffstat (limited to 'django/core/management/commands/compilemessages.py')
-rw-r--r--django/core/management/commands/compilemessages.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/django/core/management/commands/compilemessages.py b/django/core/management/commands/compilemessages.py
index bf704a4e8d..77dd0f085c 100644
--- a/django/core/management/commands/compilemessages.py
+++ b/django/core/management/commands/compilemessages.py
@@ -86,6 +86,7 @@ class Command(BaseCommand):
locales = locale or all_locales
locales = set(locales).difference(exclude)
+ self.has_errors = False
for basedir in basedirs:
if locales:
dirs = [os.path.join(basedir, l, 'LC_MESSAGES') for l in locales]
@@ -98,6 +99,9 @@ class Command(BaseCommand):
if locations:
self.compile_messages(locations)
+ if self.has_errors:
+ raise CommandError('compilemessages generated one or more errors.')
+
def compile_messages(self, locations):
"""
Locations is a list of tuples: [(directory, file), ...]
@@ -107,15 +111,21 @@ class Command(BaseCommand):
self.stdout.write('processing file %s in %s\n' % (f, dirpath))
po_path = os.path.join(dirpath, f)
if has_bom(po_path):
- raise CommandError("The %s file has a BOM (Byte Order Mark). "
- "Django only supports .po files encoded in "
- "UTF-8 and without any BOM." % po_path)
+ self.stderr.write(
+ 'The %s file has a BOM (Byte Order Mark). Django only '
+ 'supports .po files encoded in UTF-8 and without any BOM.' % po_path
+ )
+ self.has_errors = True
+ continue
base_path = os.path.splitext(po_path)[0]
# Check writability on first location
if i == 0 and not is_writable(base_path + '.mo'):
- self.stderr.write("The po files under %s are in a seemingly not writable location. "
- "mo files will not be updated/created." % dirpath)
+ self.stderr.write(
+ 'The po files under %s are in a seemingly not writable location. '
+ 'mo files will not be updated/created.' % dirpath
+ )
+ self.has_errors = True
return
args = [self.program] + self.program_options + [
@@ -124,7 +134,7 @@ class Command(BaseCommand):
output, errors, status = popen_wrapper(args)
if status:
if errors:
- msg = "Execution of %s failed: %s" % (self.program, errors)
+ self.stderr.write('Execution of %s failed: %s.' % (self.program, errors))
else:
- msg = "Execution of %s failed" % self.program
- raise CommandError(msg)
+ self.stderr.write('Execution of %s failed.' % self.program)
+ self.has_errors = True