diff --git a/planetutils/elevation_tile_download.py b/planetutils/elevation_tile_download.py index a54667a..29328b4 100644 --- a/planetutils/elevation_tile_download.py +++ b/planetutils/elevation_tile_download.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, unicode_literals, print_function import argparse import sys @@ -26,7 +26,7 @@ def main(): elif args.format == 'skadi': p = ElevationSkadiDownloader(args.outpath) else: - print "Unknown format: %s"%args.format + print("Unknown format: %s"%args.format) sys.exit(1) if args.csv: diff --git a/planetutils/elevation_tile_downloader.py b/planetutils/elevation_tile_downloader.py index 1e70d45..c03613e 100644 --- a/planetutils/elevation_tile_downloader.py +++ b/planetutils/elevation_tile_downloader.py @@ -87,7 +87,7 @@ def get_bbox_tiles(self, bbox): return tiles def tile_path(self, z, x, y): - return map(str, [z, x, str(y)+'.tif']) + return list(map(str, [z, x, str(y)+'.tif'])) class ElevationSkadiDownloader(ElevationDownloader): HGT_SIZE = (3601 * 3601 * 2) diff --git a/planetutils/elevation_tile_merge.py b/planetutils/elevation_tile_merge.py index 5a6bbfe..ee169b1 100644 --- a/planetutils/elevation_tile_merge.py +++ b/planetutils/elevation_tile_merge.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, unicode_literals, print_function import argparse import sys import fnmatch @@ -20,7 +20,7 @@ def main(): tmppath = args.outpath if args.scale and len(args.scale.split(',')) != 2: - print "Must provide min, max values" + print("Must provide min, max values") sys.exit(1) elif args.scale: # Output to tmp file @@ -32,22 +32,22 @@ def main(): matches.append(os.path.join(root, filename)) if len(matches) == 0: - print "No input files" + print("No input files") sys.exit(0) - print "Found %s files:"%len(matches) + print("Found %s files:"%len(matches)) for i in matches: - print "\t%s"%(i) + print("\t%s"%(i)) # gdal_merge.py -init 0 -o out.tif - print "Merging... %s"%(tmppath) + print("Merging... %s"%(tmppath)) cmd = ['gdal_merge.py', '-init', '0', '-o', tmppath] cmd += matches p = subprocess.check_call(cmd) # gdal_translate -of GTiff -ot Byte -scale 0 255 0 255 out.tif out8.tif if args.scale: - print "Scaling: %s -> %s"%(tmppath, outpath) + print("Scaling: %s -> %s"%(tmppath, outpath)) a = args.scale.split(",") cmd = ['gdal_translate', '-of', 'GTiff', '-ot', 'Byte', '-scale', a[0], a[1], '0', '255', tmppath, outpath] subprocess.check_call(cmd) diff --git a/planetutils/tilepack_download.py b/planetutils/tilepack_download.py index 1c84195..a64bb75 100644 --- a/planetutils/tilepack_download.py +++ b/planetutils/tilepack_download.py @@ -4,7 +4,6 @@ import argparse from . import log -from . import tilepack from .bbox import bbox_string, load_bboxes_csv from .tilepack_downloader import TilepackDownloader diff --git a/planetutils/tilepack_downloader.py b/planetutils/tilepack_downloader.py index 10d136a..5821ca4 100644 --- a/planetutils/tilepack_downloader.py +++ b/planetutils/tilepack_downloader.py @@ -5,11 +5,9 @@ from urllib.request import urlopen import os -import urlparse import subprocess import json - from . import log from . import download diff --git a/tests/test_commands.py b/tests/test_commands.py new file mode 100644 index 0000000..48ee2ee --- /dev/null +++ b/tests/test_commands.py @@ -0,0 +1,21 @@ +from __future__ import absolute_import, unicode_literals +import tempfile +import types +import os +import unittest + +class TestCommandImports(unittest.TestCase): + def test_command_imports(self): + commands = [ + 'osm_planet_update=planetutils.osm_planet_update:main', + 'osm_planet_extract=planetutils.osm_planet_extract:main', + 'osm_planet_get_timestamp=planetutils.osm_planet_get_timestamp:main', + 'osm_extract_download=planetutils.osm_extract_download:main', + 'elevation_tile_download=planetutils.elevation_tile_download:main', + 'elevation_tile_merge=planetutils.elevation_tile_merge:main', + 'valhalla_tilepack_download=planetutils.tilepack_download:main', + 'valhalla_tilepack_list=planetutils.tilepack_list:main' + ] + for i in commands: + a, _, b = i.partition('=')[-1].partition(':') + exec('import %s'%(a))