コード例 #1
0
    def _handle_q(msg):
        d = json.loads(msg.body)

        event_id = d.get(
            "event_id") or d["event_fullname"][len("LiveUpdateEvent_"):]
        liveupdate_id = d["liveupdate_id"]

        try:
            fn = TimeoutFunction(parse_embeds, 10)
            liveupdate = fn(event_id, liveupdate_id)
        except TimeoutFunctionException:
            g.log.warning("Timed out on %s::%s", event_id, liveupdate_id)
            return
        except Exception as e:
            g.log.warning("Failed to scrape %s::%s: %r", event_id,
                          liveupdate_id, e)
            return

        if not liveupdate:
            return

        if not liveupdate.embeds and not liveupdate.mobile_embeds:
            return

        payload = {
            "liveupdate_id": "LiveUpdate_" + liveupdate_id,
            "media_embeds": liveupdate.embeds,
            "mobile_embeds": liveupdate.mobile_embeds,
        }
        send_event_broadcast(event_id, type="embeds_ready", payload=payload)
コード例 #2
0
    def _handle_q(msg):
        d = json.loads(msg.body)

        try:
            fn = TimeoutFunction(parse_embeds, 10)
            liveupdate = fn(d['event_id'], d['liveupdate_id'])
        except TimeoutFunctionException:
            g.log.warning(
                "Timed out on %s::%s", d["event_id"], d["liveupdate_id"])
            return
        except Exception as e:
            g.log.warning("Failed to scrape %s::%s: %r",
                d["event_id"], d["liveupdate_id"], e)
            return

        if not liveupdate.media_objects:
            return

        payload = {
            "liveupdate_id": "LiveUpdate_" + d['liveupdate_id'],
            "media_embeds": liveupdate.embeds
        }
        send_event_broadcast(d['event_id'],
                             type="embeds_ready",
                             payload=payload)
コード例 #3
0
    def _handle_q(msg):
        d = json.loads(msg.body)

        event_id = d.get("event_id") or d["event_fullname"][len("LiveUpdateEvent_"):]
        liveupdate_id = d["liveupdate_id"]

        try:
            fn = TimeoutFunction(parse_embeds, 10)
            liveupdate = fn(event_id, liveupdate_id)
        except TimeoutFunctionException:
            g.log.warning(
                "Timed out on %s::%s", event_id, liveupdate_id)
            return
        except Exception as e:
            g.log.warning("Failed to scrape %s::%s: %r",
                event_id, liveupdate_id, e)
            return

        if not liveupdate:
            return

        if not liveupdate.embeds and not liveupdate.mobile_embeds:
            return

        payload = {
            "liveupdate_id": "LiveUpdate_" + liveupdate_id,
            "media_embeds": liveupdate.embeds,
            "mobile_embeds": liveupdate.mobile_embeds,
        }
        send_event_broadcast(event_id,
                             type="embeds_ready",
                             payload=payload)
コード例 #4
0
def close_event(event):
    """Close a liveupdate event"""
    event.state = "complete"
    event._commit()

    queries.complete_event(event)

    send_event_broadcast(event._id, type="complete", payload={})
コード例 #5
0
def close_event(event):
    """Close a liveupdate event"""
    event.state = "complete"
    event._commit()

    queries.complete_event(event)

    send_event_broadcast(event._id, type="complete", payload={})
コード例 #6
0
def _broadcast(type, payload):
    send_event_broadcast(c.liveupdate_event._id, type, payload)
コード例 #7
0
def _broadcast(type, payload):
    send_event_broadcast(c.liveupdate_event._id, type, payload)