• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python run.simple_event函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中moat.run.simple_event函数的典型用法代码示例。如果您正苦于以下问题:Python simple_event函数的具体用法?Python simple_event怎么用?Python simple_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了simple_event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:smurfix,项目名称:MoaT,代码行数:34,代码来源:wago.py


示例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)
开发者ID:smurfix,项目名称:MoaT,代码行数:7,代码来源:qbroker.py


示例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)
开发者ID:M-o-a-T,项目名称:moat,代码行数:7,代码来源:fs20switch.py


示例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()
开发者ID:smurfix,项目名称:MoaT,代码行数:7,代码来源:rpc.py


示例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()
开发者ID:smurfix,项目名称:MoaT,代码行数:7,代码来源:wait.py


示例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()
开发者ID:M-o-a-T,项目名称:moat,代码行数:7,代码来源:amqp.py


示例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:])
开发者ID:M-o-a-T,项目名称:moat,代码行数:28,代码来源:fs20avr.py


示例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])
开发者ID:smurfix,项目名称:MoaT,代码行数:28,代码来源:onewire.py


示例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)
开发者ID:M-o-a-T,项目名称:moat,代码行数:7,代码来源:fs20.py


示例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")
开发者ID:smurfix,项目名称:MoaT,代码行数:8,代码来源:onewire.py


示例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}
开发者ID:smurfix,项目名称:MoaT,代码行数:9,代码来源:fs20tx.py


示例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}
开发者ID:smurfix,项目名称:MoaT,代码行数:9,代码来源:fs20tx.py


示例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()
开发者ID:smurfix,项目名称:MoaT,代码行数:10,代码来源:state.py


示例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)
开发者ID:smurfix,项目名称:MoaT,代码行数:10,代码来源:monitor.py


示例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)
开发者ID:smurfix,项目名称:MoaT,代码行数:10,代码来源:rpc.py


示例16: do_post

	def do_post(self):
		self.slotter = None
		if self.running != "during" or self.waiter is not None:
			log(ERROR,"timeslot error post",self.running,*self.name)
			return

		self.running = "next"
		simple_event("timeslot","end",*self.name, deprecated=True)
		simple_event("timeslot","state",*self.name, state="end")
		self.next = time_delta(self.interval, now=self.next)-dt.timedelta(0,self.duration)
		self.waiter = callLater(False, self.next, self.do_pre)
开发者ID:M-o-a-T,项目名称:moat,代码行数:11,代码来源:timeslot.py


示例17: event

	def event(self,ctx,data):
		d={}
		for m,n in data.items():
			try: n = n * self.faktor[m]
			except KeyError: pass
			try: n = n + self.offset[m]
			except KeyError: pass
			d[m]=n

		simple_event("fs20","tx", *self.name, **d)
		self.last = now()
		self.last_data = data
开发者ID:smurfix,项目名称:MoaT,代码行数:12,代码来源:fs20tx.py


示例18: delete

	def delete(self,ctx=None):
		if self.timer:
			self.timer.cancel()
			self.timer = None
		try:
			if self.state:
				simple_event("pwm","change",*self.name, value=0)
		except Exception as ex:
			fix_exception(ex)
			process_failure(ex)
		finally:
			super(CommonPM,self).delete()
开发者ID:smurfix,项目名称:MoaT,代码行数:12,代码来源:pwm.py


示例19: on_info_msg

	def on_info_msg(self,msg):
		if not self._direct and not TESTING and getattr(msg,'message_id','').startswith(base_mseq):
			return # dup
		typ = getattr(msg,'content_type','')
		try:
			codec = get_codec(typ)
			data = codec.decode(msg.body)
		except Exception as e:
			data = { "raw": msg.body, "content_type": typ, "error": e }
		self.last_recv = msg.__dict__
		if 'timestamp' not in data:
			data['timestamp'] = now()
		simple_event(*(self.prefix+tuple(msg.routing_key.split('.')[self.strip:])), _direct=self._direct, **data)
开发者ID:M-o-a-T,项目名称:moat,代码行数:13,代码来源:amqp.py


示例20: up

	def up(self):
		with log_wait("monitor up "+repr(self)):
			while self.job and self.job.dead:
				gevent.sleep(0.1) # link will clear

		if not self.job:
			self.value = None
			simple_event("monitor","start",*self.name)
			self.start_job("job",self._run_loop)
			self.state_change_at = now()

			def tell_ended(_):
				simple_event("monitor","stop",*self.name)
			self.job.link(tell_ended)
开发者ID:smurfix,项目名称:MoaT,代码行数:14,代码来源:monitor.py



注:本文中的moat.run.simple_event函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python times.now函数代码示例发布时间:2022-05-27
下一篇:
Python logging.log函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap