Fixes from checkers to work around missing user definitions

This commit is contained in:
Chris Jones 2011-05-03 17:49:00 +01:00
parent bf7b413487
commit ce0bedc3cf
2 changed files with 9 additions and 2 deletions

View File

@ -21,7 +21,10 @@ def get_default_cwd():
"""Determine a reasonable default cwd""" """Determine a reasonable default cwd"""
cwd = os.getcwd() cwd = os.getcwd()
if not os.path.exists(cwd) or not os.path.isdir(cwd): if not os.path.exists(cwd) or not os.path.isdir(cwd):
try:
cwd = pwd.getpwuid(os.getuid())[5] cwd = pwd.getpwuid(os.getuid())[5]
except KeyError:
cwd = '/'
return(cwd) return(cwd)

View File

@ -128,7 +128,11 @@ def path_lookup(command):
def shell_lookup(): def shell_lookup():
"""Find an appropriate shell for the user""" """Find an appropriate shell for the user"""
shells = [os.getenv('SHELL'), pwd.getpwuid(os.getuid())[6], 'bash', try:
usershell = pwd.getpwuid(os.getuid())[6]
except KeyError:
usershell = None
shells = [os.getenv('SHELL'), usershell, 'bash',
'zsh', 'tcsh', 'ksh', 'csh', 'sh'] 'zsh', 'tcsh', 'ksh', 'csh', 'sh']
for shell in shells: for shell in shells: