Commit d4e1ef10 authored by Jalin's avatar Jalin

优化错误输出

parent 033c34e0
...@@ -37,7 +37,7 @@ class OCR: ...@@ -37,7 +37,7 @@ class OCR:
result = rc.rk_create(img, 6113) result = rc.rk_create(img, 6113)
if "Result" in result: if "Result" in result:
return self.get_image_position_by_offset(list(result['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 return None
def get_image_position_by_offset(self, offsets): def get_image_position_by_offset(self, offsets):
......
...@@ -127,7 +127,7 @@ class Order: ...@@ -127,7 +127,7 @@ class Order:
if (str(result.get('messages', '')).find('未处理') >= 0): # 未处理订单 if (str(result.get('messages', '')).find('未处理') >= 0): # 未处理订单
stay_second(self.retry_time) stay_second(self.retry_time)
OrderLog.add_quick_log( 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 return False
def check_order_info(self): def check_order_info(self):
...@@ -166,7 +166,7 @@ class Order: ...@@ -166,7 +166,7 @@ class Order:
else: else:
error = CommonLog.MESSAGE_API_RESPONSE_CAN_NOT_BE_HANDLE error = CommonLog.MESSAGE_API_RESPONSE_CAN_NOT_BE_HANDLE
if not result.get('data.isNoActive'): if not result.get('data.isNoActive'):
error = result.get('data.errMsg') error = result.get('data.errMsg', CommonLog.MESSAGE_RESPONSE_EMPTY_ERROR)
else: else:
if result.get('data.checkSeatNum'): if result.get('data.checkSeatNum'):
error = '无法提交您的订单! ' + result.get('data.errMsg') error = '无法提交您的订单! ' + result.get('data.errMsg')
......
...@@ -13,6 +13,7 @@ from py12306.helpers.request import Request ...@@ -13,6 +13,7 @@ from py12306.helpers.request import Request
from py12306.helpers.type import UserType from py12306.helpers.type import UserType
from py12306.log.order_log import OrderLog from py12306.log.order_log import OrderLog
from py12306.log.user_log import UserLog from py12306.log.user_log import UserLog
from py12306.log.common_log import CommonLog
class UserJob: class UserJob:
...@@ -149,7 +150,7 @@ class UserJob: ...@@ -149,7 +150,7 @@ class UserJob:
UserLog.add_quick_log(UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message'))).flush() UserLog.add_quick_log(UserLog.MESSAGE_LOGIN_FAIL.format(result.get('result_message'))).flush()
else: else:
UserLog.add_quick_log( 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 return False
...@@ -306,7 +307,7 @@ class UserJob: ...@@ -306,7 +307,7 @@ class UserJob:
return self.passengers return self.passengers
else: else:
UserLog.add_quick_log( 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) stay_second(self.retry_time)
return self.get_user_passengers() return self.get_user_passengers()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment