diff --git a/lib/__init__.py b/lib/__init__.py index 9d87973..486d484 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -1,9 +1,9 @@ #!/usr/bin/env python -# Located in improc/ortho/lib/ - """ PGC image processing utils and classes """ +from .version import __version__, VERSION + diff --git a/lib/ortho_functions.py b/lib/ortho_functions.py index 09c147b..1d3afa5 100644 --- a/lib/ortho_functions.py +++ b/lib/ortho_functions.py @@ -15,6 +15,7 @@ from osgeo import gdal, gdalconst, ogr, osr from lib import taskhandler, utils +from lib import VERSION #### Create Loggers logger = logging.getLogger("logger") @@ -320,7 +321,7 @@ def buildParentArgumentParser(): '--pbs/--slurm will only accept 1 thread.' .format(ARGDEF_THREADS, ARGDEF_CPUS_AVAIL), default=ARGDEF_THREADS) - parser.add_argument("--version", action='version', version="imagery_utils v{}".format(utils.package_version)) + parser.add_argument("--version", action='version', version="imagery_utils v{}".format(VERSION)) return parser, pos_arg_keys @@ -1445,7 +1446,7 @@ def WriteOutputMetadata(args, info): #### Determine custom MD dMD = {} - dMD["VERSION"] = "imagery_utils v{}".format(utils.package_version) + dMD["VERSION"] = "imagery_utils v{}".format(VERSION) tm = datetime.today() dMD["PROCESS_DATE"] = tm.strftime("%d-%b-%Y %H:%M:%S") if not args.skip_warp: diff --git a/lib/utils.py b/lib/utils.py index 569ff4e..853987f 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -26,9 +26,6 @@ logger = logging.getLogger("logger") logger.setLevel(logging.DEBUG) -package_version = '1.5.7' - - @contextlib.contextmanager def capture_stdout_stderr(): oldout, olderr = sys.stdout, sys.stderr diff --git a/lib/version.py b/lib/version.py new file mode 100644 index 0000000..cb995ee --- /dev/null +++ b/lib/version.py @@ -0,0 +1,3 @@ + +__version__ = (2, 0, 0) +VERSION = "{}.{}.{}".format(*__version__) \ No newline at end of file diff --git a/pgc_mosaic.py b/pgc_mosaic.py index b717608..7456cea 100755 --- a/pgc_mosaic.py +++ b/pgc_mosaic.py @@ -10,6 +10,8 @@ from osgeo import ogr, osr from lib import mosaic, taskhandler, utils +from lib import VERSION + ### Create Logger logger = logging.getLogger("logger") @@ -92,7 +94,7 @@ def main(): help="PBS resources requested (mimicks qsub syntax). Use only on HPC systems.") parser.add_argument("--log", help="file to log progress (default is \{}".format(default_logfile)) - parser.add_argument("--version", action='version', version="imagery_utils v{}".format(utils.package_version)) + parser.add_argument("--version", action='version', version="imagery_utils v{}".format(VERSION)) #### Parse Arguments diff --git a/pgc_mosaic_build_tile.py b/pgc_mosaic_build_tile.py index 5bff8a0..4185302 100755 --- a/pgc_mosaic_build_tile.py +++ b/pgc_mosaic_build_tile.py @@ -10,6 +10,7 @@ from osgeo import gdal from lib import mosaic, taskhandler, utils +from lib import VERSION logger = logging.getLogger("logger") logger.setLevel(logging.DEBUG) @@ -49,7 +50,7 @@ def main(): help="scratch space (default is mosaic directory)") parser.add_argument("--gtiff-compression", choices=mosaic.GTIFF_COMPRESSIONS, default="lzw", help="GTiff compression type. Default=lzw ({})".format(','.join(mosaic.GTIFF_COMPRESSIONS))) - parser.add_argument("--version", action='version', version="imagery_utils v{}".format(utils.package_version)) + parser.add_argument("--version", action='version', version="imagery_utils v{}".format(VERSION)) #### Parse Arguments diff --git a/pgc_mosaic_query_index.py b/pgc_mosaic_query_index.py index 21f5319..a4761ff 100755 --- a/pgc_mosaic_query_index.py +++ b/pgc_mosaic_query_index.py @@ -10,6 +10,7 @@ from osgeo import ogr, osr from lib import mosaic, ortho_functions, utils +from lib import VERSION ### Create Logger logger = logging.getLogger("logger") @@ -67,7 +68,7 @@ def main(): help="build shapefile of intersecting images (only invoked if --no_sort is not used)") parser.add_argument("--require-pan", action='store_true', default=False, help="limit search to imagery with both a multispectral and a panchromatic component") - parser.add_argument("--version", action='version', version="imagery_utils v{}".format(utils.package_version)) + parser.add_argument("--version", action='version', version="imagery_utils v{}".format(VERSION)) #### Parse Arguments diff --git a/pgc_ndvi.py b/pgc_ndvi.py index b5a7147..a81fa76 100755 --- a/pgc_ndvi.py +++ b/pgc_ndvi.py @@ -11,6 +11,7 @@ from osgeo import gdal from lib import ortho_functions, taskhandler, utils +from lib import VERSION #### Create Loggers logger = logging.getLogger("logger") @@ -47,7 +48,7 @@ def main(): parser.add_argument("-l", help="PBS resources requested (mimicks qsub syntax, PBS only)") parser.add_argument("--dryrun", action="store_true", default=False, help="print actions without executing") - parser.add_argument("--version", action='version', version="imagery_utils v{}".format(utils.package_version)) + parser.add_argument("--version", action='version', version="imagery_utils v{}".format(VERSION)) #### Parse Arguments diff --git a/tests/func_test_ortho.py b/tests/func_test_ortho.py index 334adff..d8ef631 100755 --- a/tests/func_test_ortho.py +++ b/tests/func_test_ortho.py @@ -22,11 +22,11 @@ def setUp(self): self.dstdir = os.path.join(script_dir, 'testdata', 'output') if platform.system() == 'Windows': - self.gimpdem = r'Y:\elevation\dem\GIMP\GIMPv2\gimpdem_v2_30m.tif' - self.rampdem = r'Y:\elevation\dem\RAMP\RAMPv2\RAMPv2_wgs84_200m.tif' + self.gimpdem = r'V:\pgc\data\elev\dem\gimp\GIMPv2\gimpdem_v2_30m.tif' + self.rampdem = r'V:\pgc\data\elev\dem\ramp\RAMPv2_wgs84_200m.tif' else: - self.gimpdem = '/mnt/agic/storage00/agic/private/elevation/dem/GIMP/GIMPv2/gimpdem_v2_30m.tif' - self.rampdem = '/mnt/agic/storage00/agic/private/elevation/dem/RAMP/RAMPv2/RAMPv2_wgs84_200m.tif' + self.gimpdem = '/mnt/pgc/data/elev/dem/gimp/GIMPv2/gimpdem_v2_30m.tif' + self.rampdem = '/mnt/pgc/data/elev/dem/ramp/RAMPv2_wgs84_200m.tif' # if os.path.isdir(self.dstdir): # shutil.rmtree(self.dstdir) @@ -63,6 +63,7 @@ def test_image_types(self): for test_image, epsg in test_images: srcfp = os.path.join(self.srcdir, test_image) + print(srcfp) cmd = r"""python "{}" -r 10 -p {} "{}" "{}" """.format(self.scriptpath, epsg, srcfp, self.dstdir) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) se, so = p.communicate() diff --git a/tests/unit_test_ortho_functions.py b/tests/unit_test_ortho_functions.py index e5e2a9e..97f4364 100755 --- a/tests/unit_test_ortho_functions.py +++ b/tests/unit_test_ortho_functions.py @@ -8,6 +8,7 @@ sys.path.append(root_dir) from lib import ortho_functions, utils +from lib import VERSION #logger = logging.getLogger("logger") # lso = logging.StreamHandler() @@ -203,7 +204,7 @@ def setUp(self): '4326', 'GTiff', 'rf', - 'imagery_utils v{}'.format(utils.package_version), + 'imagery_utils v{}'.format(VERSION), '2568.0', 'near' ]