From ce0bedc3cf7db3eadb59862be62bf928a615b5ca Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 3 May 2011 17:49:00 +0100 Subject: [PATCH] Fixes from checkers to work around missing user definitions --- terminatorlib/cwd.py | 5 ++++- terminatorlib/util.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/terminatorlib/cwd.py b/terminatorlib/cwd.py index a6877b4d..7b17d84b 100755 --- a/terminatorlib/cwd.py +++ b/terminatorlib/cwd.py @@ -21,7 +21,10 @@ def get_default_cwd(): """Determine a reasonable default cwd""" cwd = os.getcwd() if not os.path.exists(cwd) or not os.path.isdir(cwd): - cwd = pwd.getpwuid(os.getuid())[5] + try: + cwd = pwd.getpwuid(os.getuid())[5] + except KeyError: + cwd = '/' return(cwd) diff --git a/terminatorlib/util.py b/terminatorlib/util.py index 872b76d0..02d7e9e6 100755 --- a/terminatorlib/util.py +++ b/terminatorlib/util.py @@ -128,7 +128,11 @@ def path_lookup(command): def shell_lookup(): """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'] for shell in shells: