devtools/devctl.py
changeset 8249 c59c05c51321
parent 8190 2a3c1b787688
parent 8247 65b0d2587fb5
child 8258 88a7d2c49d39
equal deleted inserted replaced
8246:84f0a2e0059e 8249:c59c05c51321
    30 from warnings import warn
    30 from warnings import warn
    31 
    31 
    32 from logilab.common import STD_BLACKLIST
    32 from logilab.common import STD_BLACKLIST
    33 
    33 
    34 from cubicweb.__pkginfo__ import version as cubicwebversion
    34 from cubicweb.__pkginfo__ import version as cubicwebversion
    35 from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage
    35 from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage, ExecutionError
    36 from cubicweb.cwctl import CWCTL
    36 from cubicweb.cwctl import CWCTL
    37 from cubicweb.cwconfig import CubicWebNoAppConfiguration
    37 from cubicweb.cwconfig import CubicWebNoAppConfiguration
    38 from cubicweb.toolsutils import (SKEL_EXCLUDE, Command, copy_skeleton,
    38 from cubicweb.toolsutils import (SKEL_EXCLUDE, Command, copy_skeleton,
    39                                  underline_title)
    39                                  underline_title)
    40 from cubicweb.web.webconfig import WebConfiguration
    40 from cubicweb.web.webconfig import WebConfiguration
   375         else:
   375         else:
   376             cubes = [DevConfiguration.cube_dir(cube)
   376             cubes = [DevConfiguration.cube_dir(cube)
   377                      for cube in DevConfiguration.available_cubes()]
   377                      for cube in DevConfiguration.available_cubes()]
   378             cubes = [cubepath for cubepath in cubes
   378             cubes = [cubepath for cubepath in cubes
   379                      if osp.exists(osp.join(cubepath, 'i18n'))]
   379                      if osp.exists(osp.join(cubepath, 'i18n'))]
   380         update_cubes_catalogs(cubes)
   380         if not update_cubes_catalogs(cubes):
       
   381             raise ExecutionError("update cubes i18n catalog failed")
   381 
   382 
   382 
   383 
   383 def update_cubes_catalogs(cubes):
   384 def update_cubes_catalogs(cubes):
   384     for cubedir in cubes:
   385     for cubedir in cubes:
   385         if not osp.isdir(cubedir):
   386         if not osp.isdir(cubedir):
   389             toedit = update_cube_catalogs(cubedir)
   390             toedit = update_cube_catalogs(cubedir)
   390         except Exception:
   391         except Exception:
   391             import traceback
   392             import traceback
   392             traceback.print_exc()
   393             traceback.print_exc()
   393             print '-> error while updating catalogs for cube', cubedir
   394             print '-> error while updating catalogs for cube', cubedir
       
   395             return False
   394         else:
   396         else:
   395             # instructions pour la suite
   397             # instructions pour la suite
   396             if toedit:
   398             if toedit:
   397                 print '-> regenerated .po catalogs for cube %s.' % cubedir
   399                 print '-> regenerated .po catalogs for cube %s.' % cubedir
   398                 print '\nYou can now edit the following files:'
   400                 print '\nYou can now edit the following files:'
   399                 print '* ' + '\n* '.join(toedit)
   401                 print '* ' + '\n* '.join(toedit)
   400                 print ('When you are done, run "cubicweb-ctl i18ninstance '
   402                 print ('When you are done, run "cubicweb-ctl i18ninstance '
   401                        '<yourinstance>" to see changes in your instances.')
   403                        '<yourinstance>" to see changes in your instances.')
       
   404             return True
   402 
   405 
   403 def update_cube_catalogs(cubedir):
   406 def update_cube_catalogs(cubedir):
   404     import shutil
   407     import shutil
   405     import tempfile
   408     import tempfile
   406     from logilab.common.fileutils import ensure_fs_mode
   409     from logilab.common.fileutils import ensure_fs_mode