From: Joseph Sutton Date: Thu, 5 May 2022 09:32:13 +0000 (+1200) Subject: python: Remove redundant assignments X-Git-Tag: talloc-2.3.4~213 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=455c083ec375a58a648021543ac51faca02bc0b6;p=thirdparty%2Fsamba.git python: Remove redundant assignments Signed-off-by: Joseph Sutton Reviewed-by: Andreas Schneider --- diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py index c0a330b1b5e..66adf40307e 100644 --- a/buildtools/wafsamba/samba_deps.py +++ b/buildtools/wafsamba/samba_deps.py @@ -1181,7 +1181,7 @@ def generate_clangdb(bld): lst = tg.tasks for task in lst: try: - cmd = task.last_cmd + task.last_cmd except AttributeError: continue if isinstance(task, task_classes): diff --git a/python/examples/dnsserver.py b/python/examples/dnsserver.py index 5d726267ab3..caca9980b66 100755 --- a/python/examples/dnsserver.py +++ b/python/examples/dnsserver.py @@ -39,16 +39,16 @@ if __name__ == "__main__": dns_conn = dnsserver.dnsserver(binding_str, lp, creds) print("querying a NS record") - res = dns_conn.DnssrvEnumRecords2(0x00070000, - 0, - server, - dnszone, - newname, - None, - dnsp.DNS_TYPE_NS, - 0x0f, - None, - None) + dns_conn.DnssrvEnumRecords2(0x00070000, + 0, + server, + dnszone, + newname, + None, + dnsp.DNS_TYPE_NS, + 0x0f, + None, + None) print("adding a NS glue record") name = dnsserver.DNS_RPC_NAME() @@ -66,22 +66,22 @@ if __name__ == "__main__": addrecbuf = dnsserver.DNS_RPC_RECORD_BUF() addrecbuf.rec = addrec - res = dns_conn.DnssrvUpdateRecord2(0x00070000, - 0, - server, - dnszone, - newname, - addrecbuf, - None) + dns_conn.DnssrvUpdateRecord2(0x00070000, + 0, + server, + dnszone, + newname, + addrecbuf, + None) print("querying the NS record") - res = dns_conn.DnssrvEnumRecords2(0x00070000, - 0, - server, - dnszone, - newname, - None, - dnsp.DNS_TYPE_NS, - 0x0f, - None, - None) + dns_conn.DnssrvEnumRecords2(0x00070000, + 0, + server, + dnszone, + newname, + None, + dnsp.DNS_TYPE_NS, + 0x0f, + None, + None) diff --git a/python/samba/__init__.py b/python/samba/__init__.py index 0e6a33322f8..ec540a61521 100644 --- a/python/samba/__init__.py +++ b/python/samba/__init__.py @@ -369,7 +369,6 @@ interface_ips = _glue.interface_ips fault_setup = _glue.fault_setup set_debug_level = _glue.set_debug_level get_debug_level = _glue.get_debug_level -unix2nttime = _glue.unix2nttime float2nttime = _glue.float2nttime nttime2float = _glue.nttime2float nttime2string = _glue.nttime2string diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py index c0f27808c46..7c4d3f9bc6a 100644 --- a/python/samba/netcmd/dns.py +++ b/python/samba/netcmd/dns.py @@ -878,9 +878,9 @@ class cmd_zonecreate(Command): zone_create_info.fLoadExisting = 1 zone_create_info.dwDpFlags = dnsserver.DNS_DP_DOMAIN_DEFAULT - res = dns_conn.DnssrvOperation2(client_version, 0, server, None, - 0, 'ZoneCreate', typeid, - zone_create_info) + dns_conn.DnssrvOperation2(client_version, 0, server, None, + 0, 'ZoneCreate', typeid, + zone_create_info) typeid = dnsserver.DNSSRV_TYPEID_NAME_AND_PARAM name_and_param = dnsserver.DNS_RPC_NAME_AND_PARAM() @@ -888,9 +888,9 @@ class cmd_zonecreate(Command): name_and_param.dwParam = dnsp.DNS_ZONE_UPDATE_SECURE try: - res = dns_conn.DnssrvOperation2(client_version, 0, server, zone, - 0, 'ResetDwordProperty', typeid, - name_and_param) + dns_conn.DnssrvOperation2(client_version, 0, server, zone, + 0, 'ResetDwordProperty', typeid, + name_and_param) except WERRORError as e: if e.args[0] == werror.WERR_DNS_ERROR_ZONE_ALREADY_EXISTS: self.outf.write('Zone already exists.') diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 71664e66212..6b38e4e372b 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -733,7 +733,7 @@ class cmd_setlink(GPOCommand): # Check if valid GPO DN try: - msg = get_gpo_info(self.samdb, gpo=gpo)[0] + get_gpo_info(self.samdb, gpo=gpo)[0] except Exception: raise CommandError("GPO '%s' does not exist" % gpo) gpo_dn = str(get_gpo_dn(self.samdb, gpo)) diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index 1d830e3082f..762047c467b 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -604,11 +604,8 @@ class LDAPObject(object): continue # Attribute values that are list that contain DN based values that may differ elif x.upper() in self.dn_attributes: - m = p - n = q - if not p and not q: - m = self.attributes[x] - n = other.attributes[x] + m = self.attributes[x] + n = other.attributes[x] p = [self.fix_dn(j) for j in m] q = [other.fix_dn(j) for j in n] if p == q: diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index 70be85c406a..24f66ffbd91 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -153,8 +153,7 @@ def get_crypt_value(alg, utf8pw, rounds=0): try: import hashlib - h = hashlib.sha1() - h = None + hashlib.sha1() virtual_attributes["virtualSSHA"] = { } except ImportError as e: @@ -167,8 +166,7 @@ except ImportError as e: for (alg, attr) in [("5", "virtualCryptSHA256"), ("6", "virtualCryptSHA512")]: try: import crypt - v = get_crypt_value(alg, "") - v = None + get_crypt_value(alg, "") virtual_attributes[attr] = { } except ImportError as e: @@ -3262,7 +3260,6 @@ class cmd_user_rename(Command): for s in msg['uPNSuffixes']: upn_suffixes.append(str(s).lower()) - upn_suffix = upn.split('@')[-1].lower() upn_split = upn.split('@') if (len(upn_split) < 2): return False diff --git a/python/samba/provision/sambadns.py b/python/samba/provision/sambadns.py index 6823f9ee56b..79cb4c998fa 100644 --- a/python/samba/provision/sambadns.py +++ b/python/samba/provision/sambadns.py @@ -267,7 +267,6 @@ def setup_dns_partitions(samdb, domainsid, domaindn, forestdn, configdn, "SECDESC": b64encode(descriptor).decode('utf8') }) - domainzone_guid = get_domainguid(samdb, domainzone_dn) domainzone_guid = str(uuid.uuid4()) domainzone_dns = ldb.Dn(samdb, domainzone_dn).canonical_ex_str().strip() @@ -289,7 +288,6 @@ def setup_dns_partitions(samdb, domainsid, domaindn, forestdn, configdn, }) if fill_level != FILL_SUBDOMAIN: - forestzone_guid = get_domainguid(samdb, forestzone_dn) forestzone_guid = str(uuid.uuid4()) forestzone_dns = ldb.Dn(samdb, forestzone_dn).canonical_ex_str().strip() diff --git a/python/samba/samdb.py b/python/samba/samdb.py index 5e4f07bb679..fa9036b2b7b 100644 --- a/python/samba/samdb.py +++ b/python/samba/samdb.py @@ -900,7 +900,6 @@ unicodePwd:: %s user_dn = res[0].dn userAccountControl = int(res[0]["userAccountControl"][0]) - accountExpires = int(res[0]["accountExpires"][0]) if no_expiry_req: userAccountControl = userAccountControl | 0x10000 accountExpires = 0 diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py index c853668058e..d6e81c07635 100644 --- a/python/samba/upgradehelpers.py +++ b/python/samba/upgradehelpers.py @@ -358,8 +358,6 @@ def update_secrets(newsecrets_ldb, secrets_ldb, messagefunc): for entry in listMissing: reference = newsecrets_ldb.search(expression="distinguishedName=%s" % entry, base="", scope=SCOPE_SUBTREE) - current = secrets_ldb.search(expression="distinguishedName=%s" % entry, - base="", scope=SCOPE_SUBTREE) delta = secrets_ldb.msg_diff(empty, reference[0]) for att in hashAttrNotCopied: delta.remove(att) diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate index de39ac39cad..1ce53f5dc39 100755 --- a/source4/scripting/bin/samba_dnsupdate +++ b/source4/scripting/bin/samba_dnsupdate @@ -428,7 +428,7 @@ def call_nsupdate(d, op="add"): rfile = open(opts.use_file, 'r+') except IOError: # Perhaps create it - rfile = open(opts.use_file, 'w+') + open(opts.use_file, 'w+') # Open it for reading again, in case someone else got to it first rfile = open(opts.use_file, 'r+') fcntl.lockf(rfile, fcntl.LOCK_EX) @@ -746,7 +746,7 @@ try: cfile = open(dns_update_cache, 'r+') except IOError: # Perhaps create it - cfile = open(dns_update_cache, 'w+') + open(dns_update_cache, 'w+') # Open it for reading again, in case someone else got to it first cfile = open(dns_update_cache, 'r+') fcntl.lockf(cfile, fcntl.LOCK_EX) diff --git a/source4/scripting/devel/demodirsync.py b/source4/scripting/devel/demodirsync.py index 09c316a67d1..e21dbbcb66b 100755 --- a/source4/scripting/devel/demodirsync.py +++ b/source4/scripting/devel/demodirsync.py @@ -80,7 +80,7 @@ controls = ["dirsync:1:1:50:%s" % base64.b64encode(ndr_pack(cookie)).decode('utf (msgs, ctrls) = remote_ldb.searchex(expression="(samaccountname=*)", base=base, attrs=["objectClass"], controls=controls) if (len(ctrls)): for ctl in ctrls: - cookie = printdirsync(ctl) + printdirsync(ctl) print("Returned %d entries" % len(msgs)) cookie = savedcookie