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