mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
PEP8: fix E711: comparison to None should be 'if cond is not None:'
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
cabb299749
commit
e940e4cd48
@ -975,7 +975,7 @@ class DCJoinContext(object):
|
||||
repl.replicate(ctx.new_krbtgt_dn, source_dsa_invocation_id,
|
||||
destination_dsa_guid,
|
||||
exop=drsuapi.DRSUAPI_EXOP_REPL_SECRET, rodc=True)
|
||||
elif ctx.rid_manager_dn != None:
|
||||
elif ctx.rid_manager_dn is not None:
|
||||
# Try and get a RID Set if we can. This is only possible against the RID Master. Warn otherwise.
|
||||
try:
|
||||
repl.replicate(ctx.rid_manager_dn, source_dsa_invocation_id,
|
||||
|
@ -56,7 +56,7 @@ class cmd_delegation_show(Command):
|
||||
creds = credopts.get_credentials(lp)
|
||||
paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
|
||||
|
||||
if H == None:
|
||||
if H is None:
|
||||
path = paths.samdb
|
||||
else:
|
||||
path = H
|
||||
@ -121,7 +121,7 @@ class cmd_delegation_for_any_service(Command):
|
||||
lp = sambaopts.get_loadparm()
|
||||
creds = credopts.get_credentials(lp)
|
||||
paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
|
||||
if H == None:
|
||||
if H is None:
|
||||
path = paths.samdb
|
||||
else:
|
||||
path = H
|
||||
@ -174,7 +174,7 @@ class cmd_delegation_for_any_protocol(Command):
|
||||
lp = sambaopts.get_loadparm()
|
||||
creds = credopts.get_credentials(lp, fallback_machine=True)
|
||||
paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
|
||||
if H == None:
|
||||
if H is None:
|
||||
path = paths.samdb
|
||||
else:
|
||||
path = H
|
||||
@ -219,7 +219,7 @@ class cmd_delegation_add_service(Command):
|
||||
lp = sambaopts.get_loadparm()
|
||||
creds = credopts.get_credentials(lp)
|
||||
paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
|
||||
if H == None:
|
||||
if H is None:
|
||||
path = paths.samdb
|
||||
else:
|
||||
path = H
|
||||
@ -273,7 +273,7 @@ class cmd_delegation_del_service(Command):
|
||||
lp = sambaopts.get_loadparm()
|
||||
creds = credopts.get_credentials(lp)
|
||||
paths = provision.provision_paths_from_lp(lp, lp.get("realm"))
|
||||
if H == None:
|
||||
if H is None:
|
||||
path = paths.samdb
|
||||
else:
|
||||
path = H
|
||||
|
@ -32,7 +32,7 @@ class SimplePamTests(samba.tests.TestCase):
|
||||
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc)
|
||||
res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password])
|
||||
|
||||
self.assertTrue(res != None)
|
||||
self.assertTrue(res is not None)
|
||||
|
||||
def test_authenticate_error(self):
|
||||
domain = os.environ["DOMAIN"]
|
||||
@ -44,7 +44,7 @@ class SimplePamTests(samba.tests.TestCase):
|
||||
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc)
|
||||
res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password])
|
||||
|
||||
self.assertTrue(res != None)
|
||||
self.assertTrue(res is not None)
|
||||
|
||||
# Authenticate again to check that we are not locked out with just one
|
||||
# failed login
|
||||
@ -54,4 +54,4 @@ class SimplePamTests(samba.tests.TestCase):
|
||||
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc)
|
||||
res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password])
|
||||
|
||||
self.assertTrue(res != None)
|
||||
self.assertTrue(res is not None)
|
||||
|
@ -33,7 +33,7 @@ class PasswordExpirePamTests(samba.tests.TestCase):
|
||||
tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rc)
|
||||
res = pypamtest.run_pamtest(unix_username, "samba", [tc], [password])
|
||||
|
||||
self.assertTrue(res != None)
|
||||
self.assertTrue(res is not None)
|
||||
if warn_pwd_expire == 0:
|
||||
self.assertTrue(res.info == ())
|
||||
elif warn_pwd_expire == 50:
|
||||
|
@ -133,7 +133,7 @@ class PassWordHashGpgmeTests(PassWordHashTests):
|
||||
sc = self.get_supplemental_creds()
|
||||
if expect_cleartext:
|
||||
(pos, ct_package) = get_package(sc, "Primary:CLEARTEXT")
|
||||
self.assertTrue(ct_package != None, "Failed to retrieve cleartext")
|
||||
self.assertTrue(ct_package is not None, "Failed to retrieve cleartext")
|
||||
|
||||
# Check the clear-text value is correct.
|
||||
ct = ndr_unpack(drsblobs.package_PrimaryCLEARTEXTBlob,
|
||||
@ -141,7 +141,7 @@ class PassWordHashGpgmeTests(PassWordHashTests):
|
||||
self.assertEquals(password.encode('utf-16-le'), ct.cleartext)
|
||||
else:
|
||||
ct_package = get_package(sc, "Primary:CLEARTEXT")
|
||||
self.assertTrue(ct_package == None,
|
||||
self.assertTrue(ct_package is None,
|
||||
"Got cleartext when we shouldn't have")
|
||||
|
||||
def test_supplementalCredentials_cleartext_pso(self):
|
||||
|
@ -229,19 +229,19 @@ class SimpleDirsyncTests(DirsyncBaseTests):
|
||||
expression="samaccountname=*",
|
||||
controls=["dirsync:1:0:1"])
|
||||
# Check that nTSecurityDescriptor is returned as it's the case when doing dirsync
|
||||
self.assertTrue(res.msgs[0].get("ntsecuritydescriptor") != None)
|
||||
self.assertTrue(res.msgs[0].get("ntsecuritydescriptor") is not None)
|
||||
# Check that non replicated attributes are not returned
|
||||
self.assertTrue(res.msgs[0].get("badPwdCount") == None)
|
||||
self.assertTrue(res.msgs[0].get("badPwdCount") is None)
|
||||
# Check that non forward link are not returned
|
||||
self.assertTrue(res.msgs[0].get("memberof") == None)
|
||||
self.assertTrue(res.msgs[0].get("memberof") is None)
|
||||
|
||||
# Asking for instanceType will return also objectGUID
|
||||
res = self.ldb_admin.search(self.base_dn,
|
||||
expression="samaccountname=Administrator",
|
||||
attrs=["instanceType"],
|
||||
controls=["dirsync:1:0:1"])
|
||||
self.assertTrue(res.msgs[0].get("objectGUID") != None)
|
||||
self.assertTrue(res.msgs[0].get("instanceType") != None)
|
||||
self.assertTrue(res.msgs[0].get("objectGUID") is not None)
|
||||
self.assertTrue(res.msgs[0].get("instanceType") is not None)
|
||||
|
||||
# We don't return an entry if asked for objectGUID
|
||||
res = self.ldb_admin.search(self.base_dn,
|
||||
@ -255,10 +255,10 @@ class SimpleDirsyncTests(DirsyncBaseTests):
|
||||
expression="(distinguishedName=%s)" % str(self.base_dn),
|
||||
attrs=["name"],
|
||||
controls=["dirsync:1:0:1"])
|
||||
self.assertTrue(res.msgs[0].get("objectGUID") != None)
|
||||
self.assertTrue(res.msgs[0].get("name") != None)
|
||||
self.assertTrue(res.msgs[0].get("parentGUID") == None)
|
||||
self.assertTrue(res.msgs[0].get("instanceType") != None)
|
||||
self.assertTrue(res.msgs[0].get("objectGUID") is not None)
|
||||
self.assertTrue(res.msgs[0].get("name") is not None)
|
||||
self.assertTrue(res.msgs[0].get("parentGUID") is None)
|
||||
self.assertTrue(res.msgs[0].get("instanceType") is not None)
|
||||
|
||||
# Asking for name will return also objectGUID and parentGUID
|
||||
# and instanceType and of course name
|
||||
@ -266,10 +266,10 @@ class SimpleDirsyncTests(DirsyncBaseTests):
|
||||
expression="samaccountname=Administrator",
|
||||
attrs=["name"],
|
||||
controls=["dirsync:1:0:1"])
|
||||
self.assertTrue(res.msgs[0].get("objectGUID") != None)
|
||||
self.assertTrue(res.msgs[0].get("name") != None)
|
||||
self.assertTrue(res.msgs[0].get("parentGUID") != None)
|
||||
self.assertTrue(res.msgs[0].get("instanceType") != None)
|
||||
self.assertTrue(res.msgs[0].get("objectGUID") is not None)
|
||||
self.assertTrue(res.msgs[0].get("name") is not None)
|
||||
self.assertTrue(res.msgs[0].get("parentGUID") is not None)
|
||||
self.assertTrue(res.msgs[0].get("instanceType") is not None)
|
||||
|
||||
# Asking for dn will not return not only DN but more like if attrs=*
|
||||
# parentGUID should be returned
|
||||
@ -366,7 +366,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
|
||||
controls=["dirsync:1:0:0"])
|
||||
self.assertEqual(len(res.msgs), nb - 1)
|
||||
if nb > 1:
|
||||
self.assertTrue(res.msgs[0].get("objectGUID") != None)
|
||||
self.assertTrue(res.msgs[0].get("objectGUID") is not None)
|
||||
else:
|
||||
res = self.ldb_admin.search(self.base_dn,
|
||||
expression="(objectclass=configuration)",
|
||||
@ -454,8 +454,8 @@ class SimpleDirsyncTests(DirsyncBaseTests):
|
||||
expression="(&(objectClass=organizationalUnit)(!(isDeleted=*)))",
|
||||
controls=[control3])
|
||||
|
||||
self.assertTrue(res[0].get("parentGUID") != None)
|
||||
self.assertTrue(res[0].get("name") != None)
|
||||
self.assertTrue(res[0].get("parentGUID") is not None)
|
||||
self.assertTrue(res[0].get("name") is not None)
|
||||
delete_force(self.ldb_admin, ouname)
|
||||
|
||||
def test_dirsync_linkedattributes(self):
|
||||
@ -571,7 +571,7 @@ class SimpleDirsyncTests(DirsyncBaseTests):
|
||||
guid2 = str(ndr_unpack(misc.GUID, res[0].get("objectGUID")[0]))
|
||||
self.assertEqual(guid2, guid)
|
||||
self.assertTrue(res[0].get("isDeleted"))
|
||||
self.assertTrue(res[0].get("name") != None)
|
||||
self.assertTrue(res[0].get("name") is not None)
|
||||
|
||||
def test_cookie_from_others(self):
|
||||
res = self.ldb_admin.search(self.base_dn,
|
||||
@ -596,7 +596,7 @@ class ExtendedDirsyncTests(SimpleDirsyncTests):
|
||||
expression="(name=Administrators)",
|
||||
controls=["dirsync:1:%d:1" % flag_incr_linked])
|
||||
|
||||
self.assertTrue(res[0].get("member;range=1-1") != None)
|
||||
self.assertTrue(res[0].get("member;range=1-1") is not None)
|
||||
self.assertTrue(len(res[0].get("member;range=1-1")) > 0)
|
||||
size = len(res[0].get("member;range=1-1"))
|
||||
|
||||
@ -673,7 +673,7 @@ class ExtendedDirsyncTests(SimpleDirsyncTests):
|
||||
if str(e["name"]) == "testou3":
|
||||
guid = str(ndr_unpack(misc.GUID, e.get("objectGUID")[0]))
|
||||
|
||||
self.assertTrue(guid != None)
|
||||
self.assertTrue(guid is not None)
|
||||
ctl = str(res.controls[0]).split(":")
|
||||
ctl[1] = "1"
|
||||
ctl[2] = "1"
|
||||
|
@ -96,7 +96,7 @@ cont = 0
|
||||
if (len(ctrls)):
|
||||
for ctl in ctrls:
|
||||
cookie = printdirsync(ctl)
|
||||
if cookie != None:
|
||||
if cookie is not None:
|
||||
cont = (ctl.split(':'))[1]
|
||||
print("Returned %d entries" % len(msgs))
|
||||
|
||||
@ -112,7 +112,7 @@ while (cont == "1"):
|
||||
if (len(ctrls)):
|
||||
for ctl in ctrls:
|
||||
cookie = printdirsync(ctl)
|
||||
if cookie != None:
|
||||
if cookie is not None:
|
||||
cont = (ctl.split(':'))[1]
|
||||
print("Returned %d entries" % len(msgs))
|
||||
|
||||
|
@ -240,7 +240,7 @@ if __name__ == "__main__":
|
||||
|
||||
while True:
|
||||
(level, ctr) = drs_conn.DsGetNCChanges(drs_handle, 8, req8)
|
||||
if ctr.first_object == None and ctr.object_count != 0:
|
||||
if ctr.first_object is None and ctr.object_count != 0:
|
||||
raise RuntimeError("DsGetNCChanges: NULL first_object with object_count=%u" % (ctr.object_count))
|
||||
|
||||
obj_item = ctr.first_object
|
||||
|
@ -138,7 +138,7 @@ class DrsMoveObjectTestCase(drs_base.DrsBaseTestCase):
|
||||
version, o.version))
|
||||
i = i + 1
|
||||
|
||||
if drs == None:
|
||||
if drs is None:
|
||||
return
|
||||
|
||||
req8 = DsGetNCChangesRequest8()
|
||||
|
@ -515,7 +515,7 @@ options {
|
||||
i = child.exitstatus
|
||||
if wait_for_fail:
|
||||
# wait for timeout or fail
|
||||
if i == None or i > 0:
|
||||
if i is None or i > 0:
|
||||
return
|
||||
else:
|
||||
if i == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user