本文整理汇总了Python中config.Log.info方法的典型用法代码示例。如果您正苦于以下问题:Python Log.info方法的具体用法?Python Log.info怎么用?Python Log.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Log
的用法示例。
在下文中一共展示了Log.info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_msg
# 需要导入模块: from config import Log [as 别名]
# 或者: from config.Log import info [as 别名]
def handle_msg(self, r):
"""
@brief Recover from snapshot data.
@param r Dict: message json
"""
Log.debug('handle message')
if self.msg_handler:
self.msg_handler.handle_wxsync(r)
n = len(r['AddMsgList'])
if n == 0:
return
if self.log_mode:
echo(Constant.LOG_MSG_NEW_MSG % n)
for msg in r['AddMsgList']:
msgType = msg['MsgType']
msgId = msg['MsgId']
content = msg['Content'].replace('<', '<').replace('>', '>')
raw_msg = None
if msgType == self.wx_conf['MSGTYPE_TEXT']:
# 地理位置消息
if content.find('pictype=location') != -1:
location = content.split('<br/>')[1][:-1]
raw_msg = {
'raw_msg': msg,
'location': location,
'log': Constant.LOG_MSG_LOCATION % location
}
# 普通文本消息
else:
text = content.split(':<br/>')[-1]
raw_msg = {
'raw_msg': msg,
'text': text,
'log': text.replace('<br/>', '\n')
}
elif msgType == self.wx_conf['MSGTYPE_IMAGE']:
data = self.webwxgetmsgimg(msgId)
fn = 'img_' + msgId + '.jpg'
dir = self.save_data_folders['webwxgetmsgimg']
path = save_file(fn, data, dir)
raw_msg = {'raw_msg': msg,
'image': path,
'log': Constant.LOG_MSG_PICTURE % path}
elif msgType == self.wx_conf['MSGTYPE_VOICE']:
data = self.webwxgetvoice(msgId)
fn = 'voice_' + msgId + '.mp3'
dir = self.save_data_folders['webwxgetvoice']
path = save_file(fn, data, dir)
raw_msg = {'raw_msg': msg,
'voice': path,
'log': Constant.LOG_MSG_VOICE % path}
elif msgType == self.wx_conf['MSGTYPE_SHARECARD']:
info = msg['RecommendInfo']
card = Constant.LOG_MSG_NAME_CARD % (
info['NickName'],
info['Alias'],
info['Province'], info['City'],
Constant.LOG_MSG_SEX_OPTION[info['Sex']]
)
namecard = '%s %s %s %s %s' % (
info['NickName'], info['Alias'], info['Province'],
info['City'], Constant.LOG_MSG_SEX_OPTION[info['Sex']]
)
raw_msg = {
'raw_msg': msg,
'namecard': namecard,
'log': card
}
elif msgType == self.wx_conf['MSGTYPE_EMOTICON']:
url = search_content('cdnurl', content)
raw_msg = {'raw_msg': msg,
'emoticon': url,
'log': Constant.LOG_MSG_EMOTION % url}
elif msgType == self.wx_conf['MSGTYPE_APP']:
card = ''
# 链接, 音乐, 微博
if msg['AppMsgType'] in [
self.wx_conf['APPMSGTYPE_AUDIO'],
self.wx_conf['APPMSGTYPE_URL'],
self.wx_conf['APPMSGTYPE_OPEN']
]:
card = Constant.LOG_MSG_APP_LINK % (
Constant.LOG_MSG_APP_LINK_TYPE[msg['AppMsgType']],
msg['FileName'],
search_content('des', content, 'xml'),
msg['Url'],
search_content('appname', content, 'xml')
)
raw_msg = {
'raw_msg': msg,
'link': msg['Url'],
'log': card
}
# 图片
elif msg['AppMsgType'] == self.wx_conf['APPMSGTYPE_IMG']:
#.........这里部分代码省略.........
示例2: echo
# 需要导入模块: from config import Log [as 别名]
# 或者: from config.Log import info [as 别名]
def echo(str):
Log.info(str[:-1])
sys.stdout.write(str)
sys.stdout.flush()
示例3: Plugin
# 需要导入模块: from config import Log [as 别名]
# 或者: from config.Log import info [as 别名]
#.........这里部分代码省略.........
def get(self):
'''
Get data from input queues.
'''
if not self._ins:
raise PluginExit()
gotData = False
for i,queue in enumerate(self._ins):
try:
data = queue.pop()
except IndexError:
continue
else:
if not data:
del self._ins[i]
continue
else:
if self.unique:
if data in self:
continue
else:
gotData = True
self._dataSet.append(data)
break
else:
gotData = True
break
if not gotData:
raise QueueEmpty()
else:
if self.log:
self.log.info("plugin '{0}' got model {1}".format(self.__class__.__name__, data))
return data
def put(self, data):
'''
Put data to output queue.
'''
if self.log:
self.log.info("plugin '{0}' put model {1}".format(self.__class__.__name__, data))
for queue in self._outs:
queue.insert(0,data)
def quit(self):
'''
Quit process. if the process finish a task, it sends an empty object.
'''
if self._outs:
self.put(Model())
def dostart(self, startData):
'''
Start plugins.
'''
for obj in self._addList:
if not obj._ins:
queue = RTD.taskManager.list()
for data in startData:
queue.insert(0,data)
queue.insert(0,Model())