Fix VALIDATIONS_LOG_BASEDIR constant when $HOME is undefined

When $HOME environment variable is not defined below definition
raises TypeError:

  VALIDATIONS_LOG_BASEDIR = os.path.join(os.environ.get('HOME'), 'validations')

This replaces it by using os.path.expanduser[1] function

  VALIDATIONS_LOG_BASEDIR = os.path.expanduser('~/validations')

This issue has been detected by Tobiko CI jobs [2]:

 validations_libs/constants.py:25: in <module>
    VALIDATIONS_LOG_BASEDIR = os.path.join(os.environ.get('HOME'), 'validations')
 posixpath.py:76: in join
    a = os.fspath(a)
E   TypeError: expected str, bytes or os.PathLike object, not NoneType

[1] https://docs.python.org/3.6/library/os.path.html#os.path.expanduser
[2] https://813cfae3a1563ccfbfb3-c77d7211b8c124ad183202888cc1ebe6.ssl.cf5.rackcdn.com/796831/4/check/devstack-tobiko-gate/67bcea8/tobiko_results_04_faults_faults.html

Change-Id: I13ba1b2eb0b11c2aded35b44c7fbae643210a269
This commit is contained in:
Federico Ressi 2021-06-18 10:51:49 +02:00
parent 4d1df7b0e7
commit 0a7a45f905

View File

@ -22,7 +22,8 @@ VALIDATION_GROUPS_INFO = os.path.join(
DEFAULT_VALIDATIONS_BASEDIR,
'groups.yaml')
VALIDATIONS_LOG_BASEDIR = os.path.join(os.environ.get('HOME'), 'validations')
# NOTE(fressi) The HOME folder environment variable may be undefined.
VALIDATIONS_LOG_BASEDIR = os.path.expanduser('~/validations')
VALIDATION_ANSIBLE_ARTIFACT_PATH = os.path.join(
VALIDATIONS_LOG_BASEDIR,