本文整理汇总了Python中backend.Backend.add_event方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.add_event方法的具体用法?Python Backend.add_event怎么用?Python Backend.add_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend.Backend
的用法示例。
在下文中一共展示了Backend.add_event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Store
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import add_event [as 别名]
class Store(LineReceiver):
def __init__(self, db):
# each TCP request handler gets its own sqlite cursor
# this should be sufficient for proper concurrent behavior,
# but if anyone can confirm this, that would be appreciated
self.backend = Backend(db, exists=True)
# support both \n and (default) \r\n delimiters
# http://stackoverflow.com/questions/5087559/twisted-server-nc-client
self.delimiter = "\n"
def lineReceived(self, line):
# line: <timestamp> <some> <tags=here> -- description text of the event goes here
event = line.rstrip("\r").split(" -- ", 1)
event[0] = event[0].split(' ', 1)
timestamp = int(event[0][0])
tags = event[0][1].split(' ')
desc = event[1]
try:
event = Event(timestamp=timestamp, desc=desc, tags=tags)
print "line:", line
self.backend.add_event(event)
except sqlite3.OperationalError, e:
sys.stderr.write("sqlite error, aborting. : %s" % e)
sys.exit(2)
except Exception, e:
sys.stderr.write("bad line: %s --> error: %s\n" % (line, e))