MOD:add try catch
Showing
2 changed files
with
20 additions
and
15 deletions
... | @@ -179,5 +179,5 @@ class ECM(GenericView): | ... | @@ -179,5 +179,5 @@ class ECM(GenericView): |
179 | response = requests.post(self.search_url, headers=header_info, json=args, verify=False) | 179 | response = requests.post(self.search_url, headers=header_info, json=args, verify=False) |
180 | if response.status_code != 200: | 180 | if response.status_code != 200: |
181 | raise ECMException('ECM search failed with code: {0}'.format(response.status_code)) | 181 | raise ECMException('ECM search failed with code: {0}'.format(response.status_code)) |
182 | self.running_log.info("{0} search response.json():{1}".format(self.log_base, response.json())) | 182 | #self.running_log.info("{0} search response.json():{1}".format(self.log_base, response.json())) |
183 | return response.json() | 183 | return response.json() |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -1906,6 +1906,7 @@ class SearchGBHistoryFileView(GenericView): | ... | @@ -1906,6 +1906,7 @@ class SearchGBHistoryFileView(GenericView): |
1906 | ecm = ECM() | 1906 | ecm = ECM() |
1907 | response_json = ecm.search_doc_info_list(file_path, business_type) | 1907 | response_json = ecm.search_doc_info_list(file_path, business_type) |
1908 | data_objects = response_json['Envelope']['Body']['executeResponse']['return']['dataPackage']['DataObjects'] | 1908 | data_objects = response_json['Envelope']['Body']['executeResponse']['return']['dataPackage']['DataObjects'] |
1909 | self.running_log.info('[SearchGBHistoryFileView] [data_objects size={0}] '.format(len(data_objects))) | ||
1909 | for data_object in data_objects: | 1910 | for data_object in data_objects: |
1910 | object_id = data_object['Identity']['ObjectId']['@id'] | 1911 | object_id = data_object['Identity']['ObjectId']['@id'] |
1911 | properties_dict = {} | 1912 | properties_dict = {} |
... | @@ -1915,20 +1916,24 @@ class SearchGBHistoryFileView(GenericView): | ... | @@ -1915,20 +1916,24 @@ class SearchGBHistoryFileView(GenericView): |
1915 | value = prop.get('Value', 'null') # 如果Value为空,则输出null | 1916 | value = prop.get('Value', 'null') # 如果Value为空,则输出null |
1916 | properties_dict[name] = value | 1917 | properties_dict[name] = value |
1917 | self.running_log.info('[SearchGBHistoryFileView] [properties_dict={0}] '.format(properties_dict)) | 1918 | self.running_log.info('[SearchGBHistoryFileView] [properties_dict={0}] '.format(properties_dict)) |
1918 | gb_history_file_class.objects.create( | 1919 | |
1919 | object_id=object_id, | 1920 | try: |
1920 | object_name=properties_dict.get('object_name', ''), | 1921 | gb_history_file_class.objects.create( |
1921 | application_no=properties_dict.get('b_application_no', ''), | 1922 | object_id=object_id, |
1922 | object_type=properties_dict.get('r_object_type', ''), | 1923 | object_name=properties_dict.get('object_name', ''), |
1923 | customer_name=properties_dict.get('b_customer_name', ''), | 1924 | application_no=properties_dict.get('b_application_no', ''), |
1924 | content_size=properties_dict.get('r_content_size', ''), | 1925 | object_type='green_book', |
1925 | owner_name=properties_dict.get('owner_name', ''), | 1926 | customer_name=properties_dict.get('b_customer_name', ''), |
1926 | #input_date=properties_dict.get('b_input_date', ''), | 1927 | content_size=properties_dict.get('r_content_size', ''), |
1927 | #modify_date=properties_dict.get('r_modify_date', ''), | 1928 | owner_name=properties_dict.get('owner_name', ''), |
1928 | location=properties_dict.get('b_location', ''), | 1929 | #input_date=properties_dict.get('b_input_date', ''), |
1929 | download_finish=False | 1930 | #modify_date=properties_dict.get('r_modify_date', ''), |
1930 | ) | 1931 | location=properties_dict.get('b_location', ''), |
1931 | return response.ok(data=False) | 1932 | download_finish=False |
1933 | ) | ||
1934 | except Exception as e: | ||
1935 | self.exception_log.exception('[SearchGBHistoryFileView] [db save failed] [error={0}]'.format(traceback.format_exc())) | ||
1936 | return response.ok(data=True) | ||
1932 | 1937 | ||
1933 | class DownloadGBHistoryFileView(GenericView): | 1938 | class DownloadGBHistoryFileView(GenericView): |
1934 | permission_classes = [IsAuthenticated] | 1939 | permission_classes = [IsAuthenticated] | ... | ... |
-
Please register or sign in to post a comment