Fixing a bug due to getlogin() in syntribos
The bug is due to the fact that sometimes when using os.getlogin(), Python is calling the system getlogin() function and returns a strerror "No such file or dir", thus failing to get the login name. Change-Id: I4156325d7435c69943b2bb736bd1ec7b4d060db4 Closes-Bug: #1640850
This commit is contained in:
parent
c9b2ddcec4
commit
a2f1d7c222
|
@ -14,6 +14,7 @@
|
|||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import pwd
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
|
@ -42,7 +43,13 @@ def get_user_home_root():
|
|||
global FOLDER
|
||||
user = os.environ.get("SUDO_USER")
|
||||
if not user:
|
||||
user = os.getlogin() or os.environ.get("USER")
|
||||
try:
|
||||
user = os.environ.get("USER") or os.getlogin()
|
||||
except OSError as e:
|
||||
# Refer https://mail.python.org/pipermail/python-bugs-list/
|
||||
# 2002-July/012691.html
|
||||
LOG.error("Exception thrown in : {}".format(e))
|
||||
user = pwd.getpwuid(os.getuid())[0]
|
||||
home_path = "~{0}/{1}".format(user, FOLDER)
|
||||
return expand_path(home_path)
|
||||
|
||||
|
@ -62,6 +69,7 @@ def get_venv_root():
|
|||
|
||||
def get_syntribos_root():
|
||||
"""This determines the proper path to use as syntribos' root directory."""
|
||||
path = ""
|
||||
custom_root = CONF.syntribos.custom_root
|
||||
|
||||
if custom_root:
|
||||
|
|
Loading…
Reference in New Issue