From b73f217b814bf754d0348791982a09587603cba0 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 31 Mar 2021 16:06:10 -0400 Subject: [PATCH] BF: Don't fail if etelemetry.get_project returns None main.workflow() crashes with a TypeError when logging the latest version if "NO_ET" is in os.environ because etelemetry.get_project() returns None. Guard against this failure as well the KeyError that would be triggered if get_project(), for whatever reason, returns a dictionary without a "version" key. --- heudiconv/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heudiconv/main.py b/heudiconv/main.py index c9e8ac4c..8b65f45e 100644 --- a/heudiconv/main.py +++ b/heudiconv/main.py @@ -252,16 +252,16 @@ def workflow(*, dicom_dir_template=None, files=None, subjs=None, outdir = op.abspath(outdir) + latest = None try: import etelemetry latest = etelemetry.get_project("nipy/heudiconv") except Exception as e: lgr.warning("Could not check for version updates: %s", str(e)) - latest = {"version": 'Unknown'} lgr.info(INIT_MSG(packname=__packagename__, version=__version__, - latest=latest["version"])) + latest=(latest or {}).get("version", "Unknown"))) if command: process_extra_commands(outdir, command, files, dicom_dir_template,