[Python-checkins] python/dist/src/Lib/idlelib configHandler.py, 1.35, 1.36

kbk at users.sourceforge.net kbk at users.sourceforge.net
Tue Jan 11 20:29:44 CET 2005


Update of /cvsroot/python/python/dist/src/Lib/idlelib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9898

Modified Files:
	configHandler.py 
Log Message:
Improve error handling when .idlerc can't be created.


Index: configHandler.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- configHandler.py	6 Jun 2004 01:29:22 -0000	1.35
+++ configHandler.py	11 Jan 2005 19:29:39 -0000	1.36
@@ -193,26 +193,28 @@
         """
         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,



More information about the Python-checkins mailing list