cwctl.py
branchstable
changeset 2395 e3093fc12a00
parent 2321 0b363cd5ef76
child 2473 490f88fb99b6
equal deleted inserted replaced
2394:92bba46b853f 2395:e3093fc12a00
     8 from os import remove, listdir, system, kill, getpgid, pathsep
     8 from os import remove, listdir, system, kill, getpgid, pathsep
     9 from os.path import exists, join, isfile, isdir
     9 from os.path import exists, join, isfile, isdir
    10 
    10 
    11 from logilab.common.clcommands import register_commands, pop_arg
    11 from logilab.common.clcommands import register_commands, pop_arg
    12 
    12 
    13 from cubicweb import ConfigurationError, ExecutionError, BadCommandUsage
    13 from cubicweb import ConfigurationError, ExecutionError, BadCommandUsage, underline_title
    14 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg, CONFIGURATIONS
    14 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg, CONFIGURATIONS
    15 from cubicweb.toolsutils import Command, main_run,  rm, create_dir, confirm
    15 from cubicweb.toolsutils import Command, main_run,  rm, create_dir, confirm
    16 
    16 
    17 def wait_process_end(pid, maxtry=10, waittime=1):
    17 def wait_process_end(pid, maxtry=10, waittime=1):
    18     """wait for a process to actually die"""
    18     """wait for a process to actually die"""
   284             print ex
   284             print ex
   285             print '\navailable cubes:',
   285             print '\navailable cubes:',
   286             print ', '.join(cwcfg.available_cubes())
   286             print ', '.join(cwcfg.available_cubes())
   287             return
   287             return
   288         # create the registry directory for this application
   288         # create the registry directory for this application
       
   289         print '\n'+underline_title('Creating the application %s' % appid)
   289         create_dir(config.apphome)
   290         create_dir(config.apphome)
   290         # load site_cubicweb from the cubes dir (if any)
   291         # load site_cubicweb from the cubes dir (if any)
   291         config.load_site_cubicweb()
   292         config.load_site_cubicweb()
   292         # cubicweb-ctl configuration
   293         # cubicweb-ctl configuration
   293         print '** application\'s %s configuration' % configname
   294         print '\n'+underline_title('Configuring the application (%s.conf)' % configname)
   294         print '-' * 72
       
   295         config.input_config('main', self.config.config_level)
   295         config.input_config('main', self.config.config_level)
   296         # configuration'specific stuff
   296         # configuration'specific stuff
   297         print
   297         print
   298         helper.bootstrap(cubes, self.config.config_level)
   298         helper.bootstrap(cubes, self.config.config_level)
   299         # write down configuration
   299         # write down configuration
   300         config.save()
   300         config.save()
       
   301         print '-> generated %s' % config.main_config_file()
   301         # handle i18n files structure
   302         # handle i18n files structure
   302         # in the first cube given
   303         # in the first cube given
       
   304         print '-> preparing i18n catalogs'
   303         from cubicweb.common import i18n
   305         from cubicweb.common import i18n
   304         langs = [lang for lang, _ in i18n.available_catalogs(join(templdirs[0], 'i18n'))]
   306         langs = [lang for lang, _ in i18n.available_catalogs(join(templdirs[0], 'i18n'))]
   305         errors = config.i18ncompile(langs)
   307         errors = config.i18ncompile(langs)
   306         if errors:
   308         if errors:
   307             print '\n'.join(errors)
   309             print '\n'.join(errors)
   315         if config['uid']:
   317         if config['uid']:
   316             from logilab.common.shellutils import chown
   318             from logilab.common.shellutils import chown
   317             # this directory should be owned by the uid of the server process
   319             # this directory should be owned by the uid of the server process
   318             print 'set %s as owner of the data directory' % config['uid']
   320             print 'set %s as owner of the data directory' % config['uid']
   319             chown(config.appdatahome, config['uid'])
   321             chown(config.appdatahome, config['uid'])
   320         print
   322         print '\n-> creation done for %r.\n' % config.apphome
   321         print
       
   322         print '*' * 72
       
   323         print 'application %s (%s) created in %r' % (appid, configname,
       
   324                                                      config.apphome)
       
   325         print
       
   326         helper.postcreate()
   323         helper.postcreate()
   327 
   324 
   328 
   325 
   329 class DeleteApplicationCommand(Command):
   326 class DeleteApplicationCommand(Command):
   330     """Delete an application. Will remove application's files and
   327     """Delete an application. Will remove application's files and