d8927266 by 周伟奇

fix bug

1 parent e01e2f43
......@@ -22,7 +22,7 @@ class CMS:
self.token_type_key = 'token_type'
def update_token(self):
response = requests.post(self.oauth_url, data=self.oauth_payload, files=[])
response = requests.post(self.oauth_url, data=self.oauth_payload, files=[], verify=False)
if response.status_code != 200:
raise CMSException('CMS Oauth response with code: {0}'.format(response.status_code))
token = response.json().get(self.token_key)
......@@ -46,7 +46,7 @@ class CMS:
'Authorization': '{0} {1}'.format(self.token_type.capitalize(), token),
'Content-Type': 'application/json',
}
response = requests.post(self.url, headers=headers, json=payload)
response = requests.post(self.url, headers=headers, json=payload, verify=False)
if response.status_code != 200:
raise CMSException('CMS Oauth response with code: {0}'.format(response.status_code))
return response.json()
......
......@@ -823,7 +823,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
vehicle_status = cms_info.get('vehicleStatus', '')
first_submmison_date = cms_info.get('submissionDate', '')
vin_no = cms_info.get('vehicleInformation', {}).get('vinNo', '')
amount = str(cms_info.get('totalFinanceAmount', ''))
amount = str(cms_info.get('financialInformation', {}).get('vehiclePrice', ''))
if vehicle_status == 'New':
vehicle_field_input.append(('vinNo', vin_no))
vehicle_field_input.append(('dealer', cms_info.get('dealerName', '')))
......@@ -901,7 +901,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
bank_info[consts.DDA_EN] = dda_field_input
compare_info['bankInfo'] = bank_info
if not detect_list[2]:
if cms_info.get('mortgageType', '') == 'Mortgage Free':
other_info = {}
hmh_field_input = [
(consts.SE_HMH_FIELD[0], hmh_name),
......@@ -1399,8 +1399,14 @@ def se_compare_process(compare_info, ocr_res_dict):
for idx, license_list in info_value.items():
for license_dict in license_list:
for license_en, field_list in license_dict.items():
strip_list = []
for a, b in field_list:
if isinstance(b, str):
strip_list.append((a, b.strip()))
else:
strip_list.append((a, b))
failure_field = []
result_field_list, no_ocr_result = se_compare_license(license_en, ocr_res_dict, field_list)
result_field_list, no_ocr_result = se_compare_license(license_en, ocr_res_dict, strip_list)
for name, value, result, ocr_str, img_path, error_type in result_field_list:
if license_en not in consts.SKIP_CARD or not no_ocr_result:
total_fields += 1
......@@ -1426,11 +1432,17 @@ def se_compare_process(compare_info, ocr_res_dict):
failure_reason.setdefault(info_key, []).append(';'.join(failure_field))
else:
for license_en, field_list in info_value.items():
strip_list = []
for a, b in field_list:
if isinstance(b, str):
strip_list.append((a, b.strip()))
else:
strip_list.append((a, b))
failure_field = []
if license_en == consts.MVC34_EN:
result_field_list = se_mvc34_compare(license_en, ocr_res_dict, field_list)
result_field_list = se_mvc34_compare(license_en, ocr_res_dict, strip_list)
else:
result_field_list, _ = se_compare_license(license_en, ocr_res_dict, field_list)
result_field_list, _ = se_compare_license(license_en, ocr_res_dict, strip_list)
for name, value, result, ocr_str, img_path, error_type in result_field_list:
total_fields += 1
if result == consts.RESULT_N:
......@@ -1505,7 +1517,8 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
res_obj.compare_count = total_fields
res_obj.failed_count = failed_count
res_obj.is_finish = successful_at_this_level
res_obj.version = '{0}{1}{2}'.format(consts.INFO_SOURCE[0], consts.SPLIT_STR, application_version)
source = consts.INFO_SOURCE[1] if is_cms else consts.INFO_SOURCE[0]
res_obj.version = '{0}{1}{2}'.format(source, consts.SPLIT_STR, application_version)
# res_obj.reason1_count = reason1_count
res_obj.result = json.dumps(compare_result)
res_obj.update_time = datetime.now()
......
......@@ -44,11 +44,17 @@ def encode_des(to_encode_str, des_key):
def un_des_pad(data):
result_byte = data[0:4]
e = struct.unpack('>I', result_byte)[0]
x = (e + 4) % 8
y = 0 if x == 0 else 8 - x
return data[4:] if y == 0 else data[4:-y]
# print(data)
# result_byte = data[0:4]
# print(result_byte)
# e = struct.unpack('>I', result_byte)[0]
# x = (e + 4) % 8
# y = 0 if x == 0 else 8 - x
# print(y)
# return data[:-4] if y == 0 else data[:-y]
offset = data[-1]
return data[:-offset]
def decode_des(to_decode_str, des_key):
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!