7258: Replace some os.environ['foo'] lookups missed earlier.

(cherry picked from commit 71650917bf)
This commit is contained in:
John Ralls 2014-03-27 11:32:37 -07:00
parent 50f514ce51
commit 15d1d0e6d0
3 changed files with 8 additions and 9 deletions

View File

@ -93,7 +93,7 @@ if 'GRAMPSHOME' in os.environ:
elif 'USERPROFILE' in os.environ: elif 'USERPROFILE' in os.environ:
USER_HOME = get_env_var('USERPROFILE') USER_HOME = get_env_var('USERPROFILE')
if 'APPDATA' in os.environ: 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: else:
HOME_DIR = os.path.join(USER_HOME, 'gramps') HOME_DIR = os.path.join(USER_HOME, 'gramps')
else: else:

View File

@ -2266,10 +2266,9 @@ def write_lock_file(name):
os.mkdir(name) os.mkdir(name)
f = open(os.path.join(name, DBLOCKFN), "w") f = open(os.path.join(name, DBLOCKFN), "w")
if win(): if win():
user = os.environ['USERNAME'] user = get_env_var('USERNAME')
try: host = get_env_var('USERDOMAIN')
host = os.environ['USERDOMAIN'] if host == None:
except:
host = "" host = ""
else: else:
host = os.uname()[1] host = os.uname()[1]

View File

@ -42,7 +42,7 @@ LOG = logging.getLogger(".gen.utils.file")
# Gramps modules # 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 from ..const import TEMP_DIR, USER_HOME, GRAMPS_LOCALE as glocale
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -258,14 +258,14 @@ def search_for(name):
else: else:
name = name.split()[0] name = name.split()[0]
if win(): if win():
for i in os.environ['PATH'].split(';'): for i in get_env_var('PATH').split(';'):
fname = os.path.join(i, name) fname = os.path.join(i, name)
if os.access(fname, os.X_OK) and not os.path.isdir(fname): if os.access(fname, os.X_OK) and not os.path.isdir(fname):
return 1 return 1
if os.access(name, os.X_OK) and not os.path.isdir(name): if os.access(name, os.X_OK) and not os.path.isdir(name):
return 1 return 1
else: else:
for i in os.environ['PATH'].split(':'): for i in os.environ['PATH'].split(':'): #not win()
fname = os.path.join(i, name) fname = os.path.join(i, name)
if os.access(fname, os.X_OK) and not os.path.isdir(fname): if os.access(fname, os.X_OK) and not os.path.isdir(fname):
return 1 return 1