diff --git a/gramps/gen/const.py b/gramps/gen/const.py index 795f13359..8f214dcaa 100644 --- a/gramps/gen/const.py +++ b/gramps/gen/const.py @@ -93,7 +93,7 @@ if 'GRAMPSHOME' in os.environ: elif 'USERPROFILE' in os.environ: USER_HOME = get_env_var('USERPROFILE') if 'APPDATA' in os.environ: - HOME_DIR = os.path.join(os.environ['APPDATA'], 'gramps') + HOME_DIR = os.path.join(get_env_var('APPDATA'), 'gramps') else: HOME_DIR = os.path.join(USER_HOME, 'gramps') else: diff --git a/gramps/gen/db/write.py b/gramps/gen/db/write.py index a285928af..157be961b 100644 --- a/gramps/gen/db/write.py +++ b/gramps/gen/db/write.py @@ -2266,10 +2266,9 @@ def write_lock_file(name): os.mkdir(name) f = open(os.path.join(name, DBLOCKFN), "w") if win(): - user = os.environ['USERNAME'] - try: - host = os.environ['USERDOMAIN'] - except: + user = get_env_var('USERNAME') + host = get_env_var('USERDOMAIN') + if host == None: host = "" else: host = os.uname()[1] diff --git a/gramps/gen/utils/file.py b/gramps/gen/utils/file.py index 63a68d535..d7b082605 100644 --- a/gramps/gen/utils/file.py +++ b/gramps/gen/utils/file.py @@ -42,7 +42,7 @@ LOG = logging.getLogger(".gen.utils.file") # Gramps modules # #------------------------------------------------------------------------- -from ..constfunc import win, mac, cuni, conv_to_unicode, UNITYPE +from ..constfunc import win, mac, cuni, conv_to_unicode, UNITYPE, get_env_var from ..const import TEMP_DIR, USER_HOME, GRAMPS_LOCALE as glocale #------------------------------------------------------------------------- @@ -258,14 +258,14 @@ def search_for(name): else: name = name.split()[0] if win(): - for i in os.environ['PATH'].split(';'): + for i in get_env_var('PATH').split(';'): fname = os.path.join(i, name) if os.access(fname, os.X_OK) and not os.path.isdir(fname): return 1 if os.access(name, os.X_OK) and not os.path.isdir(name): return 1 - else: - for i in os.environ['PATH'].split(':'): + else: + for i in os.environ['PATH'].split(':'): #not win() fname = os.path.join(i, name) if os.access(fname, os.X_OK) and not os.path.isdir(fname): return 1