本文整理汇总了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
示例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, {})