当前位置: 首页>>代码示例>>Python>>正文


Python Agent.ping方法代码示例

本文整理汇总了Python中agent.Agent.ping方法的典型用法代码示例。如果您正苦于以下问题:Python Agent.ping方法的具体用法?Python Agent.ping怎么用?Python Agent.ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在agent.Agent的用法示例。


在下文中一共展示了Agent.ping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ctl_ping

# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import ping [as 别名]
def ctl_ping(*args):
	"""Ping local daemon."""
	def success(result):
		if result == 'PONG':
			print "OK"
		else:
			print >>sys.stderr, "Bad response."
			raise SystemExit(2)

	agent=Agent()
	d=agent.ping()
	d.addCallback(success)
	
	return d
开发者ID:nagius,项目名称:cxm,代码行数:16,代码来源:clid.py

示例2: SvnwatcherService

# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import ping [as 别名]
class SvnwatcherService(Service):

	def __init__(self):
		self.node=node.Node.getLocalInstance() # Local node, always connected
		self.agent=Agent()		# Factory will be stopped if cxmd does'nt respond

	def startService(self):
		def standalone(reason):
			log.info("Starting in standalone mode.")
			self.agent=None
			
		def cluster(result):
			log.info("Starting in cluster mode.")

		Service.startService(self)

		msg=self.node.run("svn status "+core.cfg['VMCONF_DIR'] +" 2>&1").read()
		if len(msg)>0:
			log.err("Your repo is not clean. Please check it : %s" % (msg))
			raise Exception("SVN repo not clean")

		d=self.agent.ping()
		d.addCallbacks(cluster, standalone)
		d.addBoth(lambda _: self.spawnInotify())
		d.addErrback(log.err)
		return d
	
	def stopService(self):
		if self.running:
			Service.stopService(self)

			try:
				self._process.signalProcess('TERM')
			except:
				pass

			try:
				reactor.stop()
			except:
				pass

	def forceUpdate(self):
		log.info("SIGHUP received: updating all repos.")

		def commitEnded(result):
			if self.agent:
				log.info("Cluster updated.")
			else:
				log.info("Local node updated.")
				
		def commitFailed(reason):
			log.err("SVN failed: %s" % reason.getErrorMessage())

		# This is a manual entry-point for recovery : no locks handled
		d=self.pp.doUpdate()
		d.addCallbacks(commitEnded, commitFailed)

	def spawnInotify(self):
		# We use this ugly way because Pyinotify and Twisted's INotify require Python 2.6
		argv=["inotifywait", "-e", "create", "-e", "modify", "-e", "delete", "-m", core.cfg['VMCONF_DIR'], "--exclude", "/\.|~$|[0-9]+$"]
		self.pp = InotifyPP(self.node, self.agent)
		self._process=reactor.spawnProcess(self.pp, argv[0], argv, {})
开发者ID:nagius,项目名称:cxm,代码行数:64,代码来源:svnwatcher.py


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