def process_data(self, req_json, resp_json):
command = req_json.get('command')
if command in self.accepted_commands:
accepted_data = self.accepted_commands[command]
result_data = {}
if 'request' in accepted_data:
result_data['request'] = {item: req_json.get(item) for item in accepted_data['request']}
if 'response' in accepted_data:
result_data['response'] = {item: resp_json.get(item) for item in accepted_data['response']}
if result_data:
data = json.dumps(result_data)
try:
resp = urllib2.urlopen(self.log_url, data=urllib.urlencode({'data': data}))
except urllib2.HTTPError as e:
logger.warn('SwarfarmLogger - Error: {}'.format(e.readline()))
else:
resp.close()
logger.info('SwarfarmLogger - {} logged successfully'.format(command))
评论列表
文章目录