本文整理汇总了Python中models.Report.count方法的典型用法代码示例。如果您正苦于以下问题:Python Report.count方法的具体用法?Python Report.count怎么用?Python Report.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Report
的用法示例。
在下文中一共展示了Report.count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: xmlrpc_test_bulk_insert
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import count [as 别名]
def xmlrpc_test_bulk_insert(self, count, same_crackers = False):
if same_crackers and len(self._crackers) < count:
logging.debug("Filling static crackers from {} to {}".format(len(self._crackers), count))
for i in xrange(len(self._crackers), count):
self._crackers.append(self.random_ip_address())
for i in xrange(count):
reporter = self.random_ip_address()
if same_crackers:
cracker_ip = self._crackers[i]
else:
cracker_ip = self.random_ip_address()
logging.debug("Adding report for {} from {}".format(cracker_ip, reporter))
yield utils.wait_and_lock_host(cracker_ip)
cracker = yield Cracker.find(where=['ip_address=?', cracker_ip], limit=1)
if cracker is None:
now = time.time()
cracker = Cracker(ip_address=cracker_ip, first_time=now, latest_time=now, total_reports=0, current_reports=0)
yield cracker.save()
yield controllers.add_report_to_cracker(cracker, reporter)
utils.unlock_host(cracker_ip)
logging.debug("Done adding report for {} from {}".format(cracker_ip,reporter))
total = yield Cracker.count()
total_reports = yield Report.count()
returnValue((total,total_reports))