Beispiel #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)
Beispiel #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)
Beispiel #3
0
    def process_link(msg):
        fname = msg.body
        link = Link._by_fullname(msg.body, data=True)

        try:
            TimeoutFunction(_set_media, 30)(embedly_services, link)
        except TimeoutFunctionException:
            print "Timed out on %s" % fname
        except KeyboardInterrupt:
            raise
        except:
            print "Error fetching %s" % fname
            print traceback.format_exc()
Beispiel #4
0
    def process_link(msg):
        def _process_link(fname):
            link = Link._by_fullname(fname, data=True)
            set_media(link)

        fname = msg.body
        try:
            TimeoutFunction(_process_link, 30)(fname)
        except TimeoutFunctionException:
            print "Timed out on %s" % fname
        except KeyboardInterrupt:
            raise
        except:
            print "Error fetching %s" % fname
            print traceback.format_exc()