mirror of
https://codeberg.org/matkoniecz/list_how_openstreetmap_can_be_improved_with_alltheplaces_data.git
synced 2025-05-13 05:03:09 +02:00
fix bunch of bugs noticed on actual code use
This commit is contained in:
parent
8c59d5537f
commit
73cca0d9a5
1 changed files with 12 additions and 4 deletions
|
@ -35,21 +35,27 @@ def latest_atp_unpacked_folder():
|
|||
for entry in get_atp_history()[::-1]:
|
||||
run_id = entry['run_id']
|
||||
candidate = atp_unpacked_folder(run_id)
|
||||
if os.path.isdir() == True:
|
||||
if os.path.isdir(candidate) == True:
|
||||
return candidate
|
||||
|
||||
def atp_unpacked_folder(run_id):
|
||||
def atp_folder_root(run_id):
|
||||
return config.atp_cache_folder() + run_id + "/"
|
||||
|
||||
def atp_unpacked_folder(run_id):
|
||||
return atp_folder_root(run_id) + "output/"
|
||||
|
||||
def download_latest_atp_dataset():
|
||||
response = get_atp_latest()
|
||||
run_id = response['run_id']
|
||||
download_specific_atp_run(run_id)
|
||||
|
||||
def download_specific_atp_run(run_id):
|
||||
folder_path = config.atp_cache_folder() + "/" + run_id + "/"
|
||||
folder_path = atp_folder_root(run_id)
|
||||
success_marker = folder_path + "atp_download_completed.success"
|
||||
|
||||
if os.path.isfile(success_marker) == True:
|
||||
return # done already
|
||||
|
||||
if os.path.isfile(success_marker) == False:
|
||||
if os.path.isdir(folder_path) == True:
|
||||
raise Exception(folder_path + " is in inconsistent state")
|
||||
|
@ -60,7 +66,9 @@ def download_specific_atp_run(run_id):
|
|||
download_url = "https://alltheplaces-data.openaddresses.io/runs/" + run_id + "/output.zip"
|
||||
filename = "entire_atp.zip"
|
||||
osm_bot_abstraction_layer.util_download_file.download_file_if_not_present_already(download_url, folder_path, filename)
|
||||
os.system('unzip "' + config.atp_cache_folder() + filename + '" -d "' + config.atp_cache_folder() + '"')
|
||||
os.system('unzip "' + folder_path + filename + '" -d "' + folder_path + '"')
|
||||
with open(success_marker, "w") as myfile:
|
||||
myfile.write("data prepared")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue