Catch any exception when trying to call "git"

Some projects (like Neutron) do import eventlet in docs/source/conf.py
. eventlet patches the subprocess module and due to that, the
submodule.CalledProcessError exception is not caught. So building the
documentation from an sdist tarball with having git installed (this
combination is common in package build envs like RDO) fails with:

subprocess.CalledProcessError: Command '['git', 'log', '-n1', \
  '--format=%ad', [...snipped...]

Change-Id: Ibff93605996855f01ba2bbe793285674b5c71d2e
This commit is contained in:
Thomas Bechtold 2019-08-22 06:55:15 +02:00
parent ceb0abfd6e
commit 7aaba6f9f5

View File

@ -35,7 +35,11 @@ def _get_last_updated_file(src_file):
'--', src_file,
]
).decode('utf-8').strip()
except (subprocess.CalledProcessError, OSError) as err:
# NOTE: we catch any exception here (instead of
# subprocess.CalledProcessError and OSError) because some projects (eg.
# neutron) do import eventlet in docs/source/conf.py which will patch
# the subprocess module and with that, the exception is not catched
except Exception as err:
LOG.info(
'[openstackdocstheme] Could not get modification time of %s: %s',
src_file, err)