优化错误输出

This commit is contained in:
Jalin
2019-01-16 21:18:57 +08:00
parent 033c34e035
commit d4e1ef1049
3 changed files with 6 additions and 5 deletions

View File

@@ -37,7 +37,7 @@ class OCR:
result = rc.rk_create(img, 6113)
if "Result" in result:
return self.get_image_position_by_offset(list(result['Result']))
CommonLog.print_auto_code_fail(result.get("Error", '-'))
CommonLog.print_auto_code_fail(result.get("Error", CommonLog.MESSAGE_RESPONSE_EMPTY_ERROR))
return None
def get_image_position_by_offset(self, offsets):

View File

@@ -127,7 +127,7 @@ class Order:
if (str(result.get('messages', '')).find('未处理') >= 0): # 未处理订单
stay_second(self.retry_time)
OrderLog.add_quick_log(
OrderLog.MESSAGE_SUBMIT_ORDER_REQUEST_FAIL.format(result.get('messages', '-'))).flush()
OrderLog.MESSAGE_SUBMIT_ORDER_REQUEST_FAIL.format(result.get('messages', CommonLog.MESSAGE_RESPONSE_EMPTY_ERROR))).flush()
return False
def check_order_info(self):
@@ -166,7 +166,7 @@ class Order:
else:
error = CommonLog.MESSAGE_API_RESPONSE_CAN_NOT_BE_HANDLE
if not result.get('data.isNoActive'):
error = result.get('data.errMsg')
error = result.get('data.errMsg', CommonLog.MESSAGE_RESPONSE_EMPTY_ERROR)
else:
if result.get('data.checkSeatNum'):
error = '无法提交您的订单! ' + result.get('data.errMsg')

View File

@@ -13,6 +13,7 @@ from py12306.helpers.request import Request
from py12306.helpers.type import UserType
from py12306.log.order_log import OrderLog
from py12306.log.user_log import UserLog
from py12306.log.common_log import CommonLog
class UserJob:
@@ -149,7 +150,7 @@ class UserJob:
UserLog.add_quick_log(UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message'))).flush()
else:
UserLog.add_quick_log(
UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message', result.get('message', '-')))).flush()
UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message', result.get('message', CommonLog.MESSAGE_RESPONSE_EMPTY_ERROR)))).flush()
return False
@@ -306,7 +307,7 @@ class UserJob:
return self.passengers
else:
UserLog.add_quick_log(
UserLog.MESSAGE_GET_USER_PASSENGERS_FAIL.format(result.get('messages', '-'), self.retry_time)).flush()
UserLog.MESSAGE_GET_USER_PASSENGERS_FAIL.format(result.get('messages', CommonLog.MESSAGE_RESPONSE_EMPTY_ERROR), self.retry_time)).flush()
stay_second(self.retry_time)
return self.get_user_passengers()