本文整理汇总了Python中handler.Handler.push方法的典型用法代码示例。如果您正苦于以下问题:Python Handler.push方法的具体用法?Python Handler.push怎么用?Python Handler.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类handler.Handler
的用法示例。
在下文中一共展示了Handler.push方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read
# 需要导入模块: from handler import Handler [as 别名]
# 或者: from handler.Handler import push [as 别名]
def read(self):
line = self.file.readline()
while line:
self.count += 1
Handler.push(self, {'type': 'line',
'raw': line.strip(),
'source': self.name })
line = self.file.readline()
reactor.callLater(1, self.read)
示例2: push
# 需要导入模块: from handler import Handler [as 别名]
# 或者: from handler.Handler import push [as 别名]
def push(self, data):
if (data.has_key('timestamp')):
print("%s - %s : %s" % (data['timestamp'],
data['source'],
data['raw']))
else:
print("unknown - %s : %s" % (data['source'],
data['raw']))
Handler.push(self, data)
示例3: push
# 需要导入模块: from handler import Handler [as 别名]
# 或者: from handler.Handler import push [as 别名]
def push(self, data):
match = data['raw'].find("ERROR")>=0
if not self.match and match:
self.info("Detected ERROR")
data['type'] = 'event'
data['raw'] = "@type:\"line\" AND @timestamp:[\"%s\" *] - %s" % (
data['timestamp'], data['raw'])
Handler.push(self, data)
self.match = match
示例4: push
# 需要导入模块: from handler import Handler [as 别名]
# 或者: from handler.Handler import push [as 别名]
def push(self, data):
self.debug("Parsing time in data %s" % (data))
try:
parser = self.parsers.get(data['source'])
if not parser:
parser = self.parsers[data['source']] = self._autodetect(
data['raw'])
stamp = parser(data['raw'])
stamp = self._format_time(self._adjust_time(stamp))
data['timestamp'] = stamp
except Exception as e:
self.warning("Failed to parse time in %s" % (data['raw']))
Handler.push(self, data)
示例5: Receiver
# 需要导入模块: from handler import Handler [as 别名]
# 或者: from handler.Handler import push [as 别名]
receiver = Receiver()
transmitter = Transmitter()
receiver.connect()
td1 = threading.Thread(target=handler.run)
td2 = threading.Thread(target=receiver.run)
td3 = threading.Thread(target=transmitter.run)
td1.start()
td2.start()
td3.start()
# main loop
while True:
if handler.is_runing() and receiver.is_runing() and transmitter.is_runing():
msg = receiver.fetch()
while msg != None:
handler.push(msg)
msg = receiver.fetch()
msg = handler.fetch_to_send()
while msg != None:
transmitter.push(msg)
msg = handler.fetch_to_send()
else:
break
handler.stop()
receiver.stop()
transmitter.stop()
td1.join()
td2.join()
td3.join()
示例6: push
# 需要导入模块: from handler import Handler [as 别名]
# 或者: from handler.Handler import push [as 别名]
def push(self, data):
self.debug("Pushing data %s to elastic search" % (data))
event = ElasticEvent(data)
self.es.index("carmanor", "line", event.dict())
Handler.push(self, data)