diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2005-01-11 19:29:39 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2005-01-11 19:29:39 (GMT) |
commit | 1b6f398c987f3078fc7732e1935e12c6b3712027 (patch) | |
tree | 81000f2b793bb4be783f52c6f4d10cc962098a07 /Lib/idlelib | |
parent | d4f5b07e5d8cb4d3c8d0da07858738b63c7c00c2 (diff) | |
download | cpython-1b6f398c987f3078fc7732e1935e12c6b3712027.zip cpython-1b6f398c987f3078fc7732e1935e12c6b3712027.tar.gz cpython-1b6f398c987f3078fc7732e1935e12c6b3712027.tar.bz2 |
Improve error handling when .idlerc can't be created.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/configHandler.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py index 370f370..d13f1e4 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/configHandler.py @@ -193,26 +193,28 @@ class IdleConf: """ Creates (if required) and returns a filesystem directory for storing user config files. + """ - cfgDir='.idlerc' - userDir=os.path.expanduser('~') - if userDir != '~': #'HOME' exists as a key in os.environ + cfgDir = '.idlerc' + userDir = os.path.expanduser('~') + if userDir != '~': # expanduser() found user home dir if not os.path.exists(userDir): - warn=('\n Warning: HOME environment variable points to\n '+ - userDir+'\n but the path does not exist.\n') + warn = ('\n Warning: os.path.expanduser("~") points to\n '+ + userDir+',\n but the path does not exist.\n') sys.stderr.write(warn) - userDir='~' - if userDir=='~': #we still don't have a home directory - #traditionally idle has defaulted to os.getcwd(), is this adeqate? - userDir = os.getcwd() #hack for no real homedir - userDir=os.path.join(userDir,cfgDir) + userDir = '~' + if userDir == "~": # still no path to home! + # traditionally IDLE has defaulted to os.getcwd(), is this adequate? + userDir = os.getcwd() + userDir = os.path.join(userDir, cfgDir) if not os.path.exists(userDir): - try: #make the config dir if it doesn't exist yet + try: os.mkdir(userDir) - except IOError: - warn=('\n Warning: unable to create user config directory\n '+ - userDir+'\n') + except (OSError, IOError): + warn = ('\n Warning: unable to create user config directory\n'+ + userDir+'\n Check path and permissions.\n Exiting!\n\n') sys.stderr.write(warn) + raise SystemExit return userDir def GetOption(self, configType, section, option, default=None, type=None, |