From 299639f1e851893da815b5ce8c1c60930f63ed00 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Mon, 6 Nov 2023 18:55:43 -0700 Subject: [PATCH] add arg to skip download --- exfiltrate.py | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/exfiltrate.py b/exfiltrate.py index dbf6450..af0bc2e 100644 --- a/exfiltrate.py +++ b/exfiltrate.py @@ -25,6 +25,7 @@ if __name__ == '__main__': parser.add_argument('--tiff-threads', default=None, help='Number of threads to use when building TIFF. Default: auto') parser.add_argument('--output-tiff', help='Path for output GeoTIFF. Default: wmts-output/output.tiff') parser.add_argument('--bbox', required=True, type=str, metavar='Bounding Box', nargs='+', default=(None, None, None, None), help='Bounding Box of the area to download. Separate each value with a space. (top left lat, top left lon, bottom right lat, bottom right lon)') + parser.add_argument('--no-download', action='store_true', help="Don't do any downloading or image checking.") args = parser.parse_args() args.base_url = args.base_url.strip('/') + f'/{args.zoom}/' @@ -59,25 +60,29 @@ if __name__ == '__main__': for row in row_iter: row_i = row col_iter = range(min_col, max_col + 1) - col_bar = tqdm(total=len(col_iter), leave=False) - with (ThreadPoolExecutor(args.threads) as executor): - futures = [executor.submit(download_tile, (row, col, args.base_url, r_headers, tiles_output, args.proxy)) for col in col_iter] - for future in as_completed(futures): - result = future.result() - if result: - result_row, result_col, new_image = result - if new_image == 'success': - total_downloaded += 1 - tiles.append((result_row, result_col)) - elif new_image == 'exist': - tiles.append((result_row, result_col)) - elif new_image == 'failure': - retries.append((result_row, result_col)) - row_bar.set_postfix({'new_files': total_downloaded, 'failures': len(retries)}) - col_bar.update() - row_bar.refresh() - col_bar.close() - row_bar.set_postfix({'new_files': total_downloaded, 'failures': len(retries)}) + if args.no_download: + for col in col_iter: + tiles.append((row, col)) + else: + col_bar = tqdm(total=len(col_iter), leave=False) + with (ThreadPoolExecutor(args.threads) as executor): + futures = [executor.submit(download_tile, (row, col, args.base_url, r_headers, tiles_output, args.proxy)) for col in col_iter] + for future in as_completed(futures): + result = future.result() + if result: + result_row, result_col, new_image = result + if new_image == 'success': + total_downloaded += 1 + tiles.append((result_row, result_col)) + elif new_image == 'exist': + tiles.append((result_row, result_col)) + elif new_image == 'failure': + retries.append((result_row, result_col)) + row_bar.set_postfix({'new_files': total_downloaded, 'failures': len(retries)}) + col_bar.update() + row_bar.refresh() + col_bar.close() + row_bar.set_postfix({'new_files': total_downloaded, 'failures': len(retries)}) row_bar.update() row_bar.close()