Skip to content

Commit

Permalink
Improve and refactor prompt handler for preview image option
Browse files Browse the repository at this point in the history
  • Loading branch information
plant99 committed Jul 23, 2020
1 parent 5afcebc commit ca27534
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions felicette/sat_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
from felicette.constants import band_tag_map
from felicette.utils.file_manager import save_to_file, data_file_exists, file_paths_wrt_id

def handle_prompt_response(response):
if response in ["n", "N"]:
exit_cli("Why not try a different location next time? I'd suggest [link=https://en.wikipedia.org/wiki/Svalbard]Svalbard[/link] :)")
elif response in ["y", "Y", ""]:
return None
else:
exit_cli("[red]Sorry, invalid response. Exiting :([/red]")


def search_landsat_data(coordinates, cloud_cover_lt):
search = Search(
Expand Down Expand Up @@ -46,13 +54,8 @@ def preview_landsat_image(landsat_item):
rprint("[blue]Preview image saved at:[/blue]")
print(paths["preview"])
# prompt a confirm option
response = input("Are you sure you want to see an enhanced version of the image at the path shown above? [y/n]")
if response in ["n", "N"]:
exit_cli("Why not try a different location next time? I'd suggest [link=https://en.wikipedia.org/wiki/Svalbard]Svalbard[/link] :)")
elif response in ["y", "Y"]:
return None
else:
exit_cli("[red]Sorry, invalid response. Exiting :([/red]")
response = input("Are you sure you want to see an enhanced version of the image at the path shown above? [Y/n]")
return handle_prompt_response(response)

def download_landsat_data(landsat_item, bands=[2, 3, 4, 8]):

Expand Down

0 comments on commit ca27534

Please sign in to comment.