729 else: |
729 else: |
730 applcubicwebversion = vcconf.get('cubicweb') |
730 applcubicwebversion = vcconf.get('cubicweb') |
731 if cubicwebversion > applcubicwebversion: |
731 if cubicwebversion > applcubicwebversion: |
732 toupgrade.append(('cubicweb', applcubicwebversion, cubicwebversion)) |
732 toupgrade.append(('cubicweb', applcubicwebversion, cubicwebversion)) |
733 if not self.config.fs_only and not toupgrade: |
733 if not self.config.fs_only and not toupgrade: |
734 print '-> no software migration needed for instance %s.' % appid |
734 print '-> no data migration needed for instance %s.' % appid |
|
735 self.i18nupgrade(config) |
|
736 mih.shutdown() |
735 return |
737 return |
736 for cube, fromversion, toversion in toupgrade: |
738 for cube, fromversion, toversion in toupgrade: |
737 print '-> migration needed from %s to %s for %s' % (fromversion, toversion, cube) |
739 print '-> migration needed from %s to %s for %s' % (fromversion, toversion, cube) |
738 # only stop once we're sure we have something to do |
740 # only stop once we're sure we have something to do |
739 if not (CWDEV or self.config.nostartstop): |
741 if not (CWDEV or self.config.nostartstop): |
740 StopInstanceCommand().stop_instance(appid) |
742 StopInstanceCommand().stop_instance(appid) |
741 # run cubicweb/componants migration scripts |
743 # run cubicweb/componants migration scripts |
742 mih.migrate(vcconf, reversed(toupgrade), self.config) |
744 mih.migrate(vcconf, reversed(toupgrade), self.config) |
743 # rewrite main configuration file |
745 # rewrite main configuration file |
744 mih.rewrite_configuration() |
746 mih.rewrite_configuration() |
|
747 mih.shutdown() |
|
748 # handle i18n upgrade |
|
749 if not self.i18nupgrade(config): |
|
750 return |
|
751 print |
|
752 print '-> instance migrated.' |
|
753 if not (CWDEV or self.config.nostartstop): |
|
754 # restart instance through fork to get a proper environment, avoid |
|
755 # uicfg pb (and probably gettext catalogs, to check...) |
|
756 forkcmd = '%s start %s' % (sys.argv[0], appid) |
|
757 status = system(forkcmd) |
|
758 if status: |
|
759 print '%s exited with status %s' % (forkcmd, status) |
|
760 print |
|
761 |
|
762 def i18nupgrade(self, config): |
745 # handle i18n upgrade: |
763 # handle i18n upgrade: |
746 # * install new languages |
764 # * install new languages |
747 # * recompile catalogs |
765 # * recompile catalogs |
748 # XXX search available language in the first cube given |
766 # XXX search available language in the first cube given |
749 from cubicweb import i18n |
767 from cubicweb import i18n |
751 langs = [lang for lang, _ in i18n.available_catalogs(join(templdir, 'i18n'))] |
769 langs = [lang for lang, _ in i18n.available_catalogs(join(templdir, 'i18n'))] |
752 errors = config.i18ncompile(langs) |
770 errors = config.i18ncompile(langs) |
753 if errors: |
771 if errors: |
754 print '\n'.join(errors) |
772 print '\n'.join(errors) |
755 if not ASK.confirm('Error while compiling message catalogs, ' |
773 if not ASK.confirm('Error while compiling message catalogs, ' |
756 'continue anyway ?'): |
774 'continue anyway?'): |
757 print '-> migration not completed.' |
775 print '-> migration not completed.' |
758 return |
776 return False |
759 mih.shutdown() |
777 return True |
760 print |
|
761 print '-> instance migrated.' |
|
762 if not (CWDEV or self.config.nostartstop): |
|
763 # restart instance through fork to get a proper environment, avoid |
|
764 # uicfg pb (and probably gettext catalogs, to check...) |
|
765 forkcmd = '%s start %s' % (sys.argv[0], appid) |
|
766 status = system(forkcmd) |
|
767 if status: |
|
768 print '%s exited with status %s' % (forkcmd, status) |
|
769 print |
|
770 |
|
771 |
778 |
772 class ShellCommand(Command): |
779 class ShellCommand(Command): |
773 """Run an interactive migration shell on an instance. This is a python shell |
780 """Run an interactive migration shell on an instance. This is a python shell |
774 with enhanced migration commands predefined in the namespace. An additional |
781 with enhanced migration commands predefined in the namespace. An additional |
775 argument may be given corresponding to a file containing commands to execute |
782 argument may be given corresponding to a file containing commands to execute |