python: Change except: statement to except Exception:
authorAmitay Isaacs <amitay@gmail.com>
Tue, 24 Jan 2012 00:54:54 +0000 (11:54 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 24 Jan 2012 02:32:40 +0000 (03:32 +0100)
This way we only catch true exceptions and keyboard interrupts
are not caught here.

Autobuild-User: Amitay Isaacs <amitay@samba.org>
Autobuild-Date: Tue Jan 24 03:32:40 CET 2012 on sn-devel-104

source4/dsdb/tests/python/dirsync.py
source4/scripting/bin/upgradeprovision
source4/scripting/devel/repl_cleartext_pwd.py
source4/scripting/python/samba/join.py
source4/scripting/python/samba/netcmd/dbcheck.py
source4/scripting/python/samba/netcmd/domain.py
source4/scripting/python/samba/provision/sambadns.py
source4/scripting/python/samba/tests/dcerpc/testrpc.py
source4/setup/provision

index 6da9003bf5660b02e7fb99a04a7aac13b5408a8d..64b847f4306fede087f30b4a41ee3d98701d3628 100755 (executable)
@@ -136,7 +136,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
         self.sd_utils.modify_sd_on_dn(self.base_dn, self.desc_sddl)
         try:
             self.ldb_admin.deletegroup("testgroup")
-        except:
+        except Exception:
             pass
 
     #def test_dirsync_errors(self):
index 738d6be891eec145e75b2a1792fa55176ac81f0b..aec0774a9d2046bc2e7d263110c3157246300aba 100755 (executable)
@@ -1488,14 +1488,14 @@ def copyxattrs(dir, refdir):
                     samba.xattr_native.wrap_setxattr(tgt,
                                                  xattr.XATTR_NTACL_NAME,
                                                  attribute)
-                except:
+                except Exception:
                     noxattr = 1
                 attribute = samba.xattr_native.wrap_getxattr(ref,
                                                  "system.posix_acl_access")
                 samba.xattr_native.wrap_setxattr(tgt,
                                                  "system.posix_acl_access",
                                                   attribute)
-            except:
+            except Exception:
                 continue
         for name in dirs:
             subdir=root[len(dir):]
@@ -1511,7 +1511,7 @@ def copyxattrs(dir, refdir):
                     samba.xattr_native.wrap_setxattr(tgt,
                                                  xattr.XATTR_NTACL_NAME,
                                                  attribute)
-                except:
+                except Exception:
                     noxattr = 1
                 attribute = samba.xattr_native.wrap_getxattr(ref,
                                                  "system.posix_acl_access")
@@ -1519,7 +1519,7 @@ def copyxattrs(dir, refdir):
                                                  "system.posix_acl_access",
                                                   attribute)
 
-            except:
+            except Exception:
                 continue
 
 
index 840d281a6ebf60e3bdd1e6d341ec3e687ad9acec..5eebc8689de59a284b929af279cb53981c062cea 100755 (executable)
@@ -101,7 +101,7 @@ if __name__ == "__main__":
     if len(args) >= 7:
         try:
             attid = int(args[4], 16)
-        except:
+        except Exception:
             attid = int(args[4])
         attname = args[5]
         attmode = args[6]
@@ -145,7 +145,7 @@ if __name__ == "__main__":
        assert store_dn == dn
        #print "%s" % ndr_print(store_hwm)
        #print "%s" % ndr_print(store_utdv)
-    except:
+    except Exception:
        store_dn = dn
        store_hwm = drsuapi.DsReplicaHighWaterMark()
        store_hwm.tmp_highest_usn  = 0
@@ -325,7 +325,7 @@ if __name__ == "__main__":
                     cleartext_unicode = unicode(cleartext_utf16, 'utf-16-le')
                     cleartext_utf8 = cleartext_unicode.encode('utf-8')
                     gls.add_attr(obj.identifier.dn, clear_utf8_name, [cleartext_utf8])
-                except:
+                except Exception:
                     pass
 
                 if attvals is not None:
index 818e0cec6d8bf67d255f013ca39b5550229d9809..dc2ceef3390f39b5b8284c1c9fea95c05eacc5c4 100644 (file)
@@ -683,7 +683,7 @@ class dc_join(object):
             ctx.destination_dsa_guid = destination_dsa_guid
 
             print "Committing SAM database"
-        except:
+        except Exception:
             ctx.local_samdb.transaction_cancel()
             raise
         else:
index bd250eb6be5aae0e290678837dbf669d9546d822..875b05950608e79ded390a5e4a1810a578c1f65b 100644 (file)
@@ -112,7 +112,7 @@ class cmd_dbcheck(Command):
             else:
                 error_count = chk.check_database(DN=DN, scope=search_scope,
                         controls=controls, attrs=attrs)
-        except:
+        except Exception:
             if started_transaction:
                 samdb.transaction_cancel()
             raise
index 6c2ebfa3018310ece96407bacc51b2f3d7ff1d17..1e26850277f5232dc81bb7c9fbf85f5ef6ad86b8 100644 (file)
@@ -855,7 +855,7 @@ class cmd_domain_samba3upgrade(Command):
                 samba.ntacls.setntacl(lp, tmpfile.name,
                             "O:S-1-5-32G:S-1-5-32", "S-1-5-32", "native")
                 eadb = False
-            except:
+            except Exception:
                 # FIXME: Don't catch all exceptions here
                 logger.info("You are not root or your system do not support xattr, using tdb backend for attributes. "
                             "If you intend to use this provision in production, rerun the script as root on a system supporting xattrs.")
index db98f13dddfe223bed48af074a997b42917a1cb4..4805294676a3b1510233948f5827242db64100fc 100644 (file)
@@ -719,7 +719,7 @@ def create_samdb_copy(samdb, logger, paths, names, domainsid, domainguid):
             "DOMAINSID" : str(domainsid),
             "DESCRIPTOR" : descr})
         setup_add_ldif(dom_ldb, setup_path("provision_basedn_options.ldif"), None)
-    except:
+    except Exception:
         logger.error("Failed to setup database for BIND, AD based DNS cannot be used")
         raise
     del partfile[domaindn]
@@ -754,7 +754,7 @@ def create_samdb_copy(samdb, logger, paths, names, domainsid, domainguid):
             tdb_copy(logger,
                      os.path.join(private_dir, pfile),
                      os.path.join(dns_dir, pfile))
-    except:
+    except Exception:
         logger.error("Failed to setup database for BIND, AD based DNS cannot be used")
         raise
 
index 44fed72fffdae0a9d3d3168d7403ea9137a73ed8..9c2541934ff52cd5600ebf7cfa0eef2128429f4d 100644 (file)
@@ -61,7 +61,7 @@ class RpcTests(object):
                     print "ERROR: Failed to instantiate %s.%s" % (typename, n)
                     self.errcount += 1
                     continue
-            except:
+            except Exception:
                 print "ERROR: Failed to instantiate %s.%s" % (typename, n)
                 self.errcount += 1
                 continue
index cea8823d09676c8e64aa1badf8c19152d816c0e6..be528545fdc9475ec63ec61494413f98ab981736 100755 (executable)
@@ -230,7 +230,7 @@ elif opts.use_xattrs == "auto" and not lp.get("posix:eadb"):
         samba.ntacls.setntacl(lp, file.name,
             "O:S-1-5-32G:S-1-5-32", "S-1-5-32", "native")
         eadb = False
-    except:
+    except Exception:
         logger.info("You are not root or your system do not support xattr, using tdb backend for attributes. "
                 "If you intend to use this provision in production, rerun the script as root on a system supporting xattrs.")
     file.close()