diff options
author | Joe Guo <joeg@catalyst.net.nz> | 2018-07-30 18:18:25 +1200 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2018-08-24 07:49:28 +0200 |
commit | 87bbc2df972d112870bb7d5c8839663affe62b21 (patch) | |
tree | 165519f190f9d8051c0f56406de925e8ed0c1cb4 /python | |
parent | 32266d2d48c1c38e54bcfaf1cad36f09e9cff355 (diff) | |
download | samba-87bbc2df972d112870bb7d5c8839663affe62b21.tar.gz |
PEP8: fix E226: missing whitespace around arithmetic operator
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>
Diffstat (limited to 'python')
35 files changed, 153 insertions, 153 deletions
diff --git a/python/samba/__init__.py b/python/samba/__init__.py index b5d8d1a4cf6..a79b1fdf473 100644 --- a/python/samba/__init__.py +++ b/python/samba/__init__.py @@ -271,7 +271,7 @@ def check_all_substituted(text): var_end = text.find("}", var_start) raise Exception("Not all variables substituted: %s" % - text[var_start:var_end+1]) + text[var_start:var_end + 1]) def read_and_sub_file(file_name, subst_vars): diff --git a/python/samba/common.py b/python/samba/common.py index 10891e4ce7a..fabbcea13df 100644 --- a/python/samba/common.py +++ b/python/samba/common.py @@ -92,7 +92,7 @@ class dsdb_Dn(object): raise RuntimeError("Invalid DN %s" % dnstring) prefix_len = 4 + len(colons[1]) + int(colons[1]) self.prefix = dnstring[0:prefix_len] - self.binary = self.prefix[3+len(colons[1]):-1] + self.binary = self.prefix[3 + len(colons[1]):-1] self.dnstring = dnstring[prefix_len:] else: self.dnstring = dnstring diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py index 521c8415c1b..6e84f1903c8 100644 --- a/python/samba/dbchecker.py +++ b/python/samba/dbchecker.py @@ -2485,7 +2485,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base))) # check that the dsServiceName is in GUID form if not 'dsServiceName' in obj: self.report('ERROR: dsServiceName missing in @ROOTDSE') - return error_count+1 + return error_count + 1 if not obj['dsServiceName'][0].startswith('<GUID='): self.report('ERROR: dsServiceName not in GUID form in @ROOTDSE') diff --git a/python/samba/gp_sec_ext.py b/python/samba/gp_sec_ext.py index 40999758e0e..79c6abaea22 100644 --- a/python/samba/gp_sec_ext.py +++ b/python/samba/gp_sec_ext.py @@ -20,10 +20,10 @@ from samba.gpclass import gp_ext_setter, gp_inf_ext class inf_to_kdc_tdb(gp_ext_setter): def mins_to_hours(self): - return '%d' % (int(self.val)/60) + return '%d' % (int(self.val) / 60) def days_to_hours(self): - return '%d' % (int(self.val)*24) + return '%d' % (int(self.val) * 24) def set_kdc_tdb(self, val): old_val = self.gp_db.gpostore.get(self.attribute) diff --git a/python/samba/gpclass.py b/python/samba/gpclass.py index c419c363611..07cdff9f212 100644 --- a/python/samba/gpclass.py +++ b/python/samba/gpclass.py @@ -142,7 +142,7 @@ class gp_log: prev = apply_log.find('guid[@value="%s"]' % guid) if prev is None: item = etree.SubElement(apply_log, 'guid') - item.attrib['count'] = '%d' % (len(apply_log)-1) + item.attrib['count'] = '%d' % (len(apply_log) - 1) item.attrib['value'] = guid def apply_log_pop(self): @@ -155,7 +155,7 @@ class gp_log: user_obj = self.gpdb.find('user[@name="%s"]' % self.user) apply_log = user_obj.find('applylog') if apply_log is not None: - ret = apply_log.find('guid[@count="%d"]' % (len(apply_log)-1)) + ret = apply_log.find('guid[@count="%d"]' % (len(apply_log) - 1)) if ret is not None: apply_log.remove(ret) return ret.attrib['value'] @@ -436,7 +436,7 @@ def cache_gpo_dir(conn, cache, sub_dir): def check_safe_path(path): dirs = re.split('/|\\\\', path) if 'sysvol' in path: - dirs = dirs[dirs.index('sysvol')+1:] + dirs = dirs[dirs.index('sysvol') + 1:] if not '..' in dirs: return os.path.join(*dirs) raise OSError(path) diff --git a/python/samba/hostconfig.py b/python/samba/hostconfig.py index 08fff4fdd4c..07916ab7cac 100644 --- a/python/samba/hostconfig.py +++ b/python/samba/hostconfig.py @@ -58,7 +58,7 @@ class SharesContainer(object): def __len__(self): if "global" in self._lp.services(): - return len(self._lp)-1 + return len(self._lp) - 1 return len(self._lp) def keys(self): diff --git a/python/samba/kcc/__init__.py b/python/samba/kcc/__init__.py index eace6612497..8f214f2822d 100644 --- a/python/samba/kcc/__init__.py +++ b/python/samba/kcc/__init__.py @@ -2194,27 +2194,27 @@ class KCC(object): # For each r(i) from (0 <= i < |R|-1) i = 0 - while i < (r_len-1): + while i < (r_len - 1): # Add an edge from r(i) to r(i+1) if r(i) is a full # replica or r(i+1) is a partial replica - if not r_list[i].is_partial() or r_list[i+1].is_partial(): - graph_list[i+1].add_edge_from(r_list[i].rep_dsa_dnstr) + if not r_list[i].is_partial() or r_list[i +1].is_partial(): + graph_list[i + 1].add_edge_from(r_list[i].rep_dsa_dnstr) # Add an edge from r(i+1) to r(i) if r(i+1) is a full # replica or ri is a partial replica. - if not r_list[i+1].is_partial() or r_list[i].is_partial(): - graph_list[i].add_edge_from(r_list[i+1].rep_dsa_dnstr) + if not r_list[i + 1].is_partial() or r_list[i].is_partial(): + graph_list[i].add_edge_from(r_list[i + 1].rep_dsa_dnstr) i = i + 1 # Add an edge from r|R|-1 to r0 if r|R|-1 is a full replica # or r0 is a partial replica. - if not r_list[r_len-1].is_partial() or r_list[0].is_partial(): - graph_list[0].add_edge_from(r_list[r_len-1].rep_dsa_dnstr) + if not r_list[r_len - 1].is_partial() or r_list[0].is_partial(): + graph_list[0].add_edge_from(r_list[r_len - 1].rep_dsa_dnstr) # Add an edge from r0 to r|R|-1 if r0 is a full replica or # r|R|-1 is a partial replica. - if not r_list[0].is_partial() or r_list[r_len-1].is_partial(): - graph_list[r_len-1].add_edge_from(r_list[0].rep_dsa_dnstr) + if not r_list[0].is_partial() or r_list[r_len -1].is_partial(): + graph_list[r_len - 1].add_edge_from(r_list[0].rep_dsa_dnstr) DEBUG("r_list is length %s" % len(r_list)) DEBUG('\n'.join(str((x.rep_dsa_guid, x.rep_dsa_dnstr)) diff --git a/python/samba/ms_forest_updates_markdown.py b/python/samba/ms_forest_updates_markdown.py index efe1654851b..1b288e3e74c 100644 --- a/python/samba/ms_forest_updates_markdown.py +++ b/python/samba/ms_forest_updates_markdown.py @@ -216,7 +216,7 @@ def read_ms_markdown(in_file, out_folder=None, out_dict={}): for node in tree: if node.text and node.text.startswith('|Operation'): # Strip first and last | - updates = [x[1:len(x)-1].split('|') for x in + updates = [x[1:len(x) - 1].split('|') for x in ET.tostring(node,method='text').splitlines()] for update in updates[2:]: output = re.match('Operation (\d+): {(.*)}', update[0]) diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index 7704cb80f5d..556afd71e40 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -30,7 +30,7 @@ class Option(optparse.Option): class PlainHelpFormatter(optparse.IndentedHelpFormatter): def format_description(self,description=""): desc_width = self.width - self.current_indent - indent = " "*self.current_indent + indent = " " * self.current_indent paragraphs = description.split('\n') wrapped_paragraphs = [ textwrap.fill(p, @@ -137,7 +137,7 @@ class Command(object): return parser, optiongroups def message(self, text): - self.outf.write(text+"\n") + self.outf.write(text + "\n") def _run(self, *argv): parser, optiongroups = self._create_parser(argv[0]) diff --git a/python/samba/netcmd/computer.py b/python/samba/netcmd/computer.py index 977c3c42164..6212bd67eea 100644 --- a/python/samba/netcmd/computer.py +++ b/python/samba/netcmd/computer.py @@ -565,7 +565,7 @@ class cmd_computer_move(Command): if not full_new_ou_dn.is_child_of(domain_dn): full_new_ou_dn.add_base(domain_dn) new_computer_dn = ldb.Dn(samdb, str(computer_dn)) - new_computer_dn.remove_base_components(len(computer_dn)-1) + new_computer_dn.remove_base_components(len(computer_dn) -1) new_computer_dn.add_base(full_new_ou_dn) try: samdb.rename(computer_dn, new_computer_dn) diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py index 050a158e2e4..17eef4fe294 100644 --- a/python/samba/netcmd/domain.py +++ b/python/samba/netcmd/domain.py @@ -2385,7 +2385,7 @@ class cmd_domain_trust_create(DomainTrustCommand): # 512 bytes and a 2 bytes confounder is required. # def random_trust_secret(length): - pw = samba.generate_random_machine_password(length//2, length//2) + pw = samba.generate_random_machine_password(length // 2, length // 2) return string_to_byte_array(pw.encode('utf-16-le')) if local_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_INBOUND: diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py index a4ec6338144..cf047769f12 100644 --- a/python/samba/netcmd/group.py +++ b/python/samba/netcmd/group.py @@ -491,7 +491,7 @@ class cmd_group_move(Command): (new_parent_dn, e.message)) full_new_group_dn = ldb.Dn(samdb, str(group_dn)) - full_new_group_dn.remove_base_components(len(group_dn)-1) + full_new_group_dn.remove_base_components(len(group_dn) - 1) full_new_group_dn.add_base(full_new_parent_dn) try: diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index 0a00c452d98..ea2c2ae4cca 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -86,13 +86,13 @@ class LDAPBase(object): # when compare content of two DCs. Uncomment for DEBUG purposes. if self.two_domains and not self.quiet: self.outf.write("\n* Place-holders for %s:\n" % self.host) - self.outf.write(4*" " + "${DOMAIN_DN} => %s\n" % + self.outf.write(4 * " " + "${DOMAIN_DN} => %s\n" % self.base_dn) - self.outf.write(4*" " + "${DOMAIN_NETBIOS} => %s\n" % + self.outf.write(4 * " " + "${DOMAIN_NETBIOS} => %s\n" % self.domain_netbios) - self.outf.write(4*" " + "${SERVER_NAME} => %s\n" % + self.outf.write(4 * " " + "${SERVER_NAME} => %s\n" % self.server_names) - self.outf.write(4*" " + "${DOMAIN_NAME} => %s\n" % + self.outf.write(4 * " " + "${DOMAIN_NAME} => %s\n" % self.domain_name) def find_domain_sid(self): @@ -303,9 +303,9 @@ class Descriptor(object): def diff_1(self, other): res = "" if len(self.dacl_list) != len(other.dacl_list): - res += 4*" " + "Difference in ACE count:\n" - res += 8*" " + "=> %s\n" % len(self.dacl_list) - res += 8*" " + "=> %s\n" % len(other.dacl_list) + res += 4 * " " + "Difference in ACE count:\n" + res += 8 * " " + "=> %s\n" % len(self.dacl_list) + res += 8 * " " + "=> %s\n" % len(other.dacl_list) # i = 0 flag = True @@ -336,9 +336,9 @@ class Descriptor(object): def diff_2(self, other): res = "" if len(self.dacl_list) != len(other.dacl_list): - res += 4*" " + "Difference in ACE count:\n" - res += 8*" " + "=> %s\n" % len(self.dacl_list) - res += 8*" " + "=> %s\n" % len(other.dacl_list) + res += 4 * " " + "Difference in ACE count:\n" + res += 8 * " " + "=> %s\n" % len(self.dacl_list) + res += 8 * " " + "=> %s\n" % len(other.dacl_list) # common_aces = [] self_aces = [] @@ -356,9 +356,9 @@ class Descriptor(object): common_aces.append(ace) self_aces = sorted(self_aces) if len(self_aces) > 0: - res += 4*" " + "ACEs found only in %s:\n" % self.con.host + res += 4 *" " + "ACEs found only in %s:\n" % self.con.host for ace in self_aces: - res += 8*" " + ace + "\n" + res += 8 * " " + ace + "\n" # for ace in other_dacl_list_fixed: try: @@ -369,15 +369,15 @@ class Descriptor(object): common_aces.append(ace) other_aces = sorted(other_aces) if len(other_aces) > 0: - res += 4*" " + "ACEs found only in %s:\n" % other.con.host + res += 4 *" " + "ACEs found only in %s:\n" % other.con.host for ace in other_aces: - res += 8*" " + ace + "\n" + res += 8 * " " + ace + "\n" # common_aces = sorted(list(set(common_aces))) if self.con.verbose: - res += 4*" " + "ACEs found in both:\n" + res += 4 *" " + "ACEs found in both:\n" for ace in common_aces: - res += 8*" " + ace + "\n" + res += 8 * " " + ace + "\n" return (self_aces == [] and other_aces == [], res) class LDAPObject(object): @@ -514,14 +514,14 @@ class LDAPObject(object): Log on the screen if there is no --quiet option set """ if not self.quiet: - self.outf.write(msg+"\n") + self.outf.write(msg +"\n") def fix_dn(self, s): res = "%s" % s if not self.two_domains: return res if res.upper().endswith(self.con.base_dn.upper()): - res = res[:len(res)-len(self.con.base_dn)] + "${DOMAIN_DN}" + res = res[:len(res) - len(self.con.base_dn)] + "${DOMAIN_DN}" return res def fix_domain_name(self, s): @@ -575,29 +575,29 @@ class LDAPObject(object): other.unique_attrs = [] if self.attributes.keys() != other.attributes.keys(): # - title = 4*" " + "Attributes found only in %s:" % self.con.host + title = 4 * " " + "Attributes found only in %s:" % self.con.host for x in self.attributes.keys(): if not x in other.attributes.keys() and \ not x.upper() in [q.upper() for q in other.ignore_attributes]: if title: res += title + "\n" title = None - res += 8*" " + x + "\n" + res += 8 * " " + x + "\n" self.unique_attrs.append(x) # - title = 4*" " + "Attributes found only in %s:" % other.con.host + title = 4 *" " + "Attributes found only in %s:" % other.con.host for x in other.attributes.keys(): if not x in self.attributes.keys() and \ not x.upper() in [q.upper() for q in self.ignore_attributes]: if title: res += title + "\n" title = None - res += 8*" " + x + "\n" + res += 8 * " " + x + "\n" other.unique_attrs.append(x) # missing_attrs = [x.upper() for x in self.unique_attrs] missing_attrs += [x.upper() for x in other.unique_attrs] - title = 4*" " + "Difference in attribute values:" + title = 4 * " " + "Difference in attribute values:" for x in self.attributes.keys(): if x.upper() in self.ignore_attributes or x.upper() in missing_attrs: continue @@ -667,9 +667,9 @@ class LDAPObject(object): res += title + "\n" title = None if p and q: - res += 8*" " + x + " => \n%s\n%s" % (p, q) + "\n" + res += 8 * " " + x + " => \n%s\n%s" % (p, q) + "\n" else: - res += 8*" " + x + " => \n%s\n%s" % (self.attributes[x], other.attributes[x]) + "\n" + res += 8 * " " + x + " => \n%s\n%s" % (self.attributes[x], other.attributes[x]) + "\n" self.df_value_attrs.append(x) # if self.unique_attrs + other.unique_attrs != []: @@ -715,7 +715,7 @@ class LDAPBundel(object): while counter < len(self.dn_list) and self.two_domains: # Use alias reference tmp = self.dn_list[counter] - tmp = tmp[:len(tmp)-len(self.con.base_dn)] + "${DOMAIN_DN}" + tmp = tmp[:len(tmp) -len(self.con.base_dn)] + "${DOMAIN_DN}" tmp = tmp.replace("CN=%s" % self.con.domain_netbios, "CN=${DOMAIN_NETBIOS}") if len(self.con.server_names) == 1: for x in self.con.server_names: @@ -731,7 +731,7 @@ class LDAPBundel(object): Log on the screen if there is no --quiet option set """ if not self.quiet: - self.outf.write(msg+"\n") + self.outf.write(msg + "\n") def update_size(self): self.size = len(self.dn_list) @@ -755,7 +755,7 @@ class LDAPBundel(object): self.log(title) title = None res = False - self.log(4*" " + x) + self.log(4 * " " + x) self.dn_list[self.dn_list.index(x)] = "" self.dn_list = [x for x in self.dn_list if x] # @@ -766,7 +766,7 @@ class LDAPBundel(object): self.log(title) title = None res = False - self.log(4*" " + x) + self.log(4 * " " + x) other.dn_list[other.dn_list.index(x)] = "" other.dn_list = [x for x in other.dn_list if x] # @@ -811,13 +811,13 @@ class LDAPBundel(object): self.log("\nComparing:") self.log("'%s' [%s]" % (object1.dn, object1.con.host)) self.log("'%s' [%s]" % (object2.dn, object2.con.host)) - self.log(4*" " + "OK") + self.log(4 * " " + "OK") else: self.log("\nComparing:") self.log("'%s' [%s]" % (object1.dn, object1.con.host)) self.log("'%s' [%s]" % (object2.dn, object2.con.host)) self.log(object1.screen_output) - self.log(4*" " + "FAILED") + self.log(4 * " " + "FAILED") res = False self.summary = object1.summary other.summary = object2.summary @@ -871,11 +871,11 @@ class LDAPBundel(object): # if self.summary["unique_attrs"]: self.log("\nAttributes found only in %s:" % self.con.host) - self.log("".join([str("\n" + 4*" " + x) for x in self.summary["unique_attrs"]])) + self.log("".join([str("\n" + 4 * " " + x) for x in self.summary["unique_attrs"]])) # if self.summary["df_value_attrs"]: self.log("\nAttributes with different values:") - self.log("".join([str("\n" + 4*" " + x) for x in self.summary["df_value_attrs"]])) + self.log("".join([str("\n" + 4 * " " + x) for x in self.summary["df_value_attrs"]])) self.summary["df_value_attrs"] = [] diff --git a/python/samba/netcmd/nettime.py b/python/samba/netcmd/nettime.py index b204d5e89ad..dcf9f6c5cdf 100644 --- a/python/samba/netcmd/nettime.py +++ b/python/samba/netcmd/nettime.py @@ -56,4 +56,4 @@ Example2 return the date and time of the local server. net = Net(creds, lp, server=credopts.ipaddress) if server_name is None: server_name = common.netcmd_dnsname(lp) - self.outf.write(net.time(server_name)+"\n") + self.outf.write(net.time(server_name) + "\n") diff --git a/python/samba/netcmd/ntacl.py b/python/samba/netcmd/ntacl.py index 30410b16bf1..3957a726689 100644 --- a/python/samba/netcmd/ntacl.py +++ b/python/samba/netcmd/ntacl.py @@ -166,7 +166,7 @@ class cmd_ntacl_get(Command): domain_sid = security.dom_sid(samdb.domain_sid) except: raise CommandError("Unable to read domain SID from configuration files") - self.outf.write(acl.as_sddl(domain_sid)+"\n") + self.outf.write(acl.as_sddl(domain_sid) + "\n") else: self.outf.write(ndr_print(acl)) @@ -215,7 +215,7 @@ class cmd_ntacl_sysvolreset(Command): s3conf.set("passdb backend", "samba_dsdb:%s" % samdb.url) LA_sid = security.dom_sid(str(domain_sid) - + "-"+str(security.DOMAIN_RID_ADMINISTRATOR)) + + "-" +str(security.DOMAIN_RID_ADMINISTRATOR)) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) s4_passdb = passdb.PDB(s3conf.get("passdb backend")) diff --git a/python/samba/netcmd/ou.py b/python/samba/netcmd/ou.py index 3a3a161a73b..9fd9d6bc3ff 100644 --- a/python/samba/netcmd/ou.py +++ b/python/samba/netcmd/ou.py @@ -144,7 +144,7 @@ class cmd_move(Command): (new_parent_dn, e.message)) full_new_ou_dn = ldb.Dn(samdb, str(full_old_ou_dn)) - full_new_ou_dn.remove_base_components(len(full_old_ou_dn)-1) + full_new_ou_dn.remove_base_components(len(full_old_ou_dn) - 1) full_new_ou_dn.add_base(full_new_parent_dn) try: diff --git a/python/samba/netcmd/spn.py b/python/samba/netcmd/spn.py index 86d73f451df..b9069b0e408 100644 --- a/python/samba/netcmd/spn.py +++ b/python/samba/netcmd/spn.py @@ -52,7 +52,7 @@ class cmd_spn_list(Command): # TODO once I understand how, use the domain info to naildown # to the correct domain (cleaneduser, realm, domain) = _get_user_realm_domain(user) - self.outf.write(cleaneduser+"\n") + self.outf.write(cleaneduser + "\n") res = sam.search( expression="samaccountname=%s" % ldb.binary_encode(cleaneduser), scope=ldb.SCOPE_SUBTREE, attrs=["servicePrincipalName"]) diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index c2af4923adb..d83a7db7ecd 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -662,7 +662,7 @@ Example4 shows how to set the account expiration so that it will never expire. credentials=creds, lp=lp) try: - samdb.setexpiry(filter, days*24*3600, no_expiry_req=noexpiry) + samdb.setexpiry(filter, days * 24 * 3600, no_expiry_req=noexpiry) except Exception as msg: # FIXME: Catch more specific exception raise CommandError("Failed to set expiry for user '%s': %s" % ( @@ -1158,7 +1158,7 @@ class GetPasswordCommand(Command): digests = ndr_unpack(drsblobs.package_PrimaryWDigestBlob, primary_wdigest) try: - digest = binascii.hexlify(bytearray(digests.hashes[i-1].hash)) + digest = binascii.hexlify(bytearray(digests.hashes[i - 1].hash)) return "%s:%s:%s" % (user, realm, digest) except IndexError: return None @@ -2576,7 +2576,7 @@ class cmd_user_move(Command): (new_parent_dn, e.message)) full_new_user_dn = ldb.Dn(samdb, str(user_dn)) - full_new_user_dn.remove_base_components(len(user_dn)-1) + full_new_user_dn.remove_base_components(len(user_dn) - 1) full_new_user_dn.add_base(full_new_parent_dn) try: diff --git a/python/samba/provision/backend.py b/python/samba/provision/backend.py index 53b03e37acf..d85072a8723 100644 --- a/python/samba/provision/backend.py +++ b/python/samba/provision/backend.py @@ -405,7 +405,7 @@ class OpenLDAPBackend(LDAPBackend): url_list = filter(None,self.ol_mmr_urls.split(',')) for url in url_list: - self.logger.info("Using LDAP-URL: "+url) + self.logger.info("Using LDAP-URL: " + url) if len(url_list) == 1: raise ProvisioningError("At least 2 LDAP-URLs needed for MMR!") diff --git a/python/samba/schema.py b/python/samba/schema.py index 61561f199f6..0958808cc88 100644 --- a/python/samba/schema.py +++ b/python/samba/schema.py @@ -208,7 +208,7 @@ def get_linked_attributes(schemadn, schemaldb): for i in range(0, len(res)): expression = ("(&(objectclass=attributeSchema)(linkID=%d)" "(attributeSyntax=2.5.5.1))" % - (int(res[i]["linkID"][0])+1)) + (int(res[i]["linkID"][0]) + 1)) target = schemaldb.searchone(basedn=schemadn, expression=expression, attribute="lDAPDisplayName", diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index 60c18c73234..bd17a870d66 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -101,7 +101,7 @@ class TestCase(unittest.TestCase): hr = ' '.join(["%02X" % x for x in lr]) ll = ll.translate(HEXDUMP_FILTER).decode('utf8') lr = lr.translate(HEXDUMP_FILTER).decode('utf8') - result += "[%04X] %-*s %-*s %s %s\n" % (N, 8*3, hl, 8*3, hr, ll, lr) + result += "[%04X] %-*s %-*s %s %s\n" % (N, 8 * 3, hl, 8 * 3, hr, ll, lr) N += 16 return result @@ -330,7 +330,7 @@ class ValidNetbiosNameTests(TestCase): self.assertTrue(samba.valid_netbios_name("FOO")) def test_too_long(self): - self.assertFalse(samba.valid_netbios_name("FOO"*10)) + self.assertFalse(samba.valid_netbios_name("FOO" * 10)) def test_invalid_characters(self): self.assertFalse(samba.valid_netbios_name("*BLA")) diff --git a/python/samba/tests/blackbox/check_output.py b/python/samba/tests/blackbox/check_output.py index 8b3643d492d..66483548d83 100644 --- a/python/samba/tests/blackbox/check_output.py +++ b/python/samba/tests/blackbox/check_output.py @@ -53,7 +53,7 @@ class TimeoutHelper(): raise TimeoutHelper.Timeout() -def _make_cmdline(data='$', repeat=5*1024*1024, retcode=0): +def _make_cmdline(data='$', repeat=5 *1024 *1024, retcode=0): """Build a command to call gen_output.py to generate large output""" return 'gen_output.py --data {} --repeat {} --retcode {}'.format(data, repeat, retcode) diff --git a/python/samba/tests/dcerpc/dnsserver.py b/python/samba/tests/dcerpc/dnsserver.py index fedda343ebf..f09fad3040d 100644 --- a/python/samba/tests/dcerpc/dnsserver.py +++ b/python/samba/tests/dcerpc/dnsserver.py @@ -35,7 +35,7 @@ class DnsserverTests(RpcInterfaceTestCase): def setUpClass(cls): good_dns = ["SAMDOM.EXAMPLE.COM", "1.EXAMPLE.COM", - "%sEXAMPLE.COM" % ("1."*100), + "%sEXAMPLE.COM" % ("1." * 100), "EXAMPLE", "\n.COM", "!@#$%^&*()_", @@ -103,7 +103,7 @@ class DnsserverTests(RpcInterfaceTestCase): # actually create these records. invalid_mx = ["SAMDOM.EXAMPLE.COM -1", "SAMDOM.EXAMPLE.COM 65536", - "%s 1" % "A"*256] + "%s 1" % "A" *256] invalid_srv = ["SAMDOM.EXAMPLE.COM 0 65536 0", "SAMDOM.EXAMPLE.COM 0 0 65536", "SAMDOM.EXAMPLE.COM 65536 0 0"] @@ -516,7 +516,7 @@ class DnsserverTests(RpcInterfaceTestCase): """ for record_type_str in self.good_records: for i in range(1, len(self.good_records[record_type_str])): - record1 = self.good_records[record_type_str][i-1] + record1 = self.good_records[record_type_str][i - 1] record2 = self.good_records[record_type_str][i] if record_type_str == 'CNAME': diff --git a/python/samba/tests/dcerpc/raw_protocol.py b/python/samba/tests/dcerpc/raw_protocol.py index 006195035c6..3f6e05b0ae0 100755 --- a/python/samba/tests/dcerpc/raw_protocol.py +++ b/python/samba/tests/dcerpc/raw_protocol.py @@ -1734,7 +1734,7 @@ class TestDCERPC_BIND(RawDCERPCTest): req = self.generate_alter(call_id=1, max_xmit_frag=alter_xmit, max_recv_frag=alter_recv, - assoc_group_id=0xffffffff-rep.u.assoc_group_id, + assoc_group_id=0xffffffff - rep.u.assoc_group_id, ctx_list=[ctx1]) self.send_pdu(req) rep = self.recv_pdu() @@ -1936,14 +1936,14 @@ class TestDCERPC_BIND(RawDCERPCTest): computer = 'UNKNOWNCOMPUTER' computer_utf16 = unicode(computer, 'utf-8').encode('utf-16-le') - real_stub = struct.pack('<IIII', 0x00200000, - len(server)+1, 0, len(server)+1) + real_stub = struct.pack('<IIII', 0x00200000, + len(server) + 1, 0, len(server) + 1) real_stub += server_utf16 + '\x00\x00' mod_len = len(real_stub) % 4 if mod_len != 0: real_stub += '\x00' * (4 - mod_len) real_stub += struct.pack('<III', - len(computer)+1, 0, len(computer)+1) + len(computer) + 1, 0, len(computer) + 1) real_stub += computer_utf16 + '\x00\x00' real_stub += '\x11\x22\x33\x44\x55\x66\x77\x88' @@ -2590,7 +2590,7 @@ class TestDCERPC_BIND(RawDCERPCTest): # And now try a new request req2 = self.generate_request(call_id = 2, - context_id=ctx.context_id-1, + context_id=ctx.context_id - 1, opnum=0, stub="") self.send_pdu(req2) @@ -2716,7 +2716,7 @@ class TestDCERPC_BIND(RawDCERPCTest): auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, auth_context_id=auth_context_id, - auth_blob="\x01"+"\x00"*15) + auth_blob="\x01" +"\x00" *15) req = self.generate_request(call_id = 3, context_id=ctx1.context_id, opnum=0, @@ -2736,7 +2736,7 @@ class TestDCERPC_BIND(RawDCERPCTest): auth_info = self.generate_auth(auth_type=auth_type, auth_level=dcerpc.DCERPC_AUTH_LEVEL_INTEGRITY, auth_context_id=auth_context_id, - auth_blob="\x01"+"\x00"*15) + auth_blob="\x01" +"\x00" * 15) req = self.generate_request(call_id = 4, context_id=ctx1.context_id, opnum=0, @@ -2852,7 +2852,7 @@ class TestDCERPC_BIND(RawDCERPCTest): auth_info = self.generate_auth(auth_type=auth_type, auth_level=dcerpc.DCERPC_AUTH_LEVEL_CONNECT, auth_context_id=auth_context_id, - auth_blob="\x01"+"\x00"*15) + auth_blob="\x01" +"\x00" * 15) req = self.generate_request(call_id = 3, context_id=ctx1.context_id, opnum=0, @@ -2936,7 +2936,7 @@ class TestDCERPC_BIND(RawDCERPCTest): auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, auth_context_id=auth_context_id, - auth_blob="\x01"+"\x00"*15) + auth_blob="\x01" +"\x00" * 15) req = self.generate_request(call_id = 1, context_id=ctx1.context_id, opnum=0, @@ -3154,7 +3154,7 @@ class TestDCERPC_BIND(RawDCERPCTest): auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, auth_context_id=auth_context_id, - auth_blob="\x01"+"\x00"*15) + auth_blob="\x01" +"\x00" * 15) req = self.generate_request(call_id = 3, context_id=ctx1.context_id, opnum=0, @@ -3315,7 +3315,7 @@ class TestDCERPC_BIND(RawDCERPCTest): auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, auth_context_id=auth_context_id, - auth_blob="\x01"+"\x00"*15) + auth_blob="\x01" +"\x00" * 15) req = self.generate_request(call_id = 3, context_id=ctx1.context_id, opnum=0, @@ -4013,7 +4013,7 @@ class TestDCERPC_BIND(RawDCERPCTest): auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, auth_context_id=auth_context_id, - auth_blob="\x01"+"\x00"*15) + auth_blob="\x01" +"\x00" * 15) req = self.generate_request(call_id = 3, context_id=ctx1.context_id, opnum=0, @@ -4308,7 +4308,7 @@ class TestDCERPC_BIND(RawDCERPCTest): auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, auth_context_id=auth_context_id, - auth_blob="\x01"+"\x00"*15) + auth_blob="\x01" +"\x00" * 15) req = self.generate_request(call_id = 3, context_id=ctx1.context_id, opnum=0, @@ -4487,7 +4487,7 @@ class TestDCERPC_BIND(RawDCERPCTest): sig_size = g.sig_size(len(stub_bin)) else: sig_size = 16 - zero_sig = "\x00"*sig_size + zero_sig = "\x00" * sig_size auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, @@ -4654,7 +4654,7 @@ class TestDCERPC_BIND(RawDCERPCTest): stub_bin += '\x00' * auth_pad_length sig_size = g.sig_size(len(stub_bin)) - zero_sig = "\x00"*sig_size + zero_sig = "\x00" * sig_size auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, @@ -4720,7 +4720,7 @@ class TestDCERPC_BIND(RawDCERPCTest): stub_bin += '\x00' * auth_pad_length sig_size = g.sig_size(len(stub_bin)) - zero_sig = "\x00"*sig_size + zero_sig = "\x00" * sig_size auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, @@ -4771,7 +4771,7 @@ class TestDCERPC_BIND(RawDCERPCTest): stub_bin += '\x00' * auth_pad_length sig_size = g.sig_size(len(stub_bin)) - zero_sig = "\x00"*sig_size + zero_sig = "\x00" * sig_size auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, @@ -4836,7 +4836,7 @@ class TestDCERPC_BIND(RawDCERPCTest): stub_bin += '\x00' * auth_pad_length sig_size = g.sig_size(len(stub_bin)) - zero_sig = "\x00"*sig_size + zero_sig = "\x00" * sig_size auth_info = self.generate_auth(auth_type=auth_type, auth_level=auth_level, diff --git a/python/samba/tests/dcerpc/raw_testcase.py b/python/samba/tests/dcerpc/raw_testcase.py index 7c99f8d807d..c7809ee2bc0 100644 --- a/python/samba/tests/dcerpc/raw_testcase.py +++ b/python/samba/tests/dcerpc/raw_testcase.py @@ -214,7 +214,7 @@ class RawDCERPCTest(TestCase): auth_blob=to_server) req = self.generate_alter(call_id=call_id, ctx_list=ctx_list, - assoc_group_id=0xffffffff-assoc_group_id, + assoc_group_id=0xffffffff -assoc_group_id, auth_info=auth_info) self.send_pdu(req) rep = self.recv_pdu() @@ -331,7 +331,7 @@ class RawDCERPCTest(TestCase): else: sig_size = 16 - zero_sig = "\x00"*sig_size + zero_sig = "\x00" * sig_size auth_info = self.generate_auth(auth_type=auth_context["auth_type"], auth_level=auth_context["auth_level"], auth_pad_length=auth_pad_length, diff --git a/python/samba/tests/password_hash.py b/python/samba/tests/password_hash.py index 745ac704c9f..bdb740d71ec 100644 --- a/python/samba/tests/password_hash.py +++ b/python/samba/tests/password_hash.py @@ -175,130 +175,130 @@ class PassWordHashTests(TestCase): self.check_digest(USER_NAME, self.netbios_domain, USER_PASS, - digests.hashes[1-1].hash) + digests.hashes[1 - 1].hash) self.check_digest(USER_NAME.lower(), self.netbios_domain.lower(), USER_PASS, - digests.hashes[2-1].hash) + digests.hashes[2 - 1].hash) self.check_digest(USER_NAME.upper(), self.netbios_domain.upper(), USER_PASS, - digests.hashes[3-1].hash) + digests.hashes[3 - 1].hash) self.check_digest(USER_NAME, self.netbios_domain.upper(), USER_PASS, - digests.hashes[4-1].hash) + digests.hashes[4 - 1].hash) self.check_digest(USER_NAME, self.netbios_domain.lower(), USER_PASS, - digests.hashes[5-1].hash) + digests.hashes[5 - 1].hash) self.check_digest(USER_NAME.upper(), self.netbios_domain.lower(), USER_PASS, - digests.hashes[6-1].hash) + digests.hashes[6 - 1].hash) self.check_digest(USER_NAME.lower(), self.netbios_domain.upper(), USER_PASS, - digests.hashes[7-1].hash) + digests.hashes[7 - 1].hash) self.check_digest(USER_NAME, self.dns_domain, USER_PASS, - digests.hashes[8-1].hash) + digests.hashes[8 - 1].hash) self.check_digest(USER_NAME.lower(), self.dns_domain.lower(), USER_PASS, - digests.hashes[9-1].hash) + digests.hashes[9 - 1].hash) self.check_digest(USER_NAME.upper(), self.dns_domain.upper(), USER_PASS, - digests.hashes[10-1].hash) + digests.hashes[10 - 1].hash) self.check_digest(USER_NAME, self.dns_domain.upper(), USER_PASS, - digests.hashes[11-1].hash) + digests.hashes[11 - 1].hash) self.check_digest(USER_NAME, self.dns_domain.lower(), USER_PASS, - digests.hashes[12-1].hash) + digests.hashes[12 - 1].hash) self.check_digest(USER_NAME.upper(), self.dns_domain.lower(), USER_PASS, - digests.hashes[13-1].hash) + digests.hashes[13 - 1].hash) self.check_digest(USER_NAME.lower(), self.dns_domain.upper(), USER_PASS, - digests.hashes[14-1].hash) + digests.hashes[14 - 1].hash) self.check_digest(UPN, "", USER_PASS, - digests.hashes[15-1].hash) + digests.hashes[15 - 1].hash) self.check_digest(UPN.lower(), "", USER_PASS, - digests.hashes[16-1].hash) + digests.hashes[16 - 1].hash) self.check_digest(UPN.upper(), "", USER_PASS, - digests.hashes[17-1].hash) + digests.hashes[17 - 1].hash) name = "%s\\%s" % (self.netbios_domain, USER_NAME) self.check_digest(name, "", USER_PASS, - digests.hashes[18-1].hash) + digests.hashes[18 - 1].hash) name = "%s\\%s" % (self.netbios_domain.lower(), USER_NAME.lower()) self.check_digest(name, "", USER_PASS, - digests.hashes[19-1].hash) + digests.hashes[19 - 1].hash) name = "%s\\%s" % (self.netbios_domain.upper(), USER_NAME.upper()) self.check_digest(name, "", USER_PASS, - digests.hashes[20-1].hash) + digests.hashes[20 - 1].hash) self.check_digest(USER_NAME, "Digest", USER_PASS, - digests.hashes[21-1].hash) + digests.hashes[21 - 1].hash) self.check_digest(USER_NAME.lower(), "Digest", USER_PASS, - digests.hashes[22-1].hash) + digests.hashes[22 - 1].hash) self.check_digest(USER_NAME.upper(), "Digest", USER_PASS, - digests.hashes[23-1].hash) + digests.hashes[23 - 1].hash) self.check_digest(UPN, "Digest", USER_PASS, - digests.hashes[24-1].hash) + digests.hashes[24 - 1].hash) self.check_digest(UPN.lower(), "Digest", USER_PASS, - digests.hashes[25-1].hash) + digests.hashes[25 - 1].hash) self.check_digest(UPN.upper(), "Digest", USER_PASS, - digests.hashes[26-1].hash) + digests.hashes[26 - 1].hash) name = "%s\\%s" % (self.netbios_domain, USER_NAME) self.check_digest(name, "Digest", USER_PASS, - digests.hashes[27-1].hash) + digests.hashes[27 - 1].hash) name = "%s\\%s" % (self.netbios_domain.lower(), USER_NAME.lower()) self.check_digest(name, "Digest", USER_PASS, - digests.hashes[28-1].hash) + digests.hashes[28 - 1].hash) name = "%s\\%s" % (self.netbios_domain.upper(), USER_NAME.upper()) self.check_digest(name, "Digest", USER_PASS, - digests.hashes[29-1].hash) + digests.hashes[29 - 1].hash) def checkUserPassword(self, up, expected): diff --git a/python/samba/tests/posixacl.py b/python/samba/tests/posixacl.py index 78eae888360..97ce6bb4a6f 100644 --- a/python/samba/tests/posixacl.py +++ b/python/samba/tests/posixacl.py @@ -324,7 +324,7 @@ class PosixAclMappingTests(TestCaseInTempDir): nwrap_winbind_active = (nwrap_module_so_path != "" and nwrap_module_fn_prefix == "winbind") - LA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_ADMINISTRATOR)) + LA_sid = security.dom_sid(str(domsid) + "-" + str(security.DOMAIN_RID_ADMINISTRATOR)) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS) SY_sid = security.dom_sid(security.SID_NT_SYSTEM) @@ -466,7 +466,7 @@ class PosixAclMappingTests(TestCaseInTempDir): self.assertEquals(facl.as_sddl(domsid),acl) posix_acl = smbd.get_sys_acl(self.tempdir, smb_acl.SMB_ACL_TYPE_ACCESS) - LA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_ADMINISTRATOR)) + LA_sid = security.dom_sid(str(domsid) + "-" + str(security.DOMAIN_RID_ADMINISTRATOR)) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS) SY_sid = security.dom_sid(security.SID_NT_SYSTEM) @@ -561,12 +561,12 @@ class PosixAclMappingTests(TestCaseInTempDir): self.assertEquals(facl.as_sddl(domsid),acl) posix_acl = smbd.get_sys_acl(self.tempdir, smb_acl.SMB_ACL_TYPE_ACCESS) - LA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_ADMINISTRATOR)) + LA_sid = security.dom_sid(str(domsid) + "-" + str(security.DOMAIN_RID_ADMINISTRATOR)) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS) SY_sid = security.dom_sid(security.SID_NT_SYSTEM) AU_sid = security.dom_sid(security.SID_NT_AUTHENTICATED_USERS) - PA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_POLICY_ADMINS)) + PA_sid = security.dom_sid(str(domsid) + "-" + str(security.DOMAIN_RID_POLICY_ADMINS)) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) @@ -676,12 +676,12 @@ class PosixAclMappingTests(TestCaseInTempDir): nwrap_winbind_active = (nwrap_module_so_path != "" and nwrap_module_fn_prefix == "winbind") - LA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_ADMINISTRATOR)) + LA_sid = security.dom_sid(str(domsid) + "-" + str(security.DOMAIN_RID_ADMINISTRATOR)) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS) SY_sid = security.dom_sid(security.SID_NT_SYSTEM) AU_sid = security.dom_sid(security.SID_NT_AUTHENTICATED_USERS) - PA_sid = security.dom_sid(str(domsid)+"-"+str(security.DOMAIN_RID_POLICY_ADMINS)) + PA_sid = security.dom_sid(str(domsid) + "-" + str(security.DOMAIN_RID_POLICY_ADMINS)) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) diff --git a/python/samba/tests/py_credentials.py b/python/samba/tests/py_credentials.py index 5737d89c948..1678cecdba3 100644 --- a/python/samba/tests/py_credentials.py +++ b/python/samba/tests/py_credentials.py @@ -234,7 +234,7 @@ class PyCredentialsTests(TestCase): newpass = samba.generate_random_password(PWD_LEN, PWD_LEN) encoded = newpass.encode('utf-16-le') pwd_len = len(encoded) - filler = [ord(x) for x in os.urandom(DATA_LEN-pwd_len)] + filler = [ord(x) for x in os.urandom(DATA_LEN - pwd_len)] pwd = netlogon.netr_CryptPassword() pwd.length = pwd_len pwd.data = filler + [ord(x) for x in encoded] diff --git a/python/samba/tests/samba_tool/dnscmd.py b/python/samba/tests/samba_tool/dnscmd.py index 913cd7cf5ba..5c27c80f783 100644 --- a/python/samba/tests/samba_tool/dnscmd.py +++ b/python/samba/tests/samba_tool/dnscmd.py @@ -44,7 +44,7 @@ class DnsCmdTestCase(SambaToolCmdTest): good_dns = ["SAMDOM.EXAMPLE.COM", "1.EXAMPLE.COM", - "%sEXAMPLE.COM" % ("1."*100), + "%sEXAMPLE.COM" % ("1." * 100), "EXAMPLE", "\n.COM", "!@#$%^&*()_", diff --git a/python/samba/tests/samba_tool/ntacl.py b/python/samba/tests/samba_tool/ntacl.py index c84c60ee4fb..3da75065548 100644 --- a/python/samba/tests/samba_tool/ntacl.py +++ b/python/samba/tests/samba_tool/ntacl.py @@ -77,7 +77,7 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest): def test_ntvfs(self): path = os.environ['SELFTEST_PREFIX'] - tempf = os.path.join(path,"pytests"+str(int(100000*random.random()))) + tempf = os.path.join(path,"pytests" +str(int(100000 * random.random()))) open(tempf, 'w').write("empty") (result, out, err) = self.runsubcmd("ntacl", "set", self.acl, tempf, @@ -88,7 +88,7 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest): def test_s3fs(self): path = os.environ['SELFTEST_PREFIX'] - tempf = os.path.join(path,"pytests"+str(int(100000*random.random()))) + tempf = os.path.join(path,"pytests" +str(int(100000 * random.random()))) open(tempf, 'w').write("empty") (result, out, err) = self.runsubcmd("ntacl", "set", self.acl, tempf, @@ -100,7 +100,7 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest): def test_ntvfs_check(self): path = os.environ['SELFTEST_PREFIX'] - tempf = os.path.join(path,"pytests"+str(int(100000*random.random()))) + tempf = os.path.join(path,"pytests" +str(int(100000 * random.random()))) open(tempf, 'w').write("empty") (result, out, err) = self.runsubcmd("ntacl", "set", self.acl, tempf, @@ -114,11 +114,11 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest): "--use-ntvfs", "--as-sddl") self.assertCmdSuccess(result, out, err) self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(self.acl+"\n", out, "Output should be the ACL") + self.assertEquals(self.acl + "\n", out, "Output should be the ACL") def test_s3fs_check(self): path = os.environ['SELFTEST_PREFIX'] - tempf = os.path.join(path,"pytests"+str(int(100000*random.random()))) + tempf = os.path.join(path,"pytests" + str(int(100000 *random.random()))) open(tempf, 'w').write("empty") (result, out, err) = self.runsubcmd("ntacl", "set", self.acl, tempf, @@ -132,4 +132,4 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest): "--use-s3fs", "--as-sddl") self.assertCmdSuccess(result, out, err) self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(self.acl+"\n", out,"Output should be the ACL") + self.assertEquals(self.acl + "\n", out,"Output should be the ACL") diff --git a/python/samba/tests/samba_tool/user_virtualCryptSHA.py b/python/samba/tests/samba_tool/user_virtualCryptSHA.py index be3316bd3bf..5417ba20297 100644 --- a/python/samba/tests/samba_tool/user_virtualCryptSHA.py +++ b/python/samba/tests/samba_tool/user_virtualCryptSHA.py @@ -52,7 +52,7 @@ HASH_OPTION = "password hash userPassword schemes" # Note: Does not correctly handle values spanning multiple lines, # which is acceptable for it's usage in these tests. def _get_attribute(out, name): - p = re.compile("^"+name+":\s+(\S+)") + p = re.compile("^" + name + ":\s+(\S+)") for line in out.split("\n"): m = p.match(line) if m: diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py index a34ca835b71..296815f3a97 100644 --- a/python/samba/tests/smb.py +++ b/python/samba/tests/smb.py @@ -20,11 +20,11 @@ from samba import smb PY3 = sys.version_info[0] == 3 addom = 'addom.samba.example.com/' -test_contents = 'abcd'*256 -utf_contents = u'Süßigkeiten Äpfel '*128 -test_literal_bytes_embed_nulls = b'\xff\xfe\x14\x61\x00\x00\x62\x63\x64'*256 +test_contents = 'abcd' * 256 +utf_contents = u'Süßigkeiten Äpfel ' * 128 +test_literal_bytes_embed_nulls = b'\xff\xfe\x14\x61\x00\x00\x62\x63\x64' * 256 binary_contents = b'\xff\xfe' -binary_contents = binary_contents + "Hello cruel world of python3".encode('utf8')*128 +binary_contents = binary_contents + "Hello cruel world of python3".encode('utf8') * 128 test_dir = os.path.join(addom, 'testing_%d' % random.randint(0,0xFFFF)) test_file = os.path.join(test_dir, 'testing').replace('/', '\\') diff --git a/python/samba/tests/strings.py b/python/samba/tests/strings.py index 23382d756ec..5f7d18c3a66 100644 --- a/python/samba/tests/strings.py +++ b/python/samba/tests/strings.py @@ -88,12 +88,12 @@ class strstr_m_Tests(samba.tests.TestCase): ('longstring ' * 100 + 'a', 'longstring ' * 100, 'longstring ' * 100 + 'a'), (KATAKANA_LETTER_A, KATAKANA_LETTER_A + 'bcd', None), (KATAKANA_LETTER_A + 'bcde', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcde'), - ('d'+KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd'), - ('d'+KATAKANA_LETTER_A + 'bd', KATAKANA_LETTER_A + 'bcd', None), + ('d' +KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcd'), + ('d' +KATAKANA_LETTER_A + 'bd', KATAKANA_LETTER_A + 'bcd', None), - ('e'+KATAKANA_LETTER_A + 'bcdf', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcdf'), + ('e' + KATAKANA_LETTER_A + 'bcdf', KATAKANA_LETTER_A + 'bcd', KATAKANA_LETTER_A + 'bcdf'), (KATAKANA_LETTER_A, KATAKANA_LETTER_A + 'bcd', None), - (KATAKANA_LETTER_A*3, 'a', None), + (KATAKANA_LETTER_A * 3, 'a', None), ] for a, b, expect in cases: if expect is not None: diff --git a/python/samba/tests/xattr.py b/python/samba/tests/xattr.py index ca25afbdcd7..ff34194328e 100644 --- a/python/samba/tests/xattr.py +++ b/python/samba/tests/xattr.py @@ -35,7 +35,7 @@ class XattrTests(TestCase): def _tmpfilename(self): random.seed() path = os.environ['SELFTEST_PREFIX'] - return os.path.join(path, "pytests"+str(int(100000*random.random()))) + return os.path.join(path, "pytests" +str(int(100000 * random.random()))) def _eadbpath(self): return os.path.join(os.environ['SELFTEST_PREFIX'], "eadb.tdb") diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py index 1dda2915be1..2dcedfb2be0 100644 --- a/python/samba/upgradehelpers.py +++ b/python/samba/upgradehelpers.py @@ -281,16 +281,16 @@ def dn_sort(x, y): tab1 = p.split(str(x)) tab2 = p.split(str(y)) minimum = min(len(tab1), len(tab2)) - len1 = len(tab1)-1 - len2 = len(tab2)-1 + len1 = len(tab1) -1 + len2 = len(tab2) -1 # Note: python range go up to upper limit but do not include it for i in range(0, minimum): - ret = cmp_fn(tab1[len1-i], tab2[len2-i]) + ret = cmp_fn(tab1[len1 - i], tab2[len2 - i]) if ret != 0: return ret else: - if i == minimum-1: - assert len1 != len2,"PB PB PB" + " ".join(tab1)+" / " + " ".join(tab2) + if i == minimum - 1: + assert len1 != len2,"PB PB PB" + " ".join(tab1) + " / " + " ".join(tab2) if len1 > len2: return 1 else: @@ -777,7 +777,7 @@ def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid): for k in sorted_keys: obj = hash_ts[k] if obj["num"] > limit_print: - dt = _glue.nttime2string(_glue.unix2nttime(k*60)) + dt = _glue.nttime2string(_glue.unix2nttime(k * 60)) print("%s # of modification: %d \tmin: %d max: %d" % (dt, obj["num"], obj["min"], obj["max"])) @@ -788,7 +788,7 @@ def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid): for i in range(0, len(kept_record)): if i != 0: key1 = kept_record[i] - key2 = kept_record[i-1] + key2 = kept_record[i - 1] if key1 - key2 == 1: # previous record is just 1 minute away from current if int(hash_ts[key1]["min"]) == int(hash_ts[key2]["max"]) + 1: |