Skip to content

Commit

Permalink
add error handling to geofabrik download calls
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoll1 committed Aug 31, 2024
1 parent 82a4c8e commit 2d46a79
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions osmand_osm/osm/osm_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from subprocess import run
from subprocess import run, CalledProcessError
import hashlib
import logging
import json
Expand Down Expand Up @@ -46,8 +46,14 @@ def update_osm(self, working_area):
'''
logging.info(f'{working_area.name} updating OSM data')
url = self.geofabrik_lookup(working_area)
run(f'curl --output {self.pbf} {url}', shell=True, capture_output=True, encoding='utf8')
run(f'curl --output {self.pbf_md5} {url}.md5', shell=True, capture_output=True, encoding='utf8')
try:
run(f'curl --output {self.pbf} {url}', shell=True, capture_output=True, check=True, encoding='utf8')
except CalledProcessError as error:
logging.error(f'{working_area.name} osm data download error {error.stderr}')
try:
run(f'curl --output {self.pbf_md5} {url}.md5', shell=True, capture_output=True, check=True, encoding='utf8')
except CalledProcessError as error:
logging.error(f'{working_area.name} osm data md5 download error {error.stderr}')
# pull md5 hash from file
with open(self.pbf_md5) as md5:
md5 = md5.read()
Expand Down

0 comments on commit 2d46a79

Please sign in to comment.