summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-03-01 05:04:23 +0100
committerJelmer Vernooij <jelmer@samba.org>2010-03-01 16:24:58 +0100
commit86e2b251861055d770327639808fddc84cdb0b56 (patch)
treeb7e882711fe8a18fd67f9bd4cd07ad2ab8d565ab
parent719cecba848b3e446ea3bc06f14cf90e9cddab9e (diff)
downloadsamba-86e2b251861055d770327639808fddc84cdb0b56.tar.gz
samba-86e2b251861055d770327639808fddc84cdb0b56.tar.bz2
samba-86e2b251861055d770327639808fddc84cdb0b56.zip
More formatting fixes, pointed out by pylint.
-rw-r--r--source4/scripting/python/samba/__init__.py52
-rw-r--r--source4/scripting/python/samba/misc.py12
-rw-r--r--source4/scripting/python/samba/ntacls.py10
-rw-r--r--source4/scripting/python/samba/provision.py6
-rw-r--r--source4/scripting/python/samba/provisionbackend.py11
-rw-r--r--source4/scripting/python/samba/samdb.py2
-rw-r--r--source4/scripting/python/samba/tests/provision.py1
-rwxr-xr-xsource4/scripting/python/samba/upgradehelpers.py1
8 files changed, 51 insertions, 44 deletions
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index 776c2740c5..c3446146a7 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -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"])
diff --git a/source4/scripting/python/samba/misc.py b/source4/scripting/python/samba/misc.py
index b01b134a4c..0089751586 100644
--- a/source4/scripting/python/samba/misc.py
+++ b/source4/scripting/python/samba/misc.py
@@ -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"
diff --git a/source4/scripting/python/samba/ntacls.py b/source4/scripting/python/samba/ntacls.py
index ad2156ae71..edcd643b2a 100644
--- a/source4/scripting/python/samba/ntacls.py
+++ b/source4/scripting/python/samba/ntacls.py
@@ -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:
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 57c8e7f25b..7287a8900c 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -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)
diff --git a/source4/scripting/python/samba/provisionbackend.py b/source4/scripting/python/samba/provisionbackend.py
index 649113e6a2..083f1dc73d 100644
--- a/source4/scripting/python/samba/provisionbackend.py
+++ b/source4/scripting/python/samba/provisionbackend.py
@@ -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")
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index 39cf1d6c40..f3622fe1b1 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -229,5 +229,5 @@ accountExpires: %u
except:
self.transaction_cancel()
raise
- self.transaction_commit();
+ self.transaction_commit()
diff --git a/source4/scripting/python/samba/tests/provision.py b/source4/scripting/python/samba/tests/provision.py
index 692477da10..45c237f373 100644
--- a/source4/scripting/python/samba/tests/provision.py
+++ b/source4/scripting/python/samba/tests/provision.py
@@ -62,6 +62,7 @@ class FindNssTests(unittest.TestCase):
class Disabled(object):
+
def test_setup_templatesdb(self):
raise NotImplementedError(self.test_setup_templatesdb)
diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py
index 31af490b6c..57c7feeb4f 100755
--- a/source4/scripting/python/samba/upgradehelpers.py
+++ b/source4/scripting/python/samba/upgradehelpers.py
@@ -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