Catch error if user is unknown
@@ -49,6 +49,11 @@ def get_run_env():
version = pkg_resources.get_distribution(PROJECT_CLIENT_NAME).version
except pkg_resources.DistributionNotFound:
version = ''
+ try:
+ user = getpass.getuser()
+ except Exception as e:
+ logger.debug('Could not detect installed packages, %s', e)
+ user = 'unknown'
return {
'pid': os.getpid(),
'hostname': socket.gethostname(),
@@ -56,7 +61,7 @@ def get_run_env():
'system': platform.system(),
'python_version_verbose': sys.version,
'python_version': platform.python_version(),
- 'user': getpass.getuser(),
+ 'user': user,
'client_version': version,
'sys.argv': sys.argv,
'is_notebook': is_notebook(),
