Ejemplo n.º 1
0
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 _run(self):
        Logger.get('OfflineEventGeneratorTask').info(
            "Started generation of the offline website for task: %s" %
            self._task.id)
        setLocale(self._task.avatar.getLang())
        self._rh = RHCustomizable()
        self._aw = self._rh._aw = AccessWrapper()
        self._rh._conf = self._rh._target = self._task.conference

        ContextManager.set('currentRH', self._rh)
        ContextManager.set('offlineMode', True)

        # Get event type
        wf = self._rh.getWebFactory()
        if wf:
            eventType = wf.getId()
        else:
            eventType = "conference"

        try:
            websiteZipFile = OfflineEvent(self._rh, self._rh._conf,
                                          eventType).create()
        except Exception, e:
            Logger.get('OfflineEventGeneratorTask').exception(
                "Generation of the offline website for task %s failed \
                with message error: %s" % (self._task.id, e))
            self._task.status = "Failed"
            return
Ejemplo n.º 3
0
    def _run(self):
        Logger.get('OfflineEventGeneratorTask').info("Started generation of the offline website for task: %s" %
                                                     self._task.id)
        setLocale(self._task.avatar.getLang())
        self._rh = RHCustomizable()
        self._aw = self._rh._aw = AccessWrapper()
        self._rh._conf = self._rh._target = self._task.conference

        ContextManager.set('currentRH', self._rh)
        ContextManager.set('offlineMode', True)

        # Get event type
        wf = self._rh.getWebFactory()
        if wf:
            eventType = wf.getId()
        else:
            eventType = "conference"

        try:
            websiteZipFile = OfflineEvent(self._rh, self._rh._conf, eventType).create()
        except Exception, e:
            Logger.get('OfflineEventGeneratorTask').exception("Generation of the offline website for task %s failed \
                with message error: %s" % (self._task.id, e))
            self._task.status = "Failed"
            return
class OfflineEventGeneratorTask(OneShotTask):
    def __init__(self, task):
        super(OfflineEventGeneratorTask, self).__init__(task.requestTime)
        self._task = task

    def run(self):
        with current_app.test_request_context():
            self._run()

    def _run(self):
        Logger.get('OfflineEventGeneratorTask').info(
            "Started generation of the offline website for task: %s" %
            self._task.id)
        setLocale(self._task.avatar.getLang())
        self._rh = RHCustomizable()
        self._aw = self._rh._aw = AccessWrapper()
        self._rh._conf = self._rh._target = self._task.conference

        ContextManager.set('currentRH', self._rh)
        ContextManager.set('offlineMode', True)

        # Get event type
        wf = self._rh.getWebFactory()
        if wf:
            eventType = wf.getId()
        else:
            eventType = "conference"

        try:
            websiteZipFile = OfflineEvent(self._rh, self._rh._conf,
                                          eventType).create()
        except Exception, e:
            Logger.get('OfflineEventGeneratorTask').exception(
                "Generation of the offline website for task %s failed \
                with message error: %s" % (self._task.id, e))
            self._task.status = "Failed"
            return

        self._task.creationTime = nowutc()
        if not websiteZipFile:
            Logger.get('OfflineEventGeneratorTask').info(
                "Generation of the offline website for task %s failed" %
                self._task.id)
            self._task.status = "Failed"
            return
        self._task.status = "Generated"
        self._task.file = websiteZipFile

        Logger.get('OfflineEventGeneratorTask').info(
            "Finished generation of the offline website for task %s" %
            self._task.id)
        ContextManager.set('offlineMode', False)
        notification = OfflineEventGeneratedNotification(self._task)
        GenericMailer.sendAndLog(notification, self._task.conference,
                                 "OfflineEventGenerator")
Ejemplo n.º 5
0
class OfflineEventGeneratorTask(OneShotTask):

    def __init__(self, task):
        super(OfflineEventGeneratorTask, self).__init__(task.requestTime)
        self._task = task

    def run(self):
        from indico.web.flask.app import make_app

        app = make_app()
        with app.test_request_context():
            self._run()

    def _run(self):
        Logger.get('OfflineEventGeneratorTask').info("Started generation of the offline website for task: %s" %
                                                     self._task.id)
        setLocale(self._task.avatar.getLang())
        self._rh = RHCustomizable()
        self._aw = self._rh._aw = AccessWrapper()
        self._rh._conf = self._rh._target = self._task.conference

        ContextManager.set('currentRH', self._rh)
        ContextManager.set('offlineMode', True)

        # Get event type
        wf = self._rh.getWebFactory()
        if wf:
            eventType = wf.getId()
        else:
            eventType = "conference"

        try:
            websiteZipFile = OfflineEvent(self._rh, self._rh._conf, eventType).create()
        except Exception, e:
            Logger.get('OfflineEventGeneratorTask').exception("Generation of the offline website for task %s failed \
                with message error: %s" % (self._task.id, e))
            self._task.status = "Failed"
            return

        self._task.creationTime = nowutc()
        if not websiteZipFile:
            Logger.get('OfflineEventGeneratorTask').info("Generation of the offline website for task %s failed" %
                                                         self._task.id)
            self._task.status = "Failed"
            return
        self._task.status = "Generated"
        self._task.file = websiteZipFile

        Logger.get('OfflineEventGeneratorTask').info("Finished generation of the offline website for task %s" %
                                                     self._task.id)
        ContextManager.set('offlineMode', False)
        notification = OfflineEventGeneratedNotification(self._task)
        GenericMailer.sendAndLog(notification, self._task.conference, "OfflineEventGenerator")
Ejemplo n.º 6
0
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)