Beispiel #1
0
    def migrate(self):
        print cformat('%{white!}migrating static sites')
        for item in committing_iterator(chain.from_iterable(
                                        self.zodb_root['modules']['offlineEvents']._idxConf.itervalues())):

            event_id = item.conference.id
            if is_legacy_id(event_id):
                print cformat('%{red!}!!!%{reset} '
                              '%{white!}{0:6s}%{reset} %{yellow!}Event has non-numeric/broken ID').format(event_id)
                continue

            if event_id not in self.zodb_root['conferences']:
                print cformat('%{red!}!!!%{reset} '
                              '%{white!}{0:6s}%{reset} %{yellow!}Event deleted, skipping static site').format(event_id)
                continue

            event_id = int(event_id)
            user = self._get_user(item.avatar.id)
            state = STATE_MAPPING[item.status]
            requested_dt = item.requestTime
            file_name, file_path = self._get_file_data(item.file)

            if file_path is None and state == StaticSiteState.success:
                print cformat('%{yellow!}!!!%{reset} %{white!}{0:6d}%{reset} '
                              '%{yellow!}file missing, marking static site as expired.').format(event_id)
                state = StaticSite.expired

            static_site = StaticSite(creator=user, event_id=event_id, state=state, requested_dt=requested_dt)
            if static_site.state == StaticSiteState.success:
                static_site.path = file_path
            db.session.add(static_site)

            print cformat('%{green}+++%{reset} %{white!}{0.event_id:6d}%{reset} '
                          '%{cyan}{0}%{reset}').format(static_site)
Beispiel #2
0
    def migrate(self):
        print cformat('%{white!}migrating static sites')
        for item in committing_iterator(
                chain.from_iterable(self.zodb_root['modules']
                                    ['offlineEvents']._idxConf.itervalues())):

            event_id = item.conference.id
            if is_legacy_id(event_id):
                print cformat(
                    '%{red!}!!!%{reset} '
                    '%{white!}{0:6s}%{reset} %{yellow!}Event has non-numeric/broken ID'
                ).format(event_id)
                continue

            if event_id not in self.zodb_root['conferences']:
                print cformat(
                    '%{red!}!!!%{reset} '
                    '%{white!}{0:6s}%{reset} %{yellow!}Event deleted, skipping static site'
                ).format(event_id)
                continue

            event_id = int(event_id)
            user = self._get_user(item.avatar.id)
            state = STATE_MAPPING[item.status]
            requested_dt = item.requestTime
            file_name, file_path = self._get_file_data(item.file)

            if file_path is None and state == StaticSiteState.success:
                print cformat(
                    '%{yellow!}!!!%{reset} %{white!}{0:6d}%{reset} '
                    '%{yellow!}file missing, marking static site as expired.'
                ).format(event_id)
                state = StaticSite.expired

            static_site = StaticSite(creator=user,
                                     event_id=event_id,
                                     state=state,
                                     requested_dt=requested_dt)
            if static_site.state == StaticSiteState.success:
                static_site.path = file_path
            db.session.add(static_site)

            print cformat(
                '%{green}+++%{reset} %{white!}{0.event_id:6d}%{reset} '
                '%{cyan}{0}%{reset}').format(static_site)