Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
11 changes: 11 additions & 0 deletions processinghistory/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -142,6 +143,16 @@ def makeAutomaticFields():
dictn['script_dir'] = os.path.dirname(script)
dictn['commandline'] = ' '.join(sys.argv[1:])

# If $<AUTOENVVARSLIST_NAME> 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)
Expand Down
3 changes: 1 addition & 2 deletions processinghistory/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
Loading