本文整理汇总了Python中moat.run.simple_event函数的典型用法代码示例。如果您正苦于以下问题:Python simple_event函数的具体用法?Python simple_event怎么用?Python simple_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了simple_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recv
def recv(self,msg):
if msg.type is MT_MULTILINE:
for x in msg.msg:
if x == "":
continue
m = _num.match(x)
if m is None:
continue
mon = int(m.group(0))
self.data[mon]=x[m.end():]
recvs,self.queue.receivers = self.queue.receivers,[]
for r in recvs:
mid = getattr(r,"msgid",None)
if mid is None or mid in self.data:
log("wago",TRACE,"found monitor",r)
self.queue.receivers.append(r)
else:
try:
raise DroppedMonitor(mid)
except DroppedMonitor as ex:
fix_exception(ex)
res = r.error(ex)
if res is SEND_AGAIN:
log("wago",TRACE,"retry monitor",r)
self.queue.enqueue(r)
else:
log("wago",TRACE,"drop monitor",r)
assert res is None or res is False, "%s.error returned %s"%(repr(r),repr(res))
return MINE
if msg.type is MT_NAK or msg.type is MT_ERROR:
simple_event("wago","monitor","error", msg=msg.msg)
return MINE
return NOT_MINE
示例2: delete
def delete(self,ctx=None):
self.server.stop_gevent()
self.server = None
if self.evt is not None:
self.evt.delete()
super(QBconn,self).delete()
simple_event("qbroker","disconnect",*self.name)
示例3: get
def get(self, state, ext=None, handler=None):
simple_event("fs20","state", *self.name, state=state, ext=ext)
ctx = Context(value=state)
if ext is not None:
ctx.ext = ext
simple_event(ctx, "input","fs20", *self.name)
示例4: on_disconnect
def on_disconnect(self):
simple_event("rpc","disconnect",*self.name)
if self.workers is not None:
for w in self.workers:
unregister_worker(w)
self.workers = None
super(RPCconn,self).delete()
示例5: retime
def retime(self, dest):
simple_event("wait","update",*self.name,dest=dest, loglevel=TRACE, deprecated=True)
simple_event("wait","state",*self.name, end_time=dest, loglevel=TRACE, state="update")
with log_wait("wait","delete1",self.name):
with self._lock:
self.end = dest
self._set_pling()
示例6: delete
def delete(self,ctx=None):
self.conn.close()
self.conn = None
self.stop_job("job")
simple_event("amqp","disconnect",*self.name, deprecated=True)
simple_event("amqp","state",*self.name, state="disconnect")
super(AMQPclient,self).delete()
示例7: lineReceived
def lineReceived(self,data):
db = ""
e = ""
if not data: return # empty line
if data[0] in PREFIX:
for d in data[1:]:
if e:
try:
db += chr(eval("0x"+e+d))
except SyntaxError:
simple_event("fs20","unknown","hex", data=data)
return
e=""
else:
e=d
if e:
log("fs20",WARN,"fs20 odd length "+data)
self.datagramReceived(data[0], db, timestamp=self.timestamp)
self.timestamp = None
elif data[0] == PREFIX_TIMESTAMP:
self.timestamp = float(data[1:])
elif data[0] == "P":
pass # idle
elif data[0] == "+":
log("fs20",DEBUG,"fs20 trace "+data)
else:
simple_event("fs20","unknown","prefix", prefix=data[0],data=data[1:])
示例8: _start
def _start(self):
reported = False
while True:
sleep(self.freq)
try:
self.time_start = now()
self.old_seen = self.seen.copy()
# log(DEBUG,"SCAN",self.path,"IN",self.bus)
self.bus.dir(path=self.path+('alarm',), proc=self._reporter, cached=False)
for id in self.old_seen:
simple_event("onewire","alarm","state",id, bus=self.bus.bus.name, path=self.path, id=id, state="off")
self.seen.remove(id)
except Exception as e:
self.last_error = e
if not reported:
reported = True
fix_exception(e)
process_failure(e)
self.time_len = now()-self.time_start
sleep(self.freq*10)
else:
reported = False
self.time_len = now()-self.time_start
for x in self.simul:
x[0] += 1
if x[0] >= x[1]:
x[0] = 0
self.bus.set(self.path+('simultaneous',x[2]),x[3])
示例9: datagramReceived
def datagramReceived(self, prefix, data, handler=None, timestamp=None):
try:
ext = PREFIX[prefix]
except KeyError:
simple_event("fs20","unknown","prefix",prefix=prefix,data=data)
else:
return ext.datagramReceived(self.ctx, data, handler, timestamp)
示例10: go_down
def go_down(self, _=None):
if not self.is_up:
return
self.is_up = False
if _ is not None:
process_failure(_)
simple_event("onewire","down",typ=self.typ,id=self.id,bus=self.bus.name,path=self.path, deprecated=True)
simple_event("onewire","device","state",self.id, typ=self.typ,id=self.id,bus=self.bus.name,path=self.path, state="down")
示例11: tx_proc_hygro
def tx_proc_hygro(ctx, data):
if len(data) != 7:
simple_event("fs20","tx","bad_length","hygro",len=len(data),data=data)
return None
if data[2] != data[5] or data[3] != data[6]:
simple_event("fs20","tx","bad_repeat","hygro",data=data)
return None
hum = data[2]*10 + data[3] + data[4]/10
return {"humidity":hum}
示例12: tx_proc_thermo
def tx_proc_thermo(ctx, data):
if len(data) != 7:
simple_event("fs20","tx","bad_length","thermo",len=len(data),data=data)
return None
if data[2] != data[5] or data[3] != data[6]:
simple_event("fs20","tx","bad_repeat","thermo",data=data)
return None
temp = data[2]*10 + data[3] + data[4]/10 -50
return {"temperature":temp}
示例13: delete
def delete(self,ctx=None):
if self.working:
raise StateChangeError(self,u"‹deleted›")
self.working = True
self.time = now()
try:
if self.value is not None:
simple_event("state","delete",*self.name, prev_value=self.value)
finally:
super(State,self).delete()
示例14: one_value
def one_value(self, step):
"""\
Get one value from some "set monitor" command.
Override this for active monitoring.
"""
if self.send_check_event and step==1:
simple_event(self.ectx, "monitor","checking",*self.name)
with log_wait("monitor","one_value",*self.name):
return self.watcher.get(block=True, timeout=None)
示例15: on_connect
def on_connect(self):
global conn_seq
conn_seq += 1
self.name = self.dest + ("n"+str(conn_seq),)
self.ctx = Context()
self.ctx.out = Reporter(self)
self.ctx.words = global_words(self.ctx)
self.workers = set()
simple_event("rpc","connect",*self.name)
Collected.__init__(self)