本文整理汇总了Python中monitor.Monitor.watch方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.watch方法的具体用法?Python Monitor.watch怎么用?Python Monitor.watch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitor.Monitor
的用法示例。
在下文中一共展示了Monitor.watch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Main
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import watch [as 别名]
class Main(object):
def __init__(self):
self.monitor = None
try:
# instanciates the config
self.config = Config()
# exists baboon when receiving a sigint signal
signal.signal(signal.SIGINT, self.sigint_handler)
# Initialize the scm class to use
scm_classes = Diffman.__subclasses__()
for cls in scm_classes:
tmp_inst = cls()
if tmp_inst.scm_name == self.config.scm:
self.diffman = tmp_inst
# TODO verify self.diffman
self.mediator = Mediator(self.diffman)
self.transport = Transport(self.mediator)
self.transport.open()
self.monitor = Monitor(self.transport, self.diffman)
self.monitor.watch()
# TODO this won't work on windows...
signal.pause()
except BaboonException, err:
sys.stderr.write("%s\n" % err)
# Try to close the transport properly. If the transport is
# not correctly started, the close() method has no effect.
self.transport.close()
# Same thing for the monitor
if self.monitor:
self.monitor.close()
# Exits with a fail return code
sys.exit(1)