24 # possible (for cubicweb-ctl reactivity, necessary for instance for usable bash |
24 # possible (for cubicweb-ctl reactivity, necessary for instance for usable bash |
25 # completion). So import locally in command helpers. |
25 # completion). So import locally in command helpers. |
26 import sys |
26 import sys |
27 from warnings import warn, filterwarnings |
27 from warnings import warn, filterwarnings |
28 from os import remove, listdir, system, pathsep |
28 from os import remove, listdir, system, pathsep |
29 from os.path import exists, join, isdir, dirname, abspath |
29 from os.path import exists, join, isdir |
30 |
30 |
31 try: |
31 try: |
32 from os import kill, getpgid |
32 from os import kill, getpgid |
33 except ImportError: |
33 except ImportError: |
34 def kill(*args): |
34 def kill(*args): |
395 if section not in ('main', 'email', 'web'): |
395 if section not in ('main', 'email', 'web'): |
396 print('\n' + underline_title('%s options' % section)) |
396 print('\n' + underline_title('%s options' % section)) |
397 config.input_config(section, self.config.config_level) |
397 config.input_config(section, self.config.config_level) |
398 # write down configuration |
398 # write down configuration |
399 config.save() |
399 config.save() |
400 self._handle_win32(config, appid) |
|
401 print('-> generated config %s' % config.main_config_file()) |
400 print('-> generated config %s' % config.main_config_file()) |
402 # handle i18n files structure |
401 # handle i18n files structure |
403 # in the first cube given |
402 # in the first cube given |
404 from cubicweb import i18n |
403 from cubicweb import i18n |
405 langs = [lang for lang, _ in i18n.available_catalogs(join(templdirs[0], 'i18n'))] |
404 langs = [lang for lang, _ in i18n.available_catalogs(join(templdirs[0], 'i18n'))] |
421 print('set %s as owner of the data directory' % config['uid']) |
420 print('set %s as owner of the data directory' % config['uid']) |
422 chown(config.appdatahome, config['uid']) |
421 chown(config.appdatahome, config['uid']) |
423 print('\n-> creation done for %s\n' % repr(config.apphome)[1:-1]) |
422 print('\n-> creation done for %s\n' % repr(config.apphome)[1:-1]) |
424 if not self.config.no_db_create: |
423 if not self.config.no_db_create: |
425 helper.postcreate(self.config.automatic, self.config.config_level) |
424 helper.postcreate(self.config.automatic, self.config.config_level) |
426 |
|
427 def _handle_win32(self, config, appid): |
|
428 if sys.platform != 'win32': |
|
429 return |
|
430 service_template = """ |
|
431 import sys |
|
432 import win32serviceutil |
|
433 sys.path.insert(0, r"%(CWPATH)s") |
|
434 |
|
435 from cubicweb.etwist.service import CWService |
|
436 |
|
437 classdict = {'_svc_name_': 'cubicweb-%(APPID)s', |
|
438 '_svc_display_name_': 'CubicWeb ' + '%(CNAME)s', |
|
439 'instance': '%(APPID)s'} |
|
440 %(CNAME)sService = type('%(CNAME)sService', (CWService,), classdict) |
|
441 |
|
442 if __name__ == '__main__': |
|
443 win32serviceutil.HandleCommandLine(%(CNAME)sService) |
|
444 """ |
|
445 open(join(config.apphome, 'win32svc.py'), 'wb').write( |
|
446 service_template % {'APPID': appid, |
|
447 'CNAME': appid.capitalize(), |
|
448 'CWPATH': abspath(join(dirname(__file__), '..'))}) |
|
449 |
425 |
450 |
426 |
451 class DeleteInstanceCommand(Command): |
427 class DeleteInstanceCommand(Command): |
452 """Delete an instance. Will remove instance's files and |
428 """Delete an instance. Will remove instance's files and |
453 unregister it. |
429 unregister it. |