本文整理汇总了Python中monitor.Monitor.addPublisher方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.addPublisher方法的具体用法?Python Monitor.addPublisher怎么用?Python Monitor.addPublisher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitor.Monitor
的用法示例。
在下文中一共展示了Monitor.addPublisher方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TCPServer
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import addPublisher [as 别名]
from SocketServer import TCPServer
except ImportError:
from socketserver import TCPServer
import threading
import sys
import os
import logging
from monitor import Monitor
from publishers import WebsocketPublisher
from connection import Connection
PORT = 80
if __name__ == "__main__":
logging.basicConfig(level=logging.WARN, filename="pyicemon.log")
# Serve static HTTP content.
os.chdir("static")
handler = SimpleHTTPRequestHandler
httpd = TCPServer(("", PORT), handler)
t = threading.Thread(target=httpd.serve_forever)
t.daemon = True
t.start()
# Fire up pyicemon.
host, port = sys.argv[1], sys.argv[2]
mon = Monitor(Connection(host, int(port)))
mon.addPublisher(WebsocketPublisher(port=9999))
mon.run()