Skip to content

Commit

Permalink
note HTTP_PROXY in error messages and reraise URLError
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanathan committed May 28, 2019
1 parent 6fc2f26 commit 3c2a43d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions epitator/importers/import_disease_ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ def import_disease_ontology(drop_previous=False, root_uri=None):
try:
disease_ontology.parse(DISEASE_ONTOLOGY_URL, format="xml")
except URLError as e:
print(e)
print("You might be operating behind a proxy. Try adopting your proxy settings.")
return
print("If you are operating behind a firewall, try setting the HTTP_PROXY/HTTPS_PROXY environment variables.")
raise

# Store disease ontology version
version_query = disease_ontology.query("""
Expand Down
5 changes: 2 additions & 3 deletions epitator/importers/import_geonames.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ def read_geonames_csv():
try:
url = request.urlopen(GEONAMES_ZIP_URL)
except URLError as e:
print(e)
print("You might be operating behind a proxy. Try adopting your proxy settings.")
return
print("If you are operating behind a firewall, try setting the HTTP_PROXY/HTTPS_PROXY environment variables.")
raise
zipfile = ZipFile(BytesIO(url.read()))
print("Download complete")
# Loading geonames data may cause errors without this line:
Expand Down
4 changes: 2 additions & 2 deletions epitator/importers/import_species.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def download_itis_database():
try:
url = request.urlopen(ITIS_URL)
except URLError:
print("You might be operating behind a proxy. Try adopting your proxy settings.")
sys.exit(1)
print("If you are operating behind a firewall, try setting the HTTP_PROXY/HTTPS_PROXY environment variables.")
raise
zipfile = ZipFile(BytesIO(url.read(int(url.headers['content-length']))))
print("Download complete")
named_temp_file = NamedTemporaryFile()
Expand Down
5 changes: 2 additions & 3 deletions epitator/importers/import_wikidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ def import_wikidata(drop_previous=False):
"""
})))
except URLError as e:
print(e)
print("You might be operating behind a proxy. Try adopting your proxy settings.")
return
print("If you are operating behind a firewall, try setting the HTTP_PROXY/HTTPS_PROXY environment variables.")
raise
results = json.loads(response.read())['results']['bindings']
print("Importing synonyms...")
cur.executemany("INSERT INTO entities VALUES (?, ?, 'disease', 'Wikidata')", [
Expand Down

0 comments on commit 3c2a43d

Please sign in to comment.