diff --git a/py12306/helpers/OCR.py b/py12306/helpers/OCR.py index 1663b73..b376fa8 100644 --- a/py12306/helpers/OCR.py +++ b/py12306/helpers/OCR.py @@ -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): diff --git a/py12306/order/order.py b/py12306/order/order.py index f32560c..394498a 100644 --- a/py12306/order/order.py +++ b/py12306/order/order.py @@ -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') diff --git a/py12306/user/job.py b/py12306/user/job.py index 0ed7024..4600ed0 100644 --- a/py12306/user/job.py +++ b/py12306/user/job.py @@ -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()