def process_last(self, user_jid, our_jid, sub, last): if last is not None: sub["last"] = last yield UserSubscriptions(user_jid).subscribe(sub["url"]) yield Subscription.create(sub) self._xmpp.send_presence(to=user_jid, from_=sub["jid"], type_="subscribe") else: yield wait_for_host(sub["host"], level=2) try: page = yield get_page(sub["url"]) except Exception: self._xmpp.send_message( to=user_jid, from_=get_full_jid(our_jid), body=u"Url check failed, subscription aborted. " "Seems like not existing url.") else: parsed = yield self._worker.parse(sub, page) if "last" in parsed and parsed["last"] is not None: self.process_last(user_jid, our_jid, sub, parsed["last"]) else: self._xmpp.send_message( to=user_jid, from_=get_full_jid(our_jid), body=u"Page parsing failed, subscription aborted. " "Seems like not existing url.")
def process_last(self, user_jid, our_jid, sub, last): if last is not None: sub["last"] = last yield UserSubscriptions(user_jid).subscribe(sub["url"]) yield Subscription.create(sub) self._xmpp.send_presence( to=user_jid, from_=sub["jid"], type_="subscribe") else: yield wait_for_host(sub["host"], level=2) try: page = yield get_page(sub["url"]) except Exception: self._xmpp.send_message( to=user_jid, from_=get_full_jid(our_jid), body=u"Url check failed, subscription aborted. " "Seems like not existing url.") else: parsed = yield self._worker.parse(sub, page) if "last" in parsed and parsed["last"] is not None: self.process_last(user_jid, our_jid, sub, parsed["last"]) else: self._xmpp.send_message( to=user_jid, from_=get_full_jid(our_jid), body=u"Page parsing failed, subscription aborted. " "Seems like not existing url.")
def process_page(self, sub, last_modified): yield utils.wait_for_host(sub["host"]) self.debug("HOST OK: %s (page)" % sub["url"]) try: page = yield get_page(sub["url"]) except NotFound: self.dead_url(sub) except Exception: err = traceback.format_exc()[:-1] self.bad_url(sub, err) else: parsed = yield self._worker.parse(sub, page) self.process_parsed(sub, parsed, last_modified) # We've done, decrement connections count self._conn_count -= 1
def process_last_modified(self, sub): yield utils.wait_for_host(sub["host"]) self.debug("HOST OK: %s (last modified)" % sub["url"]) try: last_modified = yield get_last_modified(sub["url"]) except NotFound: self.dead_url(sub) except Exception: err = traceback.format_exc()[:-1] self.bad_url(sub, err) else: if last_modified: db_last_mod = yield Subscription( sub["url"]).get_last_modified() if last_modified != db_last_mod: # Header changed, seems like page was changed # so let's continue. self.debug("LAST MODIFIED WAS CHANGED: %s" % sub["url"]) self.process_page(sub, last_modified) return # Exiting and decrement connections count self._conn_count -= 1
def main(): print 'waiting for arm...' wait_for_host(config.doggo_arm_ip) print 'waiting for overview...' wait_for_host(config.doggo_overview_ip) print 'waiting for control...' wait_for_host(config.doggo_control_ip) stream_cmd = "mplayer -fps 200 -demuxer h264es ffmpeg://tcp://%s:9999 > /dev/null &" print 'ready' print 'launching cameras...' if not os.getenv('NO_CAMERA'): os.system(stream_cmd % config.doggo_arm_ip) os.system(stream_cmd % config.doggo_overview_ip) time.sleep(1) os.system('''i3-msg '[class="MPlayer"] floating enable' ''') ui.main()
def main(instance): print 'waiting for connection to ' + instance + '...' wait_for_host(get_param('ip')) ui.main()