fix exception
This commit is contained in:
parent
1b64189ac9
commit
91032c19c9
|
@ -2,7 +2,6 @@ import shutil
|
|||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
from PIL import Image
|
||||
from tqdm import tqdm
|
||||
|
||||
from pkg.proxies import PROXIES
|
||||
|
@ -23,7 +22,7 @@ def download_tile(task):
|
|||
output_path: Path = output / f"{row}_{col}.png"
|
||||
if output_path.exists():
|
||||
valid_png_file, image_type = is_png(output_path)
|
||||
if convert_to_png and image_type != 'PNG':
|
||||
if convert_to_png and image_type and image_type != 'PNG':
|
||||
# The image was read sucessfully by PIL but it's in the wrong format.
|
||||
convert(output_path)
|
||||
if not is_png(output_path):
|
||||
|
@ -59,6 +58,7 @@ def download_tile(task):
|
|||
print(f"Failed to download tile {row}_{col}")
|
||||
return row, col, 'failure'
|
||||
except Exception as e:
|
||||
# import traceback
|
||||
# traceback.print_exc()
|
||||
tqdm.write(f'Exception on {(row, col)} - {e.__class__.__name__}: {e}')
|
||||
return row, col, 'failure'
|
||||
|
|
Loading…
Reference in New Issue