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 = RH() g.rh = rh g.static_site = True zip_file_path = create_static_site(rh, static_site.event) static_site.state = StaticSiteState.success static_site.content_type = 'application/zip' static_site.filename = 'offline_site_{}.zip'.format(static_site.event.id) with open(zip_file_path, 'rb') as f: static_site.save(f) db.session.commit() logger.info('Building static site successful: %s', static_site) g.static_site = False g.rh = 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 g.rh = 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 = RH() rh._conf = rh._target = static_site.event.as_legacy g.rh = rh g.static_site = True zip_file_path = OfflineEvent(rh, rh._conf).create() static_site.state = StaticSiteState.success static_site.content_type = 'application/zip' static_site.filename = 'offline_site_{}.zip'.format( static_site.event.id) with open(zip_file_path, 'rb') as f: static_site.save(f) db.session.commit() logger.info('Building static site successful: %s', static_site) g.static_site = False g.rh = 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 g.rh = None
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 = RH() zip_file_path = create_static_site(rh, static_site.event) static_site.state = StaticSiteState.success static_site.content_type = 'application/zip' static_site.filename = 'offline_site_{}.zip'.format(static_site.event.id) with open(zip_file_path, 'rb') as f: static_site.save(f) db.session.commit() logger.info('Building static site successful: %s', static_site) 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
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)