本文整理汇总了Python中utils.logger.Logger.notice方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.notice方法的具体用法?Python Logger.notice怎么用?Python Logger.notice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.logger.Logger
的用法示例。
在下文中一共展示了Logger.notice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_collection
# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import notice [as 别名]
def do_collection(collection, start_date, end_date):
result_data = BytesIO()
condition = {'result.publish_time': {'$gte': start_date, '$lte': end_date}}
logging.info('search: {},{}'.format(collection.name, condition))
total_samples = 0
total_size = 0;
#batch_content = leveldb.WriteBatch()
for item in collection.find(condition):
text = item['result']['text'].encode('utf-8')
if len(text) == 0:
continue
url = item['url'].encode('utf-8')
publish_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(item['result']['publish_time']))
title = item['result'].get('title', '').encode('utf-8')
sample_type = item['result']['type'].encode('utf-8')
keyword = item['result']['extra'].get('keyword', '').encode('utf-8')
sample = (url, sample_type, publish_time, url, keyword, title, text)
sample_data = msgpack.packb(sample)
total_size += len(sample_data)
result_data.write(sample_data)
total_samples += 1
logging.debug(Logger.debug("%d [%s] %d %s" % (total_samples, publish_time, len(sample_data), title)))
#sample_id = self.acquire_sample_id(1)
#if sample_id % 1000 == 0:
#print sample_id, title
#sample_data = (sample_id, title, content)
#rowstr = msgpack.dumps(sample_data)
#batch_content.Put(str(sample_id), rowstr)
#self.db.Write(batch_content, sync=True)
logging.info(Logger.notice("Collected %d samples (size = %.3f MB)." % (total_samples, total_size / (1024 * 1024))))
return result_data.getvalue()