Merge pull request #81 from mattrose/issue58
fix FileNotFound error when terminator is run from a directory that no longer exists
This commit is contained in:
commit
b800fbaea3
@ -25,12 +25,11 @@ except (ImportError):
|
||||
|
||||
def get_default_cwd():
|
||||
"""Determine a reasonable default cwd"""
|
||||
cwd = os.getcwd()
|
||||
if not os.path.exists(cwd) or not os.path.isdir(cwd):
|
||||
try:
|
||||
cwd = pwd.getpwuid(os.getuid())[5]
|
||||
except KeyError:
|
||||
cwd = '/'
|
||||
try:
|
||||
cwd = os.getcwd()
|
||||
except (FileNotFoundError,OSError):
|
||||
err("unable to set current working directory, does not exist")
|
||||
cwd = '/'
|
||||
|
||||
return(cwd)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user