commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/gnue-common/gnue/common GConfig.py


From: Jason Cater
Subject: gnue/gnue-common/gnue/common GConfig.py
Date: Wed, 06 Jun 2001 15:45:08 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/06/06 15:45:08

Modified files:
        gnue-common/gnue/common: GConfig.py 

Log message:
        Added a convenience function, openResource, that handles opening a URL 
or file resource

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/gnue/common/GConfig.py.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gnue/gnue-common/gnue/common/GConfig.py
diff -u gnue/gnue-common/gnue/common/GConfig.py:1.1 
gnue/gnue-common/gnue/common/GConfig.py:1.2
--- gnue/gnue-common/gnue/common/GConfig.py:1.1 Mon Jun  4 20:23:39 2001
+++ gnue/gnue-common/gnue/common/GConfig.py     Wed Jun  6 15:45:08 2001
@@ -32,8 +32,7 @@
 
 from GConfigParser import * 
 import os
-import os.path
-import urllib
+from gnue.common import openResource
 import string
 import GDebug
 import GDataObjects
@@ -59,17 +58,26 @@
     GDebug.printMesg(1,'Reading basic configuration')
     if os.environ.has_key('INSTALL_PREFIX'):
       location = os.environ['INSTALL_PREFIX']+'/etc/gnue.conf'
-      self.readConfig(location)
+      try: 
+        self.readConfig(location)
+      except: 
+        GDebug.printMesg (1,'File not available')
 
     GDebug.printMesg(1,'Reading user configuration overrides')
     if os.environ.has_key('HOME'):
       location = os.environ['HOME']+'/.gnue/gnue.conf'
-      self.readConfig(location)
+      try: 
+        self.readConfig(location)
+      except: 
+        GDebug.printMesg (1,'File not available')
 
     GDebug.printMesg(1,'Reading fixed system configuration')
     if os.environ.has_key('INSTALL_PREFIX'):
       location = os.environ['INSTALL_PREFIX']+'/etc/gnue.conf.fixed'
-      self.readConfig(location)
+      try: 
+        self.readConfig(location)
+      except: 
+        GDebug.printMesg (1,'File not available')
 
   def readConfig(self,location):
     global _OPTION
@@ -77,14 +85,9 @@
     
     GDebug.printMesg(1,'Configuration File: "%s"' % location)
     drive = os.path.splitdrive(location) 
-    if len(drive[0]):
-      fileHandle = open(location,'r')
-    else:
-      try:
-        fileHandle = urllib.urlopen(location)
-      except IOError:
-        GDebug.printMesg(1,'  File is not available')
-        return
+
+    fileHandle = openResource(location)
+
     try: 
       self._parser.readfp(fileHandle) 
     except DuplicateSectionError: 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]