summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/provision.py2
-rw-r--r--source4/scripting/python/samba/tests/upgradeprovisionneeddc.py25
-rwxr-xr-xsource4/scripting/python/samba/upgradehelpers.py24
3 files changed, 28 insertions, 23 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index ca62b6062f..e899534954 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -1497,7 +1497,7 @@ def provision(setup_dir, logger, session_info,
lastProvisionUSNs = get_last_provision_usn(samdb)
maxUSN = get_max_usn(samdb, str(names.rootdn))
- if lastProvisionUSNs != None:
+ if lastProvisionUSNs is not None:
update_provision_usn(samdb, 0, maxUSN, 1)
else:
set_provision_usn(samdb, 0, maxUSN)
diff --git a/source4/scripting/python/samba/tests/upgradeprovisionneeddc.py b/source4/scripting/python/samba/tests/upgradeprovisionneeddc.py
index 3b0a695d83..e400e17168 100644
--- a/source4/scripting/python/samba/tests/upgradeprovisionneeddc.py
+++ b/source4/scripting/python/samba/tests/upgradeprovisionneeddc.py
@@ -28,7 +28,8 @@ from samba.provision import getpolicypath
from samba.upgradehelpers import (get_paths, get_ldbs,
find_provision_key_parameters, identic_rename,
updateOEMInfo, getOEMInfo, update_gpo,
- delta_update_basesamdb,search_constructed_attrs_stored)
+ delta_update_basesamdb,
+ search_constructed_attrs_stored)
from samba.tests import env_loadparm, TestCaseInTempDir
from samba.tests.provision import create_dummy_secretsdb
import ldb
@@ -61,8 +62,8 @@ class UpgradeProvisionBasicLdbHelpersTestCase(TestCaseInTempDir):
paths, smb_conf_path, lp)
self.assertEquals(names.realm, "SAMBA.EXAMPLE.COM")
self.assertEquals(str(names.rootdn).lower(), rootdn.lower())
- self.assertTrue(names.policyid_dc != None)
- self.assertTrue(names.ntdsguid != "")
+ self.assertNotEquals(names.policyid_dc, None)
+ self.assertNotEquals(names.ntdsguid, "")
class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
@@ -78,8 +79,9 @@ class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
self.creds.guess(self.lp)
self.paths = paths
self.ldbs = get_ldbs(paths, self.creds, system_session(), self.lp)
- self.names = find_provision_key_parameters(self.ldbs.sam, self.ldbs.secrets,
- self.ldbs.idmap, paths, smb_conf_path, self.lp)
+ self.names = find_provision_key_parameters(self.ldbs.sam,
+ self.ldbs.secrets, self.ldbs.idmap, paths, smb_conf_path,
+ self.lp)
self.referencedb = create_dummy_secretsdb(
os.path.join(self.tempdir, "ref.ldb"))
@@ -102,10 +104,12 @@ class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
def test_delta_update_basesamdb(self):
dummysampath = self._getEmptyDbName()
delta_update_basesamdb(self.paths.samdb, dummysampath,
- self.creds, system_session(), self.lp, dummymessage)
+ self.creds, system_session(), self.lp,
+ dummymessage)
def test_update_gpo_simple(self):
- dir = getpolicypath(self.paths.sysvol, self.names.dnsdomain, self.names.policyid)
+ dir = getpolicypath(self.paths.sysvol, self.names.dnsdomain,
+ self.names.policyid)
shutil.rmtree(dir)
self.assertFalse(os.path.isdir(dir))
update_gpo(self.paths, self.ldbs.sam, self.names, self.lp, dummymessage)
@@ -117,7 +121,8 @@ class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
self.paths.sysvol = path
os.mkdir(path)
os.mkdir(os.path.join(path, self.names.dnsdomain))
- os.mkdir(os.path.join(os.path.join(path, self.names.dnsdomain), "Policies"))
+ os.mkdir(os.path.join(os.path.join(path, self.names.dnsdomain),
+ "Policies"))
update_gpo(self.paths, self.ldbs.sam, self.names, self.lp, dummymessage)
shutil.rmtree(path)
self.paths.sysvol = save
@@ -126,7 +131,7 @@ class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
realm = self.lp.get("realm")
basedn = "DC=%s" % realm.replace(".", ", DC=")
oem = getOEMInfo(self.ldbs.sam, basedn)
- self.assertTrue(oem != "")
+ self.assertNotEquals(oem, "")
def test_updateOEMInfo(self):
realm = self.lp.get("realm")
@@ -134,7 +139,7 @@ class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
oem = getOEMInfo(self.ldbs.sam, basedn)
updateOEMInfo(self.ldbs.sam, basedn)
oem2 = getOEMInfo(self.ldbs.sam, basedn)
- self.assertTrue(str(oem) != str(oem2))
+ self.assertNotEquals(str(oem), str(oem2))
self.assertTrue(re.match(".*upgrade to.*", str(oem2)))
def tearDown(self):
diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py
index 428d43450f..7c6afaec5b 100755
--- a/source4/scripting/python/samba/upgradehelpers.py
+++ b/source4/scripting/python/samba/upgradehelpers.py
@@ -319,7 +319,7 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, lp)
"objectSid","msDS-Behavior-Version" ])
names.domainguid = str(ndr_unpack(misc.GUID, res6[0]["objectGUID"][0]))
names.domainsid = ndr_unpack( security.dom_sid, res6[0]["objectSid"][0])
- if res6[0].get("msDS-Behavior-Version") == None or \
+ if res6[0].get("msDS-Behavior-Version") is None or \
int(res6[0]["msDS-Behavior-Version"][0]) < DS_DOMAIN_FUNCTION_2000:
names.domainlevel = DS_DOMAIN_FUNCTION_2000
else:
@@ -495,31 +495,31 @@ def get_diff_sddls(refsddl, cursddl):
if hash_new.has_key(part) and hash_ref.has_key(part):
# both are present, check if they contain the same ACE
- h_new = {}
- h_ref = {}
+ h_new = set()
+ h_ref = set()
c_new = chunck_acl(hash_new[part])
c_ref = chunck_acl(hash_ref[part])
for elem in c_new["aces"]:
- h_new[elem] = 1
+ h_new.add(elem)
for elem in c_ref["aces"]:
- h_ref[elem] = 1
+ h_ref.add(elem)
- for k in h_ref.keys():
+ for k in h_ref:
if h_new.has_key(k):
- h_new.pop(k)
- h_ref.pop(k)
+ h_new.remove(k)
+ h_ref.remove(k)
- if len(h_new.keys()) + len(h_ref.keys()) > 0:
+ if len(h_new) + len(h_ref) > 0:
txt = "%s\tPart %s is different between reference" \
" and current here is the detail:\n" % (txt, part)
- for item in h_new.keys():
+ for item in h_new:
txt = "%s\t\t%s ACE is not present in the" \
" reference\n" % (txt, item)
- for item in h_ref.keys():
+ for item in h_ref:
txt = "%s\t\t%s ACE is not present in the" \
" current\n" % (txt, item)
@@ -692,7 +692,7 @@ def update_gpo(paths, samdb, names, lp, message, force=0):
if not os.path.isdir(dir):
create_gpo_struct(dir)
- if names.policyid_dc == None:
+ if names.policyid_dc is None:
raise ProvisioningError("Policy ID for Domain controller is missing")
dir = getpolicypath(paths.sysvol, names.dnsdomain, names.policyid_dc)
if not os.path.isdir(dir):