More formatting fixes, pointed out by pylint.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 1 Mar 2010 04:04:23 +0000 (05:04 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 1 Mar 2010 15:24:58 +0000 (16:24 +0100)
source4/scripting/python/samba/__init__.py
source4/scripting/python/samba/misc.py
source4/scripting/python/samba/ntacls.py
source4/scripting/python/samba/provision.py
source4/scripting/python/samba/provisionbackend.py
source4/scripting/python/samba/samdb.py
source4/scripting/python/samba/tests/provision.py
source4/scripting/python/samba/upgradehelpers.py

index 776c2740c51340205aa5dce587675a6a9b69d00f..c3446146a7a3d4a3597eb2d1e5ac2b69e92b9dcc 100644 (file)
@@ -145,17 +145,20 @@ class Ldb(ldb.Ldb):
         try:
             res = self.search(base=dn, scope=ldb.SCOPE_SUBTREE, attrs=[],
                       expression="(|(objectclass=user)(objectclass=computer))")
-        except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
-            # Ignore no such object errors
-            return
-            pass
+        except ldb.LdbError, (errno, _):
+            if errno == ldb.ERR_NO_SUCH_OBJECT:
+                # Ignore no such object errors
+                return
+            else:
+                raise
 
         try:
             for msg in res:
                 self.delete(msg.dn)
-        except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
-            # Ignore no such object errors
-            return
+        except ldb.LdbError, (errno, _):
+            if errno != ldb.ERR_NO_SUCH_OBJECT:
+                # Ignore no such object errors
+                raise
 
     def erase_except_schema_controlled(self):
         """Erase this ldb, removing all records, except those that are controlled by Samba4's schema."""
@@ -171,9 +174,10 @@ class Ldb(ldb.Ldb):
                                [], controls=["show_deleted:0"]):
             try:
                 self.delete(msg.dn)
-            except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
-                # Ignore no such object errors
-                pass
+            except ldb.LdbError, (errno, _):
+                if errno != ldb.ERR_NO_SUCH_OBJECT:
+                    # Ignore no such object errors
+                    raise
 
         res = self.search(basedn, ldb.SCOPE_SUBTREE,
                           "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))",
@@ -185,9 +189,10 @@ class Ldb(ldb.Ldb):
                      "@OPTIONS", "@PARTITION", "@KLUDGEACL"]:
             try:
                 self.delete(attr)
-            except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
-                # Ignore missing dn errors
-                pass
+            except ldb.LdbError, (errno, _):
+                if errno != ldb.ERR_NO_SUCH_OBJECT:
+                    # Ignore missing dn errors
+                    raise
 
     def erase(self):
         """Erase this ldb, removing all records."""
@@ -198,9 +203,10 @@ class Ldb(ldb.Ldb):
         for attr in ["@INDEXLIST", "@ATTRIBUTES"]:
             try:
                 self.delete(attr)
-            except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
-                # Ignore missing dn errors
-                pass
+            except ldb.LdbError, (errno, _):
+                if errno != ldb.ERR_NO_SUCH_OBJECT
+                    # Ignore missing dn errors
+                    raise
 
     def erase_partitions(self):
         """Erase an ldb, removing all records."""
@@ -209,18 +215,20 @@ class Ldb(ldb.Ldb):
             try:
                 res = self.search(base=dn, scope=ldb.SCOPE_ONELEVEL, attrs=[],
                                   controls=["show_deleted:0"])
-            except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
-                # Ignore no such object errors
-                return
+            except ldb.LdbError, (errno, _):
+                if errno == ldb.ERR_NO_SUCH_OBJECT:
+                    # Ignore no such object errors
+                    return
 
             for msg in res:
                 erase_recursive(self, msg.dn)
 
             try:
                 self.delete(dn)
-            except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
-                # Ignore no such object errors
-                pass
+            except ldb.LdbError, (errno, _):
+                if errno != ldb.ERR_NO_SUCH_OBJECT:
+                    # Ignore no such object errors
+                    raise
 
         res = self.search("", ldb.SCOPE_BASE, "(objectClass=*)",
                          ["namingContexts"])
index b01b134a4c14acf835b9c263947d8f3d68f839b4..00897515868fc220025e3c84f409b5196a0470c0 100644 (file)
@@ -25,9 +25,9 @@ __docformat__ = "restructuredText"
 import ldb
 
 def messageEltFlagToString(flag):
-       if flag == ldb.FLAG_MOD_ADD:
-               return "MOD_ADD"
-       elif flag == ldb.FLAG_MOD_REPLACE:
-               return "MOD_REPLACE"
-       elif flag == ldb.FLAG_MOD_DELETE:
-               return "MOD_DELETE"
+    if flag == ldb.FLAG_MOD_ADD:
+        return "MOD_ADD"
+    elif flag == ldb.FLAG_MOD_REPLACE:
+        return "MOD_REPLACE"
+    elif flag == ldb.FLAG_MOD_DELETE:
+        return "MOD_DELETE"
index ad2156ae71f91a3379da3ed0af2ba3e0d413d423..edcd643b2a15548cb42c35ce80382c088862941c 100644 (file)
@@ -52,7 +52,7 @@ def getntacl(lp, file, backend=None, eadbfile=None):
     ntacl = ndr_unpack(xattr.NTACL,attribute)
     return ntacl
 
-def setntacl(lp,file,sddl,domsid,backend=None,eadbfile=None):
+def setntacl(lp, file, sddl, domsid, backend=None, eadbfile=None):
     checkset_backend(lp,backend,eadbfile)
     ntacl=xattr.NTACL()
     ntacl.version = 1
@@ -62,12 +62,12 @@ def setntacl(lp,file,sddl,domsid,backend=None,eadbfile=None):
     eadbname = lp.get("posix:eadb")
     if eadbname != None  and eadbname != "":
         try:
-            attribute = samba.xattr_tdb.wrap_setxattr(eadbname,file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
+            samba.xattr_tdb.wrap_setxattr(eadbname,file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
         except:
             print "Fail to open %s"%eadbname
-            attribute = samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
+            samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
     else:
-        attribute = samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
+        samba.xattr_native.wrap_setxattr(file,xattr.XATTR_NTACL_NAME,ndr_pack(ntacl))
 
 def ldapmask2filemask(ldm):
     """Takes the access mask of a DS ACE and transform them in a File ACE mask"""
@@ -138,7 +138,7 @@ def dsacl2fsacl(dssddl, domsid):
     fdescr.revision = ref.revision
     fdescr.sacl = ref.sacl
     aces = ref.dacl.aces
-    for i in range(0,len(aces)):
+    for i in range(0, len(aces)):
         ace = aces[i]
         if not ace.type &  security.SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT and str(ace.trustee) != security.SID_BUILTIN_PREW2K:
         #    if fdescr.type & security.SEC_DESC_DACL_AUTO_INHERITED:
index 57c8e7f25b1bfc30f0663616596159bda30e7b7f..7287a8900ca8273106dca74be7b60283dbaae12f 100644 (file)
@@ -602,7 +602,7 @@ def secretsdb_self_join(secretsdb, domain,
            "privateKeytab"]
     
 
-    msg = ldb.Message(ldb.Dn(secretsdb, "flatname=%s,cn=Primary Domains" % domain));
+    msg = ldb.Message(ldb.Dn(secretsdb, "flatname=%s,cn=Primary Domains" % domain))
     msg["secureChannelType"] = str(secure_channel_type)
     msg["flatname"] = [domain]
     msg["objectClass"] = ["top", "primaryDomain"]
@@ -613,7 +613,7 @@ def secretsdb_self_join(secretsdb, domain,
       msg["realm"] = realm
       msg["saltPrincipal"] = "host/%s.%s@%s" % (netbiosname.lower(), dnsdomain.lower(), realm.upper())
       msg["msDS-KeyVersionNumber"] = [str(key_version_number)]
-      msg["privateKeytab"] = ["secrets.keytab"];
+      msg["privateKeytab"] = ["secrets.keytab"]
 
 
     msg["secret"] = [machinepass]
@@ -971,7 +971,7 @@ def setup_samdb(path, setup_path, session_info, provision_backend, lp,
         setup_add_ldif(samdb, setup_path("aggregate_schema.ldif"), 
                        {"SCHEMADN": names.schemadn})
 
-        message("Reopening sam.ldb with new schema");
+        message("Reopening sam.ldb with new schema")
         samdb.transaction_commit()
         samdb = Ldb(session_info=admin_session_info,
                     credentials=provision_backend.credentials, lp=lp)
index 649113e6a264a5dfc792728384be7e996fba4662..083f1dc73dbe90bdf64956dd5b29e71ad6290ac3 100644 (file)
@@ -119,7 +119,7 @@ class ExistingBackend(ProvisionBackend):
     def init(self):
         #Check to see that this 'existing' LDAP backend in fact exists
         ldapi_db = Ldb(self.ldapi_uri, credentials=self.credentials)
-        search_ol_rootdse = ldapi_db.search(base="", scope=SCOPE_BASE,
+        ldapi_db.search(base="", scope=SCOPE_BASE,
                                             expression="(objectClass=OpenLDAProotDSE)")
 
         # If we have got here, then we must have a valid connection to the LDAP server, with valid credentials supplied
@@ -170,7 +170,7 @@ class LDAPBackend(ProvisionBackend):
         try:
             ldapi_db = Ldb(self.ldapi_uri)
             ldapi_db.search(base="", scope=SCOPE_BASE,
-                expression="(objectClass=OpenLDAProotDSE)");
+                expression="(objectClass=OpenLDAProotDSE)")
             try:
                 f = open(self.paths.slapdpid, "r")
                 p = f.read()
@@ -204,7 +204,7 @@ class LDAPBackend(ProvisionBackend):
         except OSError:
             pass
 
-        self.schema.write_to_tmp_ldb(schemadb_path);
+        self.schema.write_to_tmp_ldb(schemadb_path)
 
         self.credentials = Credentials()
         self.credentials.guess(self.lp)
@@ -243,7 +243,6 @@ class LDAPBackend(ProvisionBackend):
                 return
             except LdbError:
                 time.sleep(1)
-                pass
         
         raise ProvisioningError("slapd died before we could make a connection to it")
 
@@ -297,7 +296,7 @@ class OpenLDAPBackend(LDAPBackend):
                 self.domainsid,
                 schemadn=self.names.schemadn,
                 serverdn=self.names.serverdn,
-                files=[setup_path("schema_samba4.ldif")]);
+                files=[setup_path("schema_samba4.ldif")])
 
     def provision(self):
         # Wipe the directories so we can start
@@ -674,7 +673,7 @@ class FDSBackend(LDAPBackend):
         fedora_ds_dir = os.path.join(self.paths.ldapdir, "slapd-samba4")
         shutil.rmtree(fedora_ds_dir, True)
 
-        self.slapd_provision_command = [self.slapd_path, "-D", fedora_ds_dir, "-i", self.paths.slapdpid];
+        self.slapd_provision_command = [self.slapd_path, "-D", fedora_ds_dir, "-i", self.paths.slapdpid]
         #In the 'provision' command line, stay in the foreground so we can easily kill it
         self.slapd_provision_command.append("-d0")
 
index 39cf1d6c406ed87c7cd0bc7fda04e16a8140a061..f3622fe1b1a1789c79dda7f7f7df2d75b3efb8d0 100644 (file)
@@ -229,5 +229,5 @@ accountExpires: %u
         except:
             self.transaction_cancel()
             raise
-        self.transaction_commit();
+        self.transaction_commit()
 
index 692477da10c1ae883a59c7cca0129652fd01bbfc..45c237f373e84ed36b125e8a8c82b4f357150f06 100644 (file)
@@ -62,6 +62,7 @@ class FindNssTests(unittest.TestCase):
 
 
 class Disabled(object):
+
     def test_setup_templatesdb(self):
         raise NotImplementedError(self.test_setup_templatesdb)
 
index 31af490b6c68d8120cfb855462e94a03805b8ff4..57c7feeb4f899ad7ac855c67f58fc00e2fb8fc1a 100755 (executable)
@@ -27,7 +27,6 @@ import string
 import re
 import shutil
 
-import samba
 from samba import Ldb, DS_DOMAIN_FUNCTION_2000
 from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE
 import ldb