# HG changeset patch # User Adrien Di Mascio # Date 1476102444 -7200 # Node ID b96bed36765dccbcfaacaae0a81d3f4d7038ab5c # Parent 2efe0bf90ebb9efc5568578515eef45b45727171 [devctl] make sure i18ncube always delete its tempdir closes #15613724 diff -r 2efe0bf90ebb -r b96bed36765d cubicweb/devtools/devctl.py --- a/cubicweb/devtools/devctl.py Mon Oct 10 14:34:41 2016 +0200 +++ b/cubicweb/devtools/devctl.py Mon Oct 10 14:27:24 2016 +0200 @@ -565,35 +565,36 @@ def update_cube_catalogs(cubedir): cubedir = osp.abspath(osp.normpath(cubedir)) workdir = tempfile.mkdtemp() - cube = osp.basename(cubedir) - print('cubedir', cubedir) - print(underline_title('Updating i18n catalogs for cube %s' % cube)) - chdir(cubedir) - extractor = I18nCubeMessageExtractor(workdir, cubedir) - potfile = extractor.generate_pot_file() - if potfile is None: - print('no message catalog for cube', cube, 'nothing to translate') + try: + cube = osp.basename(cubedir) + print('cubedir', cubedir) + print(underline_title('Updating i18n catalogs for cube %s' % cube)) + chdir(cubedir) + extractor = I18nCubeMessageExtractor(workdir, cubedir) + potfile = extractor.generate_pot_file() + if potfile is None: + print('no message catalog for cube', cube, 'nothing to translate') + return () + print('-> merging main pot file with existing translations:', end=' ') + chdir('i18n') + toedit = [] + for lang in CubicWebNoAppConfiguration.cw_languages(): + print(lang, end=' ') + cubepo = '%s.po' % lang + if not osp.exists(cubepo): + shutil.copy(potfile, cubepo) + else: + cmd = ['msgmerge', '-N', '-s', '-o', cubepo + 'new', + cubepo, potfile] + execute2(cmd) + ensure_fs_mode(cubepo) + shutil.move('%snew' % cubepo, cubepo) + toedit.append(osp.abspath(cubepo)) + print() + return toedit + finally: + # cleanup shutil.rmtree(workdir) - return () - print('-> merging main pot file with existing translations:', end=' ') - chdir('i18n') - toedit = [] - for lang in CubicWebNoAppConfiguration.cw_languages(): - print(lang, end=' ') - cubepo = '%s.po' % lang - if not osp.exists(cubepo): - shutil.copy(potfile, cubepo) - else: - cmd = ['msgmerge', '-N', '-s', '-o', cubepo + 'new', - cubepo, potfile] - execute2(cmd) - ensure_fs_mode(cubepo) - shutil.move('%snew' % cubepo, cubepo) - toedit.append(osp.abspath(cubepo)) - print() - # cleanup - shutil.rmtree(workdir) - return toedit class NewCubeCommand(Command):