def build_static_site(static_site): static_site.state = StaticSiteState.running db.session.commit() try: logger.info('Building static site: {}'.format(static_site)) session.lang = static_site.creator.settings.get('lang') rh = RHCustomizable() rh._aw = AccessWrapper() rh._conf = rh._target = static_site.event ContextManager.set('currentRH', rh) ContextManager.set('offlineMode', True) # Get event type wf = rh.getWebFactory() event_type = wf.getId() if wf else 'conference' zip_file_path = OfflineEvent(rh, rh._conf, event_type).create(static_site.id) static_site.path = zip_file_path static_site.state = StaticSiteState.success db.session.commit() logger.info('Building static site successful: {}'.format(static_site)) ContextManager.set('offlineMode', False) ContextManager.set('currentRH', None) notify_static_site_success(static_site) except Exception: logger.exception('Building static site failed: {}'.format(static_site)) static_site.state = StaticSiteState.failed db.session.commit() raise finally: ContextManager.set('offlineMode', False) ContextManager.set('currentRH', None)
def build_static_site(static_site): static_site.state = StaticSiteState.running db.session.commit() try: logger.info('Building static site: %s', static_site) session.lang = static_site.creator.settings.get('lang') rh = RHCustomizable() rh._aw = AccessWrapper() rh._conf = rh._target = static_site.event_new.as_legacy g.rh = rh ContextManager.set('currentRH', rh) g.static_site = True # Get event type wf = rh.getWebFactory() event_type = wf.getId() if wf else 'conference' zip_file_path = OfflineEvent(rh, rh._conf, event_type).create(static_site.id) static_site.path = zip_file_path static_site.state = StaticSiteState.success db.session.commit() logger.info('Building static site successful: %s', static_site) g.static_site = False ContextManager.set('currentRH', None) notify_static_site_success(static_site) except Exception: logger.exception('Building static site failed: %s', static_site) static_site.state = StaticSiteState.failed db.session.commit() raise finally: g.static_site = False ContextManager.set('currentRH', None)