Skip to content

Commit

Permalink
IncompleteRead exception really managed
Browse files Browse the repository at this point in the history
  • Loading branch information
metalbobinou authored Aug 10, 2023
1 parent 457501e commit 4e9c0ef
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/2-Get_Ark_ID.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ def get_ressource_url(url):
url_new = response.url
headers = response.headers
status = response.status
except Exception as e:
print("--- UNKNOWN ERROR WHILE READING HTTP RESPONSE: ---")
except http.client.IncompleteRead as e:
print("--- ERROR : INCOMPLETE HTTP RESPONSE ---")
print(str(e))
print("#############")
logging.error(traceback.format_exc())
Expand Down
18 changes: 13 additions & 5 deletions src/2bis-Get_Ark_ID_NO_BS4.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,19 @@ def get_ressource_url(url):
else:
print("OK")

data = response.read()
url_new = response.url
headers = response.headers
status = response.status
#text = data.decode(info.get_param('charset', 'utf-8'))
# Read the HTTP response
try:
data = response.read()
url_new = response.url
headers = response.headers
status = response.status
#text = data.decode(info.get_param('charset', 'utf-8'))
except http.client.IncompleteRead as e:
print("--- ERROR : INCOMPLETE HTTP RESPONSE ---")
print(str(e))
print("#############")
logging.error(traceback.format_exc())
return (None)

print("## url_new : " + str(url_new))
print("## headers : " + str(headers))
Expand Down
4 changes: 2 additions & 2 deletions src/4-Download_Date_to_JPEG.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def get_document_debat_parlementaire(ark_id, directory_output, filename_prefix):
url_new = response.url
headers = response.headers
status = response.status
except Exception as e:
print("--- UNKNOWN ERROR WHILE READING HTTP RESPONSE: ---")
except http.client.IncompleteRead as e:
print("--- ERROR : INCOMPLETE HTTP RESPONSE ---")
print(str(e))
print("#############")
logging.error(traceback.format_exc())
Expand Down
4 changes: 2 additions & 2 deletions src/4-Download_Date_to_PDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def get_document_PDF_debat_parlementaire(ark_id, directory_output, filename_pref
url_new = response.url
headers = response.headers
status = response.status
except Exception as e:
print("--- UNKNOWN ERROR WHILE READING HTTP RESPONSE: ---")
except http.client.IncompleteRead as e:
print("--- ERROR : INCOMPLETE HTTP RESPONSE ---")
print(str(e))
print("#############")
logging.error(traceback.format_exc())
Expand Down

0 comments on commit 4e9c0ef

Please sign in to comment.