Changeset 4183

Show
Ignore:
Timestamp:
06/25/2008 04:52:42 PM (2 months ago)
Author:
ed
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/lib/DesignerXmlConverter.py

    r4117 r4183  
    744744            try: 
    745745                currSizer = sizerDict[currParent].pop() 
    746             except: pass 
     746            except (KeyError, IndexError): 
     747                pass 
    747748""" 
    748749        self._grdPgfText = """      parentStack.append(currParent) 
     
    770771            try: 
    771772                currSizer = sizerDict[currParent].pop() 
    772             except: pass 
     773            except (KeyError, IndexError): 
     774                pass 
    773775        else: 
    774776            currSizer = None 
     
    810812            try: 
    811813                currSizer = sizerDict[currParent].pop() 
    812             except: pass 
     814            except (KeyError, IndexError): 
     815                pass 
    813816        else: 
    814817            currSizer = None 
     
    821824            try: 
    822825                currSizer = sizerDict[currParent].pop() 
    823             except: pass 
     826            except (KeyError, IndexError): 
     827                pass 
    824828""" 
    825829        self._innerPropText = """   %(prop)s = property(%(pdg)s, %(pds)s, %(pdd)s,  
  • trunk/dabo/lib/SimpleCrypt.py

    r3054 r4183  
    5252            chunks = [chr(int(aString[i] + aString[i+1], 16))  
    5353                    for i in range(0, len(aString), 2)] 
    54         except
    55             raise ValueError, "Incorrectly-encrypted password" 
     54        except IndexError
     55            raise ValueError, _("Incorrectly-encrypted password") 
    5656        return "".join(chunks) 
    5757 
  • trunk/dabo/lib/autosuper/setup.py

    r3054 r4183  
    3939    setup(**pyrex_commands) 
    4040 
    41 except: 
    42     raise 
     41except ImportError, e: 
    4342    setup(**params) 
     43    raise e 
  • trunk/dabo/lib/connParser.py

    r3237 r4183  
    107107                escQuote(d["database"], noQuote=True), escQuote(d["user"], noQuote=True),  
    108108                escQuote(d["password"], noQuote=True), d["port"]) 
    109     except
     109    except KeyError
    110110        # Not a valid conn info dict 
    111111        ret = "" 
  • trunk/dabo/lib/datanav/Bizobj.py

    r3054 r4183  
    1717            cursorInfo, alias = fld.split(" as ") 
    1818            table, field = cursorInfo.split(".")         
    19         except
     19        except ValueError
    2020            # if fld wasn't sent as the conventional "table.field as alias", 
    2121            # then there's nothing to automatically do. 
  • trunk/dabo/lib/datanav/Form.py

    r3335 r4183  
    8989            try: 
    9090                os.remove(f) 
    91             except
     91            except OSError
    9292                # perhaps it is already gone, removed explicitly. 
    9393                pass 
     
    329329            self.pageFrame.release() 
    330330            del self.__dict__["PageFrame"] 
    331         except: pass 
     331        except KeyError: 
     332            pass 
    332333         
    333334        if self.beforeSetupPageFrame(): 
     
    627628        try: 
    628629            ret = self._allFieldSpecs[tbl] 
    629         except: pass 
     630        except KeyError: 
     631            pass 
    630632        return ret 
    631633         
     
    853855            try: 
    854856                c.Alignment 
    855             except
     857            except AttributeError
    856858                continue 
    857859            objects.append(((c.Left, c.Top + currentY), c)) 
  • trunk/dabo/lib/datanav/Page.py

    r3754 r4183  
    166166            try: 
    167167                del self.sortFields[self.sortDS] 
    168             except
     168            except KeyError
    169169                pass 
    170170        elif action== "show": 
  • trunk/dabo/lib/datanav2/Bizobj.py

    r3054 r4183  
    1717            cursorInfo, alias = fld.split(" as ") 
    1818            table, field = cursorInfo.split(".")         
    19         except
     19        except ValueError
    2020            # if fld wasn't sent as the conventional "table.field as alias", 
    2121            # then there's nothing to automatically do. 
  • trunk/dabo/lib/datanav2/Form.py

    r3718 r4183  
    257257            self.pageFrame.release() 
    258258            del self.__dict__["PageFrame"] 
    259         except: pass 
     259        except KeyError: pass 
    260260         
    261261        if self.beforeSetupPageFrame(): 
     
    692692            try: 
    693693                c.DataField 
    694             except
     694            except AttributeError
    695695                continue 
    696696            objects.append(((c.Left, c.Top + currentY), c)) 
  • trunk/dabo/lib/datanav2/Page.py

    r4045 r4183  
    165165            try: 
    166166                del self.sortFields[self.sortDS] 
    167             except
     167            except KeyError
    168168                pass 
    169169        elif action== "show": 
  • trunk/dabo/lib/dates.py

    r3944 r4183  
    147147            try: 
    148148                ret = datetime.date(*time.strptime(strVal, "%x")[:3]) 
    149             except
     149            except IndexError
    150150                pass 
    151151    return ret 
     
    218218            try: 
    219219                ret = datetime.datetime(*time.strptime(strVal, "%x %X")) 
    220             except
     220            except IndexError
    221221                pass 
    222222    return ret 
  • trunk/dabo/lib/eventMixin.py

    r4119 r4183  
    109109        try: 
    110110            self.__raisedEvents.pop() 
    111         except
     111        except (AttributeError, IndexError)
    112112            # This is a deleted object; no need (or ability!) to do anything else. 
    113113            return 
     
    210210            try: 
    211211                parent = parent.Parent 
    212             except
     212            except AttributeError
    213213                parent = self.Form 
    214214                stop = True 
  • trunk/dabo/lib/propertyHelperMixin.py

    r3986 r4183  
    187187                        self._setName(_propDict[prop]) 
    188188                        continue 
    189                     except
     189                    except AttributeError
    190190                        # Not a class that implements _setName() 
    191191                        pass 
     
    231231                else: 
    232232                    raise AttributeError, "'%s' is not a property." % prop 
    233             if isinstance(eval("self.%s" % prop), basestring): 
    234                 # If this is property holds strings, we need to quote the value. 
    235                 try: 
    236                     exec("self.%s = '%s'" % (prop, val) ) 
    237                 except: 
    238                     raise ValueError, "Could not set property '%s' to value: %s" % (prop, val) 
    239             else: 
    240                 try: 
    241                     exec("self.%s = %s" % (prop, val) ) 
    242                 except: 
    243                     # Still could be a string, if the original value was None 
    244                     try: 
    245                         exec("self.%s = '%s'" % (prop, val) ) 
    246                     except: 
    247                         raise ValueError, "Could not set property '%s' to value: %s" % (prop, val) 
     233            setattr(self, prop, val) 
     234#           if isinstance(eval("self.%s" % prop), basestring): 
     235#               # If this is property holds strings, we need to quote the value. 
     236#               try: 
     237#                   exec("self.%s = '%s'" % (prop, val) ) 
     238#               except : 
     239#                   raise ValueError, "Could not set property '%s' to value: %s" % (prop, val) 
     240#           else: 
     241#               try: 
     242#                   exec("self.%s = %s" % (prop, val) ) 
     243#               except: 
     244#                   # Still could be a string, if the original value was None 
     245#                   try: 
     246#                       exec("self.%s = '%s'" % (prop, val) ) 
     247#                   except: 
     248#                       raise ValueError, "Could not set property '%s' to value: %s" % (prop, val) 
    248249         
    249250     
     
    315316                try: 
    316317                    propVal = propRef.fget(cls) 
    317                 except
     318                except AttributeError
    318319                    # There are many reasons the propval may not be determined for now,  
    319320                    # such as not being a live instance. 
  • trunk/dabo/lib/reportUtils.py

    r4033 r4183  
    2525            try: 
    2626                os.remove(f) 
    27             except
     27            except OSError
    2828                pass 
    2929 
  • trunk/dabo/lib/reportWriter.py

    r4037 r4183  
    959959                c.setFont(fontName, fontSize) 
    960960            except: 
     961                ### FIXME 
    961962                # An unavailable fontName was likely specified. The rw docs promise to 
    962963                # default to Helvetica in this case. 
     
    12361237                c.drawImage(imageData, 0, 0, width, height, mask) 
    12371238            except: 
     1239                ### FIXME 
    12381240                pass             
    12391241        ## All done, restore the canvas state to how we found it (important because 
     
    14991501                            ev = eval(show) 
    15001502                        except: 
     1503                            ### FIXME 
    15011504                            ## expression failed to eval: default to True (show it) 
    15021505                            ev = True 
  • trunk/dabo/lib/test/test_utils.py

    r3752 r4183  
    2525        try: 
    2626            shutil.rmtree(self.tempTestDir) 
    27         except
     27        except OSError
    2828            pass 
    2929        os.mkdir(self.tempTestDir) 
  • trunk/dabo/lib/utils.py

    r4099 r4183  
    6262    # os.path.expanduser should work on all posix systems (*nix, Mac, and some 
    6363    # Windows NT setups): 
    64     try: 
    65         hd = os.path.expanduser("~") 
    66     except: 
    67         pass 
     64    hd = os.path.expanduser("~") 
    6865 
    6966    # If for some reason the posix function above didn't work, most Linux setups 
     
    123120            try: 
    124121                os.makedirs(dd) 
    125             except
     122            except OSError
    126123                sys.stderr.write("Couldn't create the user setting directory (%s)." % dd) 
    127124                dd = None 
  • trunk/dabo/lib/uuid.py

    r3054 r4183  
    298298        dirs.insert(0, buffer.value.decode('mbcs')) 
    299299    except: 
     300        ### FIXME 
    300301        pass 
    301302    for dir in dirs: 
     
    352353            lib = ctypes.CDLL(ctypes.util.find_library(libname)) 
    353354        except: 
     355            ### FIXME 
    354356            continue 
    355357        if hasattr(lib, 'uuid_generate_random'): 
     
    365367        lib = ctypes.windll.rpcrt4 
    366368    except: 
     369        ### FIXME 
    367370        lib = None 
    368371    _UuidCreate = getattr(lib, 'UuidCreateSequential', 
    369372                          getattr(lib, 'UuidCreate', None)) 
    370373except: 
     374    ### FIXME 
    371375    pass 
    372376 
     
    408412            _node = getter() 
    409413        except: 
     414            ### FIXME 
    410415            continue 
    411416        if _node is not None: 
     
    461466        return UUID(bytes=os.urandom(16), version=4) 
    462467    except: 
     468        ### FIXME 
    463469        import random 
    464470        bytes = [chr(random.randrange(256)) for i in range(16)]