From d859076403de9b544936c767177e1703d8945b50 Mon Sep 17 00:00:00 2001 From: Neil Flood Date: Fri, 11 Apr 2025 15:33:45 +1000 Subject: [PATCH 1/2] Remove OpenJPEG test again, as it was not properly tested. Sigh.... --- processinghistory/tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/processinghistory/tests.py b/processinghistory/tests.py index 59245d3..7c89dd0 100755 --- a/processinghistory/tests.py +++ b/processinghistory/tests.py @@ -34,8 +34,7 @@ def makeRaster(filename, drvr='KEA', returnDS=False): # Test these drivers -driverList = [('KEA', 'kea'), ('HFA', 'img'), ('GTiff', 'tif'), - ('JP2OpenJPEG', 'jpg')] +driverList = [('KEA', 'kea'), ('HFA', 'img'), ('GTiff', 'tif')] # Remove any drivers not installed driverList = [dd for dd in driverList if gdal.GetDriverByName(dd[0]) is not None] From 6d370fd6ed8da43e904129f5be64edb656b87d26 Mon Sep 17 00:00:00 2001 From: Neil Flood Date: Fri, 11 Apr 2025 15:48:37 +1000 Subject: [PATCH 2/2] Implement configurable list of environment variables to auto-include --- README.md | 2 ++ processinghistory/history.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index f4a531e..6b20c2d 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ and several entries giving the various fields of the os.uname() return value. There is also an entry called `package_version_dict`, which contains a dictionary of version numbers for as many imported Python packages as it can find. So, for example, this will include the version number of numpy and osgeo (i.e. GDAL) which are imported at the time of execution. +If the environment variable `HISTORY_ENVVARS_TO_AUTOINCLUDE` is set, it will be taken to be a space-separated list of other environment variable names. For each of these names, if it is set, then that name/value pair will also be automatically included in the metadata dictionary. + ## Viewer A simple viewer called ``historyview`` is provided, to display the processing history to the console. Since the whole lineage can be quite large and complex, no attempt is made to display the whole thing at once. Rather, the metadata dictionary or the list of parents can be displayed, for either the main file itself, or for a nominated ancestor file within the lineage. diff --git a/processinghistory/history.py b/processinghistory/history.py index 0843e13..9f33c77 100644 --- a/processinghistory/history.py +++ b/processinghistory/history.py @@ -47,6 +47,7 @@ CURRENTFILE_KEY = "CURRENTFILE" METADATA_BY_KEY = "metadataByKey" PARENTS_BY_KEY = "parentsByKey" +AUTOENVVARSLIST_NAME = "HISTORY_ENVVARS_TO_AUTOINCLUDE" # These GDAL drivers are known to have limits on the size of metadata which # can be stored, and so we need to keep below these, or we lose everything. @@ -142,6 +143,16 @@ def makeAutomaticFields(): dictn['script_dir'] = os.path.dirname(script) dictn['commandline'] = ' '.join(sys.argv[1:]) + # If $ is set, it is a space-separated list of + # other environment variables which should be included. + autoEnvVars = os.getenv(AUTOENVVARSLIST_NAME) + if autoEnvVars is not None: + autoEnvVarsList = autoEnvVars.split() + for envVar in autoEnvVarsList: + val = os.getenv(envVar) + if val is not None: + dictn[envVar] = val + dictn['python_version'] = "{}.{}.{}".format(*sys.version_info) # Find version numbers of any external imported modules (if possible)