dabo Commit
Revision 4183
Date: 2008-06-25 16:52:42 -0700 (Wed, 25 Jun 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4183

Changed:
U   trunk/dabo/lib/DesignerXmlConverter.py
U   trunk/dabo/lib/SimpleCrypt.py
U   trunk/dabo/lib/autosuper/setup.py
U   trunk/dabo/lib/connParser.py
U   trunk/dabo/lib/datanav/Bizobj.py
U   trunk/dabo/lib/datanav/Form.py
U   trunk/dabo/lib/datanav/Page.py
U   trunk/dabo/lib/datanav2/Bizobj.py
U   trunk/dabo/lib/datanav2/Form.py
U   trunk/dabo/lib/datanav2/Page.py
U   trunk/dabo/lib/dates.py
U   trunk/dabo/lib/eventMixin.py
U   trunk/dabo/lib/propertyHelperMixin.py
U   trunk/dabo/lib/reportUtils.py
U   trunk/dabo/lib/reportWriter.py
U   trunk/dabo/lib/test/test_utils.py
U   trunk/dabo/lib/utils.py
U   trunk/dabo/lib/uuid.py

Log:
Removed bare 'except:' lines.

Paul, I wasn't sure how to fix these two scripts. Since you wrote them, you 
might have a better idea. I labeled the bare except: lines with FIXME comments:
        lib/reportWriter.py
        lib/uuid.py



Diff:
Modified: trunk/dabo/lib/DesignerXmlConverter.py
===================================================================
--- trunk/dabo/lib/DesignerXmlConverter.py      2008-06-25 23:09:08 UTC (rev 
4182)
+++ trunk/dabo/lib/DesignerXmlConverter.py      2008-06-25 23:52:42 UTC (rev 
4183)
@@ -743,7 +743,8 @@
                else:
                        try:
                                currSizer = sizerDict[currParent].pop()
-                       except: pass
+                       except (KeyError, IndexError):
+                               pass
 """
                self._grdPgfText = """          parentStack.append(currParent)
                sizerDict[currParent].append(currSizer)
@@ -769,7 +770,8 @@
                if sizerDict[currParent]:
                        try:
                                currSizer = sizerDict[currParent].pop()
-                       except: pass
+                       except (KeyError, IndexError):
+                               pass
                else:
                        currSizer = None
 """
@@ -809,7 +811,8 @@
                self._szPopText = """           if sizerDict[currParent]:
                        try:
                                currSizer = sizerDict[currParent].pop()
-                       except: pass
+                       except (KeyError, IndexError):
+                               pass
                else:
                        currSizer = None
 """
@@ -820,7 +823,8 @@
                else:
                        try:
                                currSizer = sizerDict[currParent].pop()
-                       except: pass
+                       except (KeyError, IndexError):
+                               pass
 """
                self._innerPropText = """       %(prop)s = property(%(pdg)s, 
%(pds)s, %(pdd)s, 
                        \"\"\"%(pdc)s\"\"\")

Modified: trunk/dabo/lib/SimpleCrypt.py
===================================================================
--- trunk/dabo/lib/SimpleCrypt.py       2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/SimpleCrypt.py       2008-06-25 23:52:42 UTC (rev 4183)
@@ -51,7 +51,7 @@
                try:
                        chunks = [chr(int(aString[i] + aString[i+1], 16)) 
                                        for i in range(0, len(aString), 2)]
-               except:
-                       raise ValueError, "Incorrectly-encrypted password"
+               except IndexError:
+                       raise ValueError, _("Incorrectly-encrypted password")
                return "".join(chunks)
 

Modified: trunk/dabo/lib/autosuper/setup.py
===================================================================
--- trunk/dabo/lib/autosuper/setup.py   2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/autosuper/setup.py   2008-06-25 23:52:42 UTC (rev 4183)
@@ -38,6 +38,6 @@
     pyrex_commands.update(ext)
     setup(**pyrex_commands)
 
-except:
-    raise
+except ImportError, e:
     setup(**params)
+    raise e

Modified: trunk/dabo/lib/connParser.py
===================================================================
--- trunk/dabo/lib/connParser.py        2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/connParser.py        2008-06-25 23:52:42 UTC (rev 4183)
@@ -106,7 +106,7 @@
                                escQuote(d["name"], noQuote=True), 
escQuote(d["host"], noQuote=True), 
                                escQuote(d["database"], noQuote=True), 
escQuote(d["user"], noQuote=True), 
                                escQuote(d["password"], noQuote=True), 
d["port"])
-       except:
+       except KeyError:
                # Not a valid conn info dict
                ret = ""
        return ret

Modified: trunk/dabo/lib/datanav/Bizobj.py
===================================================================
--- trunk/dabo/lib/datanav/Bizobj.py    2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/datanav/Bizobj.py    2008-06-25 23:52:42 UTC (rev 4183)
@@ -16,7 +16,7 @@
                try:
                        cursorInfo, alias = fld.split(" as ")
                        table, field = cursorInfo.split(".")            
-               except:
+               except ValueError:
                        # if fld wasn't sent as the conventional "table.field 
as alias",
                        # then there's nothing to automatically do.
                        alias, table, field = None, None, None

Modified: trunk/dabo/lib/datanav/Form.py
===================================================================
--- trunk/dabo/lib/datanav/Form.py      2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/datanav/Form.py      2008-06-25 23:52:42 UTC (rev 4183)
@@ -88,7 +88,7 @@
                for f in self._tempFiles:
                        try:
                                os.remove(f)
-                       except:
+                       except OSError:
                                # perhaps it is already gone, removed 
explicitly.
                                pass
 
@@ -328,7 +328,8 @@
                        self.pageFrame.unbindEvent()
                        self.pageFrame.release()
                        del self.__dict__["PageFrame"]
-               except: pass
+               except KeyError:
+                       pass
                
                if self.beforeSetupPageFrame():
                        self.pageFrame = PageFrame.PageFrame(self, 
tabStyle=self.pageFrameStyle,
@@ -626,7 +627,8 @@
                ret = None
                try:
                        ret = self._allFieldSpecs[tbl]
-               except: pass
+               except KeyError:
+                       pass
                return ret
                
        
@@ -852,7 +854,7 @@
                                continue
                        try:
                                c.Alignment
-                       except:
+                       except AttributeError:
                                continue
                        objects.append(((c.Left, c.Top + currentY), c))
                return objects

Modified: trunk/dabo/lib/datanav/Page.py
===================================================================
--- trunk/dabo/lib/datanav/Page.py      2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/datanav/Page.py      2008-06-25 23:52:42 UTC (rev 4183)
@@ -165,7 +165,7 @@
                if action == "remove":
                        try:
                                del self.sortFields[self.sortDS]
-                       except:
+                       except KeyError:
                                pass
                elif action== "show":
                        # Get the descrips and order

Modified: trunk/dabo/lib/datanav2/Bizobj.py
===================================================================
--- trunk/dabo/lib/datanav2/Bizobj.py   2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/datanav2/Bizobj.py   2008-06-25 23:52:42 UTC (rev 4183)
@@ -16,7 +16,7 @@
                try:
                        cursorInfo, alias = fld.split(" as ")
                        table, field = cursorInfo.split(".")            
-               except:
+               except ValueError:
                        # if fld wasn't sent as the conventional "table.field 
as alias",
                        # then there's nothing to automatically do.
                        alias, table, field = None, None, None

Modified: trunk/dabo/lib/datanav2/Form.py
===================================================================
--- trunk/dabo/lib/datanav2/Form.py     2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/datanav2/Form.py     2008-06-25 23:52:42 UTC (rev 4183)
@@ -256,7 +256,7 @@
                        self.pageFrame.unbindEvent()
                        self.pageFrame.release()
                        del self.__dict__["PageFrame"]
-               except: pass
+               except KeyError: pass
                
                if self.beforeSetupPageFrame():
                        self.pageFrame = PageFrame.PageFrame(self, 
tabStyle=self.PageFrameStyle,
@@ -691,7 +691,7 @@
                                continue
                        try:
                                c.DataField
-                       except:
+                       except AttributeError:
                                continue
                        objects.append(((c.Left, c.Top + currentY), c))
                return objects

Modified: trunk/dabo/lib/datanav2/Page.py
===================================================================
--- trunk/dabo/lib/datanav2/Page.py     2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/datanav2/Page.py     2008-06-25 23:52:42 UTC (rev 4183)
@@ -164,7 +164,7 @@
                if action == "remove":
                        try:
                                del self.sortFields[self.sortDS]
-                       except:
+                       except KeyError:
                                pass
                elif action== "show":
                        # Get the descrips and order

Modified: trunk/dabo/lib/dates.py
===================================================================
--- trunk/dabo/lib/dates.py     2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/dates.py     2008-06-25 23:52:42 UTC (rev 4183)
@@ -146,7 +146,7 @@
                        # Fall back to the current locale setting in user's os 
account:
                        try:
                                ret = datetime.date(*time.strptime(strVal, 
"%x")[:3])
-                       except:
+                       except IndexError:
                                pass
        return ret
 
@@ -217,7 +217,7 @@
                        # Fall back to the current locale setting in user's os 
account:
                        try:
                                ret = datetime.datetime(*time.strptime(strVal, 
"%x %X"))
-                       except:
+                       except IndexError:
                                pass
        return ret
 

Modified: trunk/dabo/lib/eventMixin.py
===================================================================
--- trunk/dabo/lib/eventMixin.py        2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/eventMixin.py        2008-06-25 23:52:42 UTC (rev 4183)
@@ -108,7 +108,7 @@
                                break
                try:
                        self.__raisedEvents.pop()
-               except:
+               except (AttributeError, IndexError):
                        # This is a deleted object; no need (or ability!) to do 
anything else.
                        return
                
@@ -209,7 +209,7 @@
                                break
                        try:
                                parent = parent.Parent
-                       except:
+                       except AttributeError:
                                parent = self.Form
                                stop = True
 

Modified: trunk/dabo/lib/propertyHelperMixin.py
===================================================================
--- trunk/dabo/lib/propertyHelperMixin.py       2008-06-25 23:09:08 UTC (rev 
4182)
+++ trunk/dabo/lib/propertyHelperMixin.py       2008-06-25 23:52:42 UTC (rev 
4183)
@@ -186,7 +186,7 @@
                                        try:
                                                self._setName(_propDict[prop])
                                                continue
-                                       except:
+                                       except AttributeError:
                                                # Not a class that implements 
_setName()
                                                pass
                                propRef = eval("self.__class__.%s" % prop)
@@ -230,21 +230,22 @@
                                        continue
                                else:
                                        raise AttributeError, "'%s' is not a 
property." % prop
-                       if isinstance(eval("self.%s" % prop), basestring):
-                               # If this is property holds strings, we need to 
quote the value.
-                               try:
-                                       exec("self.%s = '%s'" % (prop, val) )
-                               except:
-                                       raise ValueError, "Could not set 
property '%s' to value: %s" % (prop, val)
-                       else:
-                               try:
-                                       exec("self.%s = %s" % (prop, val) )
-                               except:
-                                       # Still could be a string, if the 
original value was None
-                                       try:
-                                               exec("self.%s = '%s'" % (prop, 
val) )
-                                       except:
-                                               raise ValueError, "Could not 
set property '%s' to value: %s" % (prop, val)
+                       setattr(self, prop, val)
+#                      if isinstance(eval("self.%s" % prop), basestring):
+#                              # If this is property holds strings, we need to 
quote the value.
+#                              try:
+#                                      exec("self.%s = '%s'" % (prop, val) )
+#                              except :
+#                                      raise ValueError, "Could not set 
property '%s' to value: %s" % (prop, val)
+#                      else:
+#                              try:
+#                                      exec("self.%s = %s" % (prop, val) )
+#                              except:
+#                                      # Still could be a string, if the 
original value was None
+#                                      try:
+#                                              exec("self.%s = '%s'" % (prop, 
val) )
+#                                      except:
+#                                              raise ValueError, "Could not 
set property '%s' to value: %s" % (prop, val)
                
        
        def _setKwEventBindings(self, kwEvtDict):
@@ -314,7 +315,7 @@
                        else:
                                try:
                                        propVal = propRef.fget(cls)
-                               except:
+                               except AttributeError:
                                        # There are many reasons the propval 
may not be determined for now, 
                                        # such as not being a live instance.
                                        propVal = None

Modified: trunk/dabo/lib/reportUtils.py
===================================================================
--- trunk/dabo/lib/reportUtils.py       2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/reportUtils.py       2008-06-25 23:52:42 UTC (rev 4183)
@@ -24,7 +24,7 @@
                for f in self._tempFiles:
                        try:
                                os.remove(f)
-                       except:
+                       except OSError:
                                pass
 
        def append(self, f):

Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py      2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/reportWriter.py      2008-06-25 23:52:42 UTC (rev 4183)
@@ -958,6 +958,7 @@
                        try:
                                c.setFont(fontName, fontSize)
                        except:
+                       ### FIXME
                                # An unavailable fontName was likely specified. 
The rw docs promise to
                                # default to Helvetica in this case.
                                c.setFont("Helvetica", fontSize)
@@ -1235,6 +1236,7 @@
                        try:
                                c.drawImage(imageData, 0, 0, width, height, 
mask)
                        except:
+                       ### FIXME
                                pass                    
                ## All done, restore the canvas state to how we found it 
(important because
                ## rotating, scaling, etc. are cumulative, not absolute and we 
don't want
@@ -1498,6 +1500,7 @@
                                                try:
                                                        ev = eval(show)
                                                except:
+                                               ### FIXME
                                                        ## expression failed to 
eval: default to True (show it)
                                                        ev = True
                                                if not ev:

Modified: trunk/dabo/lib/test/test_utils.py
===================================================================
--- trunk/dabo/lib/test/test_utils.py   2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/test/test_utils.py   2008-06-25 23:52:42 UTC (rev 4183)
@@ -24,7 +24,7 @@
                self.tempTestDir = tempfile.gettempdir() + os.sep + 
"relpath_tests_dir"
                try:
                        shutil.rmtree(self.tempTestDir)
-               except:
+               except OSError:
                        pass
                os.mkdir(self.tempTestDir)
                os.chdir(self.tempTestDir)

Modified: trunk/dabo/lib/utils.py
===================================================================
--- trunk/dabo/lib/utils.py     2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/utils.py     2008-06-25 23:52:42 UTC (rev 4183)
@@ -61,10 +61,7 @@
 
        # os.path.expanduser should work on all posix systems (*nix, Mac, and 
some
        # Windows NT setups):
-       try:
-               hd = os.path.expanduser("~")
-       except:
-               pass
+       hd = os.path.expanduser("~")
 
        # If for some reason the posix function above didn't work, most Linux 
setups
        # define the environmental variable $HOME, and perhaps this is done 
sometimes
@@ -122,7 +119,7 @@
                        # try to create the dabo directory:
                        try:
                                os.makedirs(dd)
-                       except:
+                       except OSError:
                                sys.stderr.write("Couldn't create the user 
setting directory (%s)." % dd)
                                dd = None
        return dd

Modified: trunk/dabo/lib/uuid.py
===================================================================
--- trunk/dabo/lib/uuid.py      2008-06-25 23:09:08 UTC (rev 4182)
+++ trunk/dabo/lib/uuid.py      2008-06-25 23:52:42 UTC (rev 4183)
@@ -297,6 +297,7 @@
         ctypes.windll.kernel32.GetSystemDirectoryA(buffer, 300)
         dirs.insert(0, buffer.value.decode('mbcs'))
     except:
+       ### FIXME
         pass
     for dir in dirs:
         try:
@@ -351,6 +352,7 @@
         try:
             lib = ctypes.CDLL(ctypes.util.find_library(libname))
         except:
+               ### FIXME
             continue
         if hasattr(lib, 'uuid_generate_random'):
             _uuid_generate_random = lib.uuid_generate_random
@@ -364,10 +366,12 @@
     try:
         lib = ctypes.windll.rpcrt4
     except:
+       ### FIXME
         lib = None
     _UuidCreate = getattr(lib, 'UuidCreateSequential',
                           getattr(lib, 'UuidCreate', None))
 except:
+       ### FIXME
     pass
 
 def _unixdll_getnode():
@@ -407,6 +411,7 @@
         try:
             _node = getter()
         except:
+               ### FIXME
             continue
         if _node is not None:
             return _node
@@ -460,6 +465,7 @@
         import os
         return UUID(bytes=os.urandom(16), version=4)
     except:
+       ### FIXME
         import random
         bytes = [chr(random.randrange(256)) for i in range(16)]
         return UUID(bytes=bytes, version=4)




_______________________________________________
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