Fixed #29492 -- Improved compilemessages speed
This commit is contained in:
parent
553617e613
commit
998d774195
|
@ -1,4 +1,5 @@
|
||||||
import codecs
|
import codecs
|
||||||
|
import concurrent.futures
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -106,35 +107,41 @@ class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
Locations is a list of tuples: [(directory, file), ...]
|
Locations is a list of tuples: [(directory, file), ...]
|
||||||
"""
|
"""
|
||||||
for i, (dirpath, f) in enumerate(locations):
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||||
if self.verbosity > 0:
|
futures = []
|
||||||
self.stdout.write('processing file %s in %s\n' % (f, dirpath))
|
for i, (dirpath, f) in enumerate(locations):
|
||||||
po_path = os.path.join(dirpath, f)
|
if self.verbosity > 0:
|
||||||
if has_bom(po_path):
|
self.stdout.write('processing file %s in %s\n' % (f, dirpath))
|
||||||
self.stderr.write(
|
po_path = os.path.join(dirpath, f)
|
||||||
'The %s file has a BOM (Byte Order Mark). Django only '
|
if has_bom(po_path):
|
||||||
'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 '
|
||||||
self.has_errors = True
|
'supports .po files encoded in UTF-8 and without any BOM.' % po_path
|
||||||
continue
|
)
|
||||||
base_path = os.path.splitext(po_path)[0]
|
self.has_errors = True
|
||||||
|
continue
|
||||||
|
base_path = os.path.splitext(po_path)[0]
|
||||||
|
|
||||||
# Check writability on first location
|
# Check writability on first location
|
||||||
if i == 0 and not is_writable(base_path + '.mo'):
|
if i == 0 and not is_writable(base_path + '.mo'):
|
||||||
self.stderr.write(
|
self.stderr.write(
|
||||||
'The po files under %s are in a seemingly not writable location. '
|
'The po files under %s are in a seemingly not writable location. '
|
||||||
'mo files will not be updated/created.' % dirpath
|
'mo files will not be updated/created.' % dirpath
|
||||||
)
|
)
|
||||||
self.has_errors = True
|
self.has_errors = True
|
||||||
return
|
return
|
||||||
|
|
||||||
args = [self.program] + self.program_options + [
|
args = [self.program] + self.program_options + [
|
||||||
'-o', base_path + '.mo', base_path + '.po'
|
'-o', base_path + '.mo', base_path + '.po'
|
||||||
]
|
]
|
||||||
output, errors, status = popen_wrapper(args)
|
futures.append(executor.submit(popen_wrapper, args))
|
||||||
if status:
|
|
||||||
if errors:
|
for future in concurrent.futures.as_completed(futures):
|
||||||
self.stderr.write('Execution of %s failed: %s.' % (self.program, errors))
|
output, errors, status = future.result()
|
||||||
else:
|
if status:
|
||||||
self.stderr.write('Execution of %s failed.' % self.program)
|
if self.verbosity > 0:
|
||||||
self.has_errors = True
|
if errors:
|
||||||
|
self.stderr.write("Execution of %s failed: %s" % (self.program, errors))
|
||||||
|
else:
|
||||||
|
self.stderr.write("Execution of %s failed" % self.program)
|
||||||
|
self.has_errors = True
|
||||||
|
|
Loading…
Reference in New Issue