dabo Commit
Revision 4179
Date: 2008-06-25 15:09:04 -0700 (Wed, 25 Jun 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4179

Changed:
U   trunk/dabo/__version__.py
U   trunk/dabo/dApp.py
U   trunk/dabo/dBug.py
U   trunk/dabo/dColors.py
U   trunk/dabo/dObject.py
U   trunk/dabo/dPref.py

Log:
Removed bare 'except:' from the code.


Diff:
Modified: trunk/dabo/__version__.py
===================================================================
--- trunk/dabo/__version__.py   2008-06-25 19:58:11 UTC (rev 4178)
+++ trunk/dabo/__version__.py   2008-06-25 22:09:04 UTC (rev 4179)
@@ -18,7 +18,7 @@
                _revision = os.popen("svnversion %s" % 
package_path).read().strip()
                if not _revision[0].isdigit():
                        _revision = None
-       except:
+       except IndexError:
                _revision = None
 
 if _revision is None:

Modified: trunk/dabo/dApp.py
===================================================================
--- trunk/dabo/dApp.py  2008-06-25 19:58:11 UTC (rev 4178)
+++ trunk/dabo/dApp.py  2008-06-25 22:09:04 UTC (rev 4179)
@@ -73,7 +73,7 @@
                                        if not f.endswith(".pyc"):
                                                # Don't worry about the .pyc 
files, since they may not be there
                                                print "Could not delete %s: %s" 
% (f, e)
-               except:
+               except StandardError, e:
                        # In these rare cases, Python has already 'gone away', 
so just bail
                        pass
        
@@ -436,7 +436,7 @@
                        localVers = dabo.version["file_revision"]
                        try:
                                localVers = localVers.split(":")[1]
-                       except:
+                       except IndexError:
                                # Not a mixed version
                                pass
                        ret = int("".join([ch for ch in localVers if 
ch.isdigit()]))
@@ -526,8 +526,10 @@
                                        url = 
"http://dabodev.com/frameworkVersions/latest?project=%s"; % abbrev
                                        try:
                                                vers = 
int(urllib2.urlopen(url).read())
-                                       except:
+                                       except ValueError:
                                                vers = -1
+                                       except StandardError, e:
+                                               dabo.errorLog.write(_("Failed 
to open URL '%s'. Error: %s") % (url, e))
                                        localVers = 
self._currentUpdateVersion(nm)
                                        retAvailable = (localVers < vers)
                                prf.setValue("last_check", now)
@@ -550,9 +552,9 @@
                        webpath = self.webUpdateDirs[pn.lower()]
                        try:
                                resp = urllib2.urlopen(fileurl % (abbrev, 
currvers))
-                       except:
+                       except StandardError, e:
                                # No internet access, or Dabo site is down.
-                               dabo.errorLog.write(_("Cannot access the Dabo 
site."))
+                               dabo.errorLog.write(_("Cannot access the Dabo 
site. Error: %s") % e)
                                self._resetWebUpdateCheck()
                                return None
                        respFiles = resp.read()
@@ -581,9 +583,12 @@
                url = "http://dabodev.com/frameworkVersions/latest";
                try:
                        vers = int(urllib2.urlopen(url).read())
-               except:
+               except ValueError:
                        vers = self._currentUpdateVersion()
-                       self.PreferenceManager.setValue("current_version", vers)
+               except StandardError, e:
+                       dabo.errorLog.write(_("Cannot access the Dabo site. 
Error: %s") % e)
+                       vers = self._currentUpdateVersion()
+               self.PreferenceManager.setValue("current_version", vers)
                return vers
                
 
@@ -886,15 +891,15 @@
                for conn in self.dbConnections:
                        try:
                                conn.close()
-                       except:
-                               pass
+                       except StandardError, e:
+                               dabo.errorLog.write(_("Failed to close 
connection. Error: %s") % e)
        
        
        def addConnectInfo(self, ci, name=None):
                if name is None:
                        try:
                                name = ci.Name
-                       except:
+                       except AttributeError:
                                # Use a default name
                                name = "[EMAIL PROTECTED]" % (ci.User, ci.Host)
                self.dbConnectionDefs[name] = ci
@@ -1100,11 +1105,13 @@
                if not ret:
                        try:
                                ret = self.ActiveForm.BasePrefKey
-                       except: pass
+                       except AttributeError: 
+                               pass
                if not ret:
                        try:
                                ret = self.MainForm.BasePrefKey
-                       except: pass
+                       except AttributeError:
+                               pass
                if not ret:
                        dabo.infoLog.write(_("WARNING: No BasePrefKey has been 
set for this application."))
                        try:
@@ -1141,8 +1148,8 @@
                if isinstance(val, basestring):
                        try:
                                f = open(val, "a")
-                       except:
-                               dabo.errorLog.write(_("Could not open file: 
'%s'") % val)
+                       except IOError, e:
+                               dabo.errorLog.write(_("Could not open file: 
'%s': %s") % (val, e))
                                return
                else:
                        f = val

Modified: trunk/dabo/dBug.py
===================================================================
--- trunk/dabo/dBug.py  2008-06-25 19:58:11 UTC (rev 4178)
+++ trunk/dabo/dBug.py  2008-06-25 22:09:04 UTC (rev 4179)
@@ -60,9 +60,8 @@
        value will be 'functionCall.log'.
        """
        try:
-               if loggit.fhwr:
-                       pass
-       except:
+               loggit.fhwr
+       except AttributeError:
                # ... open it
                fname = dabo.loggitFile
                loggit.fhwr = open(fname, "a")
@@ -74,8 +73,8 @@
                        for ag in args:
                                try:
                                        loggit.fhwr.write(" %s" % ag)
-                               except:
-                                       loggit.fhwr.write(" ERR")
+                               except StandardError, e:
+                                       loggit.fhwr.write(" ERR: %s" % e)
                        loggit.fhwr.write("\n")
                if kwargs:
                        loggit.fhwr.write("\tKWARGS:%s\n" % kwargs)

Modified: trunk/dabo/dColors.py
===================================================================
--- trunk/dabo/dColors.py       2008-06-25 19:58:11 UTC (rev 4178)
+++ trunk/dabo/dColors.py       2008-06-25 22:09:04 UTC (rev 4179)
@@ -231,7 +231,7 @@
        except KeyError:
                try:
                        ret = colorTupleFromHex(color)
-               except:
+               except InvalidCharError:
                        ret = colorTupleFromString(color)
        return ret
        

Modified: trunk/dabo/dObject.py
===================================================================
--- trunk/dabo/dObject.py       2008-06-25 19:58:11 UTC (rev 4178)
+++ trunk/dabo/dObject.py       2008-06-25 22:09:04 UTC (rev 4179)
@@ -187,7 +187,7 @@
                """Return the list of (Dabo) methods for this class or 
instance."""
                try:
                        methodList = cls.__methodList
-               except:
+               except AttributeError:
                        methodList = None
 
                if refresh:

Modified: trunk/dabo/dPref.py
===================================================================
--- trunk/dabo/dPref.py 2008-06-25 19:58:11 UTC (rev 4178)
+++ trunk/dabo/dPref.py 2008-06-25 22:09:04 UTC (rev 4179)
@@ -218,8 +218,8 @@
                crs = self._cursor
                try:
                        typ = self._typeDict[type(val)]
-               except:
-                       print "BAD TYPE", type(val)
+               except KeyError:
+                       dabo.errorLog.write(_("BAD TYPE: %s") % type(val))
                        typ = "?"
                # Convert it to a string that can be properly converted back
                val = self._encodeType(val, typ)




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to