diff options
author | Joe Guo <joeg@catalyst.net.nz> | 2018-07-30 18:19:05 +1200 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2018-08-24 07:49:28 +0200 |
commit | 12d3fbe15cb58b57c60499103101e3a845378859 (patch) | |
tree | 3a557d14c0c9cbafd6edee5649d1c8165f973a92 /python/samba | |
parent | 35de42275bc8475466ef29d1e2c2c7391c9f769b (diff) | |
download | samba-12d3fbe15cb58b57c60499103101e3a845378859.tar.gz |
PEP8: fix E231: missing whitespace after ','
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/samba')
44 files changed, 214 insertions, 214 deletions
diff --git a/python/samba/ms_forest_updates_markdown.py b/python/samba/ms_forest_updates_markdown.py index 1b288e3e74c..bd992474967 100644 --- a/python/samba/ms_forest_updates_markdown.py +++ b/python/samba/ms_forest_updates_markdown.py @@ -217,7 +217,7 @@ def read_ms_markdown(in_file, out_folder=None, out_dict={}): if node.text and node.text.startswith('|Operation'): # Strip first and last | updates = [x[1:len(x) - 1].split('|') for x in - ET.tostring(node,method='text').splitlines()] + ET.tostring(node, method='text').splitlines()] for update in updates[2:]: output = re.match('Operation (\d+): {(.*)}', update[0]) if output: diff --git a/python/samba/ms_schema.py b/python/samba/ms_schema.py index cd7e5fb12f3..109c298cebc 100644 --- a/python/samba/ms_schema.py +++ b/python/samba/ms_schema.py @@ -83,8 +83,8 @@ oMObjectClassBER = { } # separated by commas in docs, and must be broken up -multivalued_attrs = set(["auxiliaryclass","maycontain","mustcontain","posssuperiors", - "systemauxiliaryclass","systemmaycontain","systemmustcontain", +multivalued_attrs = set(["auxiliaryclass", "maycontain", "mustcontain", "posssuperiors", + "systemauxiliaryclass", "systemmaycontain", "systemmustcontain", "systemposssuperiors"]) def __read_folded_line(f, buffer): diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index 556afd71e40..cd1a2373550 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -28,7 +28,7 @@ class Option(optparse.Option): # This help formatter does text wrapping and preserves newlines class PlainHelpFormatter(optparse.IndentedHelpFormatter): - def format_description(self,description=""): + def format_description(self, description=""): desc_width = self.width - self.current_indent indent = " " * self.current_indent paragraphs = description.split('\n') @@ -128,7 +128,7 @@ class Command(object): usage=self.synopsis, description=self.full_description, formatter=PlainHelpFormatter(), - prog=prog,epilog=epilog) + prog=prog, epilog=epilog) parser.add_options(self.takes_options) optiongroups = {} for name, optiongroup in self.takes_optiongroups.items(): diff --git a/python/samba/netcmd/dbcheck.py b/python/samba/netcmd/dbcheck.py index 4e5e78d5668..874b2f990d6 100644 --- a/python/samba/netcmd/dbcheck.py +++ b/python/samba/netcmd/dbcheck.py @@ -108,7 +108,7 @@ class cmd_dbcheck(Command): samdb_schema = SamDB(session_info=system_session(), url=None, credentials=creds, lp=lp) - scope_map = {"SUB": ldb.SCOPE_SUBTREE, "BASE": ldb.SCOPE_BASE, "ONE":ldb.SCOPE_ONELEVEL} + scope_map = {"SUB": ldb.SCOPE_SUBTREE, "BASE": ldb.SCOPE_BASE, "ONE": ldb.SCOPE_ONELEVEL} scope = scope.upper() if not scope in scope_map: raise CommandError("Unknown scope %s" % scope) diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py index cc65c9236df..26c7551bc22 100644 --- a/python/samba/netcmd/dns.py +++ b/python/samba/netcmd/dns.py @@ -549,7 +549,7 @@ class cmd_serverinfo(Command): takes_options = [ Option('--client-version', help='Client Version', default='longhorn', metavar='w2k|dotnet|longhorn', - choices=['w2k','dotnet','longhorn'], dest='cli_ver'), + choices=['w2k', 'dotnet', 'longhorn'], dest='cli_ver'), ] def run(self, server, cli_ver, sambaopts=None, credopts=None, @@ -581,7 +581,7 @@ class cmd_zoneinfo(Command): takes_options = [ Option('--client-version', help='Client Version', default='longhorn', metavar='w2k|dotnet|longhorn', - choices=['w2k','dotnet','longhorn'], dest='cli_ver'), + choices=['w2k', 'dotnet', 'longhorn'], dest='cli_ver'), ] def run(self, server, zone, cli_ver, sambaopts=None, credopts=None, @@ -613,7 +613,7 @@ class cmd_zonelist(Command): takes_options = [ Option('--client-version', help='Client Version', default='longhorn', metavar='w2k|dotnet|longhorn', - choices=['w2k','dotnet','longhorn'], dest='cli_ver'), + choices=['w2k', 'dotnet', 'longhorn'], dest='cli_ver'), Option('--primary', help='List primary zones (default)', action='store_true', dest='primary'), Option('--secondary', help='List secondary zones', @@ -692,7 +692,7 @@ class cmd_zonecreate(Command): takes_options = [ Option('--client-version', help='Client Version', default='longhorn', metavar='w2k|dotnet|longhorn', - choices=['w2k','dotnet','longhorn'], dest='cli_ver') + choices=['w2k', 'dotnet', 'longhorn'], dest='cli_ver') ] def run(self, server, zone, cli_ver, sambaopts=None, credopts=None, @@ -923,7 +923,7 @@ class cmd_add_record(Command): def run(self, server, zone, name, rtype, data, sambaopts=None, credopts=None, versionopts=None): - if rtype.upper() not in ('A','AAAA','PTR','CNAME','NS','MX','SRV','TXT'): + if rtype.upper() not in ('A', 'AAAA', 'PTR', 'CNAME', 'NS', 'MX', 'SRV', 'TXT'): raise CommandError('Adding record of type %s is not supported' % rtype) record_type = dns_type_flag(rtype) @@ -975,7 +975,7 @@ class cmd_update_record(Command): def run(self, server, zone, name, rtype, olddata, newdata, sambaopts=None, credopts=None, versionopts=None): - if rtype.upper() not in ('A','AAAA','PTR','CNAME','NS','MX','SOA','SRV','TXT'): + if rtype.upper() not in ('A', 'AAAA', 'PTR', 'CNAME', 'NS', 'MX', 'SOA', 'SRV', 'TXT'): raise CommandError('Updating record of type %s is not supported' % rtype) record_type = dns_type_flag(rtype) @@ -1044,7 +1044,7 @@ class cmd_delete_record(Command): def run(self, server, zone, name, rtype, data, sambaopts=None, credopts=None, versionopts=None): - if rtype.upper() not in ('A','AAAA','PTR','CNAME','NS','MX','SRV','TXT'): + if rtype.upper() not in ('A', 'AAAA', 'PTR', 'CNAME', 'NS', 'MX', 'SRV', 'TXT'): raise CommandError('Deleting record of type %s is not supported' % rtype) record_type = dns_type_flag(rtype) diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py index 19d522064e8..40117251450 100644 --- a/python/samba/netcmd/domain.py +++ b/python/samba/netcmd/domain.py @@ -148,7 +148,7 @@ def get_testparm_var(testparm, smbconf, varname): p = subprocess.Popen([testparm, '-s', '-l', '--parameter-name=%s' % varname, smbconf], stdout=subprocess.PIPE, stderr=errfile) - (out,err) = p.communicate() + (out, err) = p.communicate() errfile.close() lines = out.split('\n') if lines: @@ -303,7 +303,7 @@ class cmd_domain_provision(Command): ] ntvfs_options = [ - Option("--use-xattrs", type="choice", choices=["yes","no","auto"], + Option("--use-xattrs", type="choice", choices=["yes", "no", "auto"], metavar="[yes|no|auto]", help="Define if we should use the native fs capabilities or a tdb file for " "storing attributes likes ntacl when --use-ntvfs is set. " @@ -1365,9 +1365,9 @@ class cmd_domain_passwordsettings_set(Command): Option("-H", "--URL", help="LDB URL for database or target server", type=str, metavar="URL", dest="H"), Option("-q", "--quiet", help="Be quiet", action="store_true"), # unused - Option("--complexity", type="choice", choices=["on","off","default"], + Option("--complexity", type="choice", choices=["on", "off", "default"], help="The password complexity (on | off | default). Default is 'on'"), - Option("--store-plaintext", type="choice", choices=["on","off","default"], + Option("--store-plaintext", type="choice", choices=["on", "off", "default"], help="Store plaintext passwords where account have 'store passwords with reversible encryption' set (on | off | default). Default is 'off'"), Option("--history-length", help="The password history length (<integer> | default). Default is 24.", type=str), @@ -1581,7 +1581,7 @@ class cmd_domain_classicupgrade(Command): ] ntvfs_options = [ - Option("--use-xattrs", type="choice", choices=["yes","no","auto"], + Option("--use-xattrs", type="choice", choices=["yes", "no", "auto"], metavar="[yes|no|auto]", help="Define if we should use the native fs capabilities or a tdb file for " "storing attributes likes ntacl when --use-ntvfs is set. " diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py index 2d4ad9cd501..e8dbdd432f6 100644 --- a/python/samba/netcmd/drs.py +++ b/python/samba/netcmd/drs.py @@ -617,7 +617,7 @@ class cmd_drs_bind(Command): ("DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2", "DRS_EXT_ADDENTRY_V2"), ("DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION", "DRS_EXT_LINKED_VALUE_REPLICATION"), ("DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2", "DRS_EXT_DCINFO_V2"), - ("DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD","DRS_EXT_INSTANCE_TYPE_NOT_REQ_ON_MOD"), + ("DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD", "DRS_EXT_INSTANCE_TYPE_NOT_REQ_ON_MOD"), ("DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND", "DRS_EXT_CRYPTO_BIND"), ("DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO", "DRS_EXT_GET_REPL_INFO"), ("DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION", "DRS_EXT_STRONG_ENCRYPTION"), diff --git a/python/samba/netcmd/dsacl.py b/python/samba/netcmd/dsacl.py index 7522736b125..4ca15cdc99d 100644 --- a/python/samba/netcmd/dsacl.py +++ b/python/samba/netcmd/dsacl.py @@ -87,7 +87,7 @@ class cmd_dsacl_set(Command): res = samdb.search(base=trusteedn, expression="(objectClass=*)", scope=SCOPE_BASE) assert(len(res) == 1) - return ndr_unpack(security.dom_sid,res[0]["objectSid"][0]) + return ndr_unpack(security.dom_sid, res[0]["objectSid"][0]) def modify_descriptor(self, samdb, object_dn, desc, controls=None): assert(isinstance(desc, security.descriptor)) @@ -109,7 +109,7 @@ class cmd_dsacl_set(Command): def get_domain_sid(self, samdb): res = samdb.search(base=samdb.domain_dn(), expression="(objectClass=*)", scope=SCOPE_BASE) - return ndr_unpack(security.dom_sid,res[0]["objectSid"][0]) + return ndr_unpack(security.dom_sid, res[0]["objectSid"][0]) def add_ace(self, samdb, object_dn, new_ace): """Add new ace explicitly.""" diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index c5e322342ad..06b4fe508b9 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -432,7 +432,7 @@ class cmd_list(Command): try: msg = self.samdb.search(expression='(&(|(samAccountName=%s)(samAccountName=%s$))(objectClass=User))' % - (ldb.binary_encode(username),ldb.binary_encode(username))) + (ldb.binary_encode(username), ldb.binary_encode(username))) user_dn = msg[0].dn except Exception: raise CommandError("Failed to find account %s" % username) diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index ea2c2ae4cca..3f4d63d989f 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -97,7 +97,7 @@ class LDAPBase(object): def find_domain_sid(self): res = self.ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE) - return ndr_unpack(security.dom_sid,res[0]["objectSid"][0]) + return ndr_unpack(security.dom_sid, res[0]["objectSid"][0]) def find_servers(self): """ @@ -492,19 +492,19 @@ class LDAPObject(object): # Attributes that contain the Domain name e.g. 'samba.org' self.domain_attributes = [ "proxyAddresses", "mail", "userPrincipalName", "msExchSmtpFullyQualifiedDomainName", - "dnsHostName", "networkAddress", "dnsRoot", "servicePrincipalName",] + "dnsHostName", "networkAddress", "dnsRoot", "servicePrincipalName", ] self.domain_attributes = [x.upper() for x in self.domain_attributes] # # May contain DOMAIN_NETBIOS and SERVER_NAME self.servername_attributes = ["distinguishedName", "name", "CN", "sAMAccountName", "dNSHostName", "servicePrincipalName", "rIDSetReferences", "serverReference", "serverReferenceBL", - "msDS-IsDomainFor", "interSiteTopologyGenerator",] + "msDS-IsDomainFor", "interSiteTopologyGenerator", ] self.servername_attributes = [x.upper() for x in self.servername_attributes] # - self.netbios_attributes = ["servicePrincipalName", "CN", "distinguishedName", "nETBIOSName", "name",] + self.netbios_attributes = ["servicePrincipalName", "CN", "distinguishedName", "nETBIOSName", "name", ] self.netbios_attributes = [x.upper() for x in self.netbios_attributes] # - self.other_attributes = ["name", "DC",] + self.other_attributes = ["name", "DC", ] self.other_attributes = [x.upper() for x in self.other_attributes] # self.ignore_attributes = [x.upper() for x in self.ignore_attributes] @@ -968,7 +968,7 @@ class cmd_ldapcmp(Command): con1 = LDAPBase(URL1, creds, lp, two=two, quiet=quiet, descriptor=descriptor, sort_aces=sort_aces, - verbose=verbose,view=view, base=base, scope=scope, + verbose=verbose, view=view, base=base, scope=scope, outf=self.outf, errf=self.errf) assert len(con1.base_dn) > 0 diff --git a/python/samba/netcmd/ntacl.py b/python/samba/netcmd/ntacl.py index 3957a726689..e7f410382c4 100644 --- a/python/samba/netcmd/ntacl.py +++ b/python/samba/netcmd/ntacl.py @@ -19,7 +19,7 @@ from samba.credentials import DONT_USE_KERBEROS import samba.getopt as options from samba.dcerpc import security, idmap -from samba.ntacls import setntacl, getntacl,getdosinfo +from samba.ntacls import setntacl, getntacl, getdosinfo from samba import Ldb from samba.ndr import ndr_unpack, ndr_print from samba.samdb import SamDB @@ -53,17 +53,17 @@ class cmd_ntacl_set(Command): takes_options = [ Option("-q", "--quiet", help="Be quiet", action="store_true"), Option("--xattr-backend", type="choice", help="xattr backend type (native fs or tdb)", - choices=["native","tdb"]), + choices=["native", "tdb"]), Option("--eadb-file", help="Name of the tdb file where attributes are stored", type="string"), Option("--use-ntvfs", help="Set the ACLs directly to the TDB or xattr for use with the ntvfs file server", action="store_true"), Option("--use-s3fs", help="Set the ACLs for use with the default s3fs file server via the VFS layer", action="store_true"), Option("--service", help="Name of the smb.conf service to use when applying the ACLs", type="string") ] - takes_args = ["acl","file"] + takes_args = ["acl", "file"] def run(self, acl, file, use_ntvfs=False, use_s3fs=False, - quiet=False,xattr_backend=None,eadb_file=None, + quiet=False, xattr_backend=None, eadb_file=None, credopts=None, sambaopts=None, versionopts=None, service=None): logger = self.get_logger() @@ -129,7 +129,7 @@ class cmd_ntacl_get(Command): takes_options = [ Option("--as-sddl", help="Output ACL in the SDDL format", action="store_true"), Option("--xattr-backend", type="choice", help="xattr backend type (native fs or tdb)", - choices=["native","tdb"]), + choices=["native", "tdb"]), Option("--eadb-file", help="Name of the tdb file where attributes are stored", type="string"), Option("--use-ntvfs", help="Get the ACLs directly from the TDB or xattr used with the ntvfs file server", action="store_true"), Option("--use-s3fs", help="Get the ACLs for use via the VFS layer used by the default s3fs file server", action="store_true"), @@ -223,10 +223,10 @@ class cmd_ntacl_sysvolreset(Command): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) if (LA_type != idmap.ID_TYPE_UID and LA_type != idmap.ID_TYPE_BOTH): raise CommandError("SID %s is not mapped to a UID" % LA_sid) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) if (BA_type != idmap.ID_TYPE_GID and BA_type != idmap.ID_TYPE_BOTH): raise CommandError("SID %s is not mapped to a GID" % BA_sid) diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index d83a7db7ecd..677e0a91559 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -1857,7 +1857,7 @@ samba-tool user syncpasswords --terminate \\ self.samdb_url = H self.dirsync_filter = dirsync_filter self.dirsync_attrs = dirsync_attrs - self.dirsync_controls = ["dirsync:1:0:0","extended_dn:1:0"]; + self.dirsync_controls = ["dirsync:1:0:0", "extended_dn:1:0"]; self.password_attrs = password_attrs self.decrypt_samba_gpg = decrypt_samba_gpg self.sync_command = sync_command @@ -1881,7 +1881,7 @@ samba-tool user syncpasswords --terminate \\ self.current_pid = None self.outf.write("Initialized cache_ldb[%s]\n" % (cache_ldb)) msgs = self.cache.parse_ldif(add_ldif) - changetype,msg = next(msgs) + changetype, msg = next(msgs) ldif = self.cache.write_ldif(msg, ldb.CHANGETYPE_NONE) self.outf.write("%s" % ldif) else: @@ -2079,7 +2079,7 @@ samba-tool user syncpasswords --terminate \\ assert len(res_controls) > 0 assert res_controls[0].oid == "1.2.840.113556.1.4.841" res_controls[0].critical = True - self.dirsync_controls = [str(res_controls[0]),"extended_dn:1:0"] + self.dirsync_controls = [str(res_controls[0]), "extended_dn:1:0"] log_msg("dirsyncControls: %r\n" % self.dirsync_controls) modify_ldif = "dn: %s\n" % (self.cache_dn) diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py index a4f808ccd4a..5af894d4791 100644 --- a/python/samba/provision/__init__.py +++ b/python/samba/provision/__init__.py @@ -204,9 +204,9 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, # netbiosname # Get the netbiosname first (could be obtained from smb.conf in theory) res = secretsdb.search(expression="(flatname=%s)" % - names.domain,base="CN=Primary Domains", + names.domain, base="CN=Primary Domains", scope=ldb.SCOPE_SUBTREE, attrs=["sAMAccountName"]) - names.netbiosname = str(res[0]["sAMAccountName"]).replace("$","") + names.netbiosname = str(res[0]["sAMAccountName"]).replace("$", "") names.smbconf = smbconf @@ -215,7 +215,7 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, current = samdb.search(expression="(objectClass=*)", base="", scope=ldb.SCOPE_BASE, attrs=["defaultNamingContext", "schemaNamingContext", - "configurationNamingContext","rootDomainNamingContext", + "configurationNamingContext", "rootDomainNamingContext", "namingContexts"]) names.configdn = current[0]["configurationNamingContext"][0] @@ -275,7 +275,7 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, # domain guid/sid res6 = samdb.search(expression="(objectClass=*)", base=basedn, scope=ldb.SCOPE_BASE, attrs=["objectGUID", - "objectSid","msDS-Behavior-Version"]) + "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]) names.forestsid = ndr_unpack(security.dom_sid, res6[0]["objectSid"][0]) @@ -288,15 +288,15 @@ def find_provision_key_parameters(samdb, secretsdb, idmapdb, paths, smbconf, # policy guid res7 = samdb.search(expression="(name={%s})" % DEFAULT_POLICY_GUID, base="CN=Policies,CN=System," + basedn, - scope=ldb.SCOPE_ONELEVEL, attrs=["cn","displayName"]) - names.policyid = str(res7[0]["cn"]).replace("{","").replace("}","") + scope=ldb.SCOPE_ONELEVEL, attrs=["cn", "displayName"]) + names.policyid = str(res7[0]["cn"]).replace("{", "").replace("}", "") # dc policy guid res8 = samdb.search(expression="(name={%s})" % DEFAULT_DC_POLICY_GUID, base="CN=Policies,CN=System," + basedn, scope=ldb.SCOPE_ONELEVEL, - attrs=["cn","displayName"]) + attrs=["cn", "displayName"]) if len(res8) == 1: - names.policyid_dc = str(res8[0]["cn"]).replace("{","").replace("}","") + names.policyid_dc = str(res8[0]["cn"]).replace("{", "").replace("}", "") else: names.policyid_dc = None @@ -407,7 +407,7 @@ def set_provision_usn(samdb, low, high, id): samdb.add(delta) -def get_max_usn(samdb,basedn): +def get_max_usn(samdb, basedn): """ This function return the biggest USN present in the provision :param samdb: A LDB object pointing to the sam.ldb @@ -415,8 +415,8 @@ def get_max_usn(samdb,basedn): (ie. DC=foo, DC=bar) :return: The biggest USN in the provision""" - res = samdb.search(expression="objectClass=*",base=basedn, - scope=ldb.SCOPE_SUBTREE,attrs=["uSNChanged"], + res = samdb.search(expression="objectClass=*", base=basedn, + scope=ldb.SCOPE_SUBTREE, attrs=["uSNChanged"], controls=["search_options:1:2", "server_sort:1:1:uSNChanged", "paged_results:1:1"]) @@ -1264,10 +1264,10 @@ def create_default_gpo(sysvolpath, dnsdomain, policyguid, policyguid_dc): :param policyguid: GUID of the default domain policy :param policyguid_dc: GUID of the default domain controler policy """ - policy_path = getpolicypath(sysvolpath,dnsdomain,policyguid) + policy_path = getpolicypath(sysvolpath, dnsdomain, policyguid) create_gpo_struct(policy_path) - policy_path = getpolicypath(sysvolpath,dnsdomain,policyguid_dc) + policy_path = getpolicypath(sysvolpath, dnsdomain, policyguid_dc) create_gpo_struct(policy_path) diff --git a/python/samba/provision/backend.py b/python/samba/provision/backend.py index d85072a8723..e2e372e8b59 100644 --- a/python/samba/provision/backend.py +++ b/python/samba/provision/backend.py @@ -403,7 +403,7 @@ class OpenLDAPBackend(LDAPBackend): # For now, make these equal mmr_pass = self.ldapadminpass - url_list = filter(None,self.ol_mmr_urls.split(',')) + url_list = filter(None, self.ol_mmr_urls.split(',')) for url in url_list: self.logger.info("Using LDAP-URL: " + url) if len(url_list) == 1: @@ -512,7 +512,7 @@ class OpenLDAPBackend(LDAPBackend): "REFINT_CONFIG": refint_config, "INDEX_CONFIG": index_config, "ADMIN_UID": str(os.getuid()), - "NOSYNC": nosync_config,}) + "NOSYNC": nosync_config, }) self.setup_db_dir(os.path.join(self.ldapdir, "db", "forestdns")) self.setup_db_dir(os.path.join(self.ldapdir, "db", "domaindns")) diff --git a/python/samba/provision/common.py b/python/samba/provision/common.py index 03e22789515..2f95492d33a 100644 --- a/python/samba/provision/common.py +++ b/python/samba/provision/common.py @@ -42,7 +42,7 @@ def setup_path(file): return os.path.join(setup_dir(), file) -def setup_add_ldif(ldb, ldif_path, subst_vars=None,controls=["relax:0"]): +def setup_add_ldif(ldb, ldif_path, subst_vars=None, controls=["relax:0"]): """Setup a ldb in the private dir. :param ldb: LDB file to import data into @@ -55,7 +55,7 @@ def setup_add_ldif(ldb, ldif_path, subst_vars=None,controls=["relax:0"]): ldb.add_ldif(data, controls) -def setup_modify_ldif(ldb, ldif_path, subst_vars=None,controls=["relax:0"]): +def setup_modify_ldif(ldb, ldif_path, subst_vars=None, controls=["relax:0"]): """Modify a ldb in the private dir. :param ldb: LDB object. diff --git a/python/samba/schema.py b/python/samba/schema.py index 0958808cc88..55cb52e0fc4 100644 --- a/python/samba/schema.py +++ b/python/samba/schema.py @@ -219,7 +219,7 @@ def get_linked_attributes(schemadn, schemaldb): return attributes -def get_dnsyntax_attributes(schemadn,schemaldb): +def get_dnsyntax_attributes(schemadn, schemaldb): res = schemaldb.search( expression="(&(!(linkID=*))(objectclass=attributeSchema)(attributeSyntax=2.5.5.1))", base=schemadn, scope=SCOPE_ONELEVEL, diff --git a/python/samba/sd_utils.py b/python/samba/sd_utils.py index aebb2cabc4b..26e80ee2f4a 100644 --- a/python/samba/sd_utils.py +++ b/python/samba/sd_utils.py @@ -66,7 +66,7 @@ class SDUtils(object): def dacl_add_ace(self, object_dn, ace): """Add an ACE to an objects security descriptor """ - desc = self.read_sd_on_dn(object_dn,["show_deleted:1"]) + desc = self.read_sd_on_dn(object_dn, ["show_deleted:1"]) desc_sddl = desc.as_sddl(self.domain_sid) if ace in desc_sddl: return diff --git a/python/samba/tests/common.py b/python/samba/tests/common.py index 49ae2b07a78..146c6a8de9d 100644 --- a/python/samba/tests/common.py +++ b/python/samba/tests/common.py @@ -50,13 +50,13 @@ class CommonTests(samba.tests.TestCaseInTempDir): dn4 = dsdb_Dn(sam, "B:8:00000000:<GUID=ffffffff-17f4-452a-b002-963e1909d101>;OU=dn4,DC=samba,DC=example,DC=com") dn5 = dsdb_Dn(sam, "<GUID=ffffffff-27f4-452a-b002-963e1909d101>;OU=dn5,DC=samba,DC=example,DC=com") dn6 = dsdb_Dn(sam, "<GUID=00000000-27f4-452a-b002-963e1909d101>;OU=dn6,DC=samba,DC=example,DC=com") - unsorted_links14 = [dn1,dn2,dn3,dn4] + unsorted_links14 = [dn1, dn2, dn3, dn4] sorted_vals14 = [str(dn) for dn in sorted(unsorted_links14)] self.assertEquals(sorted_vals14[0], str(dn3)) self.assertEquals(sorted_vals14[1], str(dn2)) self.assertEquals(sorted_vals14[2], str(dn1)) self.assertEquals(sorted_vals14[3], str(dn4)) - unsorted_links56 = [dn5,dn6] + unsorted_links56 = [dn5, dn6] sorted_vals56 = [str(dn) for dn in sorted(unsorted_links56)] self.assertEquals(sorted_vals56[0], str(dn6)) self.assertEquals(sorted_vals56[1], str(dn5)) diff --git a/python/samba/tests/dcerpc/raw_protocol.py b/python/samba/tests/dcerpc/raw_protocol.py index 3f6e05b0ae0..2659b755ef7 100755 --- a/python/samba/tests/dcerpc/raw_protocol.py +++ b/python/samba/tests/dcerpc/raw_protocol.py @@ -800,7 +800,7 @@ class TestDCERPC_BIND(RawDCERPCTest): # With a known but wrong syntax we get a protocol error # see test_no_auth_presentation_ctx_valid2 - tsf1b_list = [zero_syntax,samba.dcerpc.epmapper.abstract_syntax(),ndr64] + tsf1b_list = [zero_syntax, samba.dcerpc.epmapper.abstract_syntax(), ndr64] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -862,7 +862,7 @@ class TestDCERPC_BIND(RawDCERPCTest): # With a unknown but wrong syntaxes we get NO protocol error # see test_no_auth_presentation_ctx_invalid4 - tsf1b_list = [zero_syntax,samba.dcerpc.epmapper.abstract_syntax()] + tsf1b_list = [zero_syntax, samba.dcerpc.epmapper.abstract_syntax()] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -977,7 +977,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - tsf1_list = [zero_syntax,ndr32] + tsf1_list = [zero_syntax, ndr32] ctx1 = dcerpc.ctx_list() ctx1.context_id = 1 ctx1.num_transfer_syntaxes = len(tsf1_list) @@ -1016,7 +1016,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - tsf2_list = [ndr32,ndr32] + tsf2_list = [ndr32, ndr32] ctx2 = dcerpc.ctx_list() ctx2.context_id = 2 ctx2.num_transfer_syntaxes = len(tsf2_list) @@ -1069,7 +1069,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx4.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx4.transfer_syntaxes = tsf4_list - req = self.generate_alter(call_id=34, ctx_list=[ctx3,ctx4]) + req = self.generate_alter(call_id=34, ctx_list=[ctx3, ctx4]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1106,7 +1106,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - req = self.generate_alter(call_id=43, ctx_list=[ctx4,ctx3]) + req = self.generate_alter(call_id=43, ctx_list=[ctx4, ctx3]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1156,7 +1156,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - req = self.generate_alter(call_id=44, ctx_list=[ctx4,ctx4]) + req = self.generate_alter(call_id=44, ctx_list=[ctx4, ctx4]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1220,7 +1220,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx5epm.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx5epm.transfer_syntaxes = tsf5epm_list - req = self.generate_alter(call_id=55, ctx_list=[ctx5mgmt,ctx5epm]) + req = self.generate_alter(call_id=55, ctx_list=[ctx5mgmt, ctx5epm]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1257,7 +1257,7 @@ class TestDCERPC_BIND(RawDCERPCTest): self.assertEquals(rep.u.cancel_count, 0) self.assertGreaterEqual(len(rep.u.stub_and_verifier), rep.u.alloc_hint) - req = self.generate_alter(call_id=55, ctx_list=[ctx5mgmt,ctx5epm]) + req = self.generate_alter(call_id=55, ctx_list=[ctx5mgmt, ctx5epm]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_ALTER_RESP, req.call_id, @@ -1337,7 +1337,7 @@ class TestDCERPC_BIND(RawDCERPCTest): zero_syntax = misc.ndr_syntax_id() ndr64 = base.transfer_syntax_ndr64() - tsf1_list = [btf1,btf2,zero_syntax] + tsf1_list = [btf1, btf2, zero_syntax] ctx1 = dcerpc.ctx_list() ctx1.context_id = 1 ctx1.num_transfer_syntaxes = len(tsf1_list) @@ -1372,7 +1372,7 @@ class TestDCERPC_BIND(RawDCERPCTest): zero_syntax = misc.ndr_syntax_id() - tsf1_list = [zero_syntax,btf1,btf2,zero_syntax] + tsf1_list = [zero_syntax, btf1, btf2, zero_syntax] ctx1 = dcerpc.ctx_list() ctx1.context_id = 1 ctx1.num_transfer_syntaxes = len(tsf1_list) @@ -1422,7 +1422,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx2.abstract_syntax = zero_syntax ctx2.transfer_syntaxes = tsf2_list - req = self.generate_bind(call_id=0, ctx_list=[ctx1,ctx2]) + req = self.generate_bind(call_id=0, ctx_list=[ctx1, ctx2]) self.send_pdu(req) rep = self.recv_pdu() self.verify_pdu(rep, dcerpc.DCERPC_PKT_BIND_NAK, req.call_id, @@ -1482,7 +1482,7 @@ class TestDCERPC_BIND(RawDCERPCTest): zero_syntax = misc.ndr_syntax_id() ndr64 = base.transfer_syntax_ndr64() - tsf1_list = [btf1,btf2,zero_syntax] + tsf1_list = [btf1, btf2, zero_syntax] ctx1 = dcerpc.ctx_list() ctx1.context_id = 1 ctx1.num_transfer_syntaxes = len(tsf1_list) @@ -1760,8 +1760,8 @@ class TestDCERPC_BIND(RawDCERPCTest): opnum=0, alloc_hint=0xffffffff, stub="\00" * chunk_size) - self.send_pdu(req,ndr_print=True,hexdump=True) - rep = self.recv_pdu(ndr_print=True,hexdump=True) + self.send_pdu(req, ndr_print=True, hexdump=True) + rep = self.recv_pdu(ndr_print=True, hexdump=True) self.verify_pdu(rep, dcerpc.DCERPC_PKT_RESPONSE, req.call_id, auth_length=0) self.assertNotEquals(rep.u.alloc_hint, 0) @@ -1985,7 +1985,7 @@ class TestDCERPC_BIND(RawDCERPCTest): alloc_hint -= thistime else: alloc_hint = 0 - self.send_pdu(req,hexdump=False) + self.send_pdu(req, hexdump=False) if fault_first is not None: rep = self.recv_pdu() # We get a fault back @@ -3545,7 +3545,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx1.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx1.transfer_syntaxes = tsf1_list - tsf1b_list = [ndr32,ndr64] + tsf1b_list = [ndr32, ndr64] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -3714,7 +3714,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx1.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx1.transfer_syntaxes = tsf1_list - tsf1b_list = [ndr32,ndr64] + tsf1b_list = [ndr32, ndr64] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -3802,7 +3802,7 @@ class TestDCERPC_BIND(RawDCERPCTest): ctx1.abstract_syntax = samba.dcerpc.mgmt.abstract_syntax() ctx1.transfer_syntaxes = tsf1_list - tsf1b_list = [ndr32,ndr64] + tsf1b_list = [ndr32, ndr64] ctx1b = dcerpc.ctx_list() ctx1b.context_id = 1 ctx1b.num_transfer_syntaxes = len(tsf1b_list) @@ -4935,7 +4935,7 @@ class TestDCERPC_BIND(RawDCERPCTest): time.sleep(0.5) self.connect() - ack2 = self.do_generic_bind(ctx=ctx,assoc_group_id=ack.u.assoc_group_id, + ack2 = self.do_generic_bind(ctx=ctx, assoc_group_id=ack.u.assoc_group_id, nak_reason=dcerpc.DCERPC_BIND_NAK_REASON_NOT_SPECIFIED) return diff --git a/python/samba/tests/dcerpc/raw_testcase.py b/python/samba/tests/dcerpc/raw_testcase.py index c7809ee2bc0..b6bba02bbb7 100644 --- a/python/samba/tests/dcerpc/raw_testcase.py +++ b/python/samba/tests/dcerpc/raw_testcase.py @@ -478,7 +478,7 @@ class RawDCERPCTest(TestCase): floor5.lhs = lhs5 floor5.rhs.ipaddr = "0.0.0.0" - floors = [floor1,floor2,floor3,floor4,floor5] + floors = [floor1, floor2, floor3, floor4, floor5] req_tower = samba.dcerpc.epmapper.epm_tower() req_tower.num_floors = len(floors) req_tower.floors = floors @@ -572,7 +572,7 @@ class RawDCERPCTest(TestCase): try: rep_pdu = self.recv_raw(hexdump=hexdump, timeout=timeout) if rep_pdu is None: - return (None,None) + return (None, None) rep = ndr_unpack(samba.dcerpc.dcerpc.ncacn_packet, rep_pdu, allow_remaining=True) if ndr_print: sys.stderr.write("recv_pdu: %s" % samba.ndr.ndr_print(rep)) diff --git a/python/samba/tests/dcerpc/rpcecho.py b/python/samba/tests/dcerpc/rpcecho.py index 33cb867f09c..0711ae41546 100644 --- a/python/samba/tests/dcerpc/rpcecho.py +++ b/python/samba/tests/dcerpc/rpcecho.py @@ -40,7 +40,7 @@ class RpcEchoTests(RpcInterfaceTestCase): self.assertEquals(2, self.conn.AddOne(1)) def test_echodata(self): - self.assertEquals([1,2,3], self.conn.EchoData([1, 2, 3])) + self.assertEquals([1, 2, 3], self.conn.EchoData([1, 2, 3])) def test_call(self): self.assertEquals(u"foobar", self.conn.TestCall(u"foobar")) @@ -48,7 +48,7 @@ class RpcEchoTests(RpcInterfaceTestCase): def test_surrounding(self): surrounding_struct = echo.Surrounding() surrounding_struct.x = 4 - surrounding_struct.surrounding = [1,2,3,4] + surrounding_struct.surrounding = [1, 2, 3, 4] y = self.conn.TestSurrounding(surrounding_struct) self.assertEquals(8 * [0], y.surrounding) diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py index e02ed8b7a4b..7dacfb2cbc3 100644 --- a/python/samba/tests/docs.py +++ b/python/samba/tests/docs.py @@ -103,7 +103,7 @@ class SmbDotConfTests(TestCase): 'panic action', 'homedir map', 'NIS homedir', 'server string', 'netbios name', 'socket options', 'use mmap', 'ctdbd socket', 'printing', 'printcap name', 'queueresume command', - 'queuepause command','lpresume command', 'lppause command', + 'queuepause command', 'lpresume command', 'lppause command', 'lprm command', 'lpq command', 'print command', 'template homedir', 'max open files', 'include system krb5 conf', 'rpc server dynamic port range', @@ -258,14 +258,14 @@ class SmbDotConfTests(TestCase): 'bytes': '10', 'octal': '0123', 'ustring': 'ustring', - 'enum':'', 'boolean-auto': '', 'char': 'a', 'list': 'a, b, c'} + 'enum': '', 'boolean-auto': '', 'char': 'a', 'list': 'a, b, c'} opposite_arbitrary = {'string': 'string2', 'boolean': 'no', 'integer': '6', 'boolean-rev': 'no', 'cmdlist': 'd e f', 'bytes': '11', 'octal': '0567', 'ustring': 'ustring2', - 'enum':'', 'boolean-auto': '', 'char': 'b', 'list': 'd, e, f'} + 'enum': '', 'boolean-auto': '', 'char': 'b', 'list': 'd, e, f'} failset = set() count = 0 diff --git a/python/samba/tests/dsdb_lock.py b/python/samba/tests/dsdb_lock.py index cd3851e2f40..332526ed795 100644 --- a/python/samba/tests/dsdb_lock.py +++ b/python/samba/tests/dsdb_lock.py @@ -235,7 +235,7 @@ class DsdbLockTestCase(SamDBTestCase): backenddb.transaction_start() - backenddb.add({"dn":"@DSDB_LOCK_TEST"}) + backenddb.add({"dn": "@DSDB_LOCK_TEST"}) backenddb.delete("@DSDB_LOCK_TEST") # Obtain a write lock @@ -335,7 +335,7 @@ class DsdbLockTestCase(SamDBTestCase): os.write(w1, b"started") self.assertEqual(os.read(r2, 3), b"add") - backenddb.add({"dn":"@DSDB_LOCK_TEST"}) + backenddb.add({"dn": "@DSDB_LOCK_TEST"}) backenddb.delete("@DSDB_LOCK_TEST") os.write(w1, b"added") diff --git a/python/samba/tests/dsdb_schema_attributes.py b/python/samba/tests/dsdb_schema_attributes.py index dbfafc4122d..d5ad336b13c 100644 --- a/python/samba/tests/dsdb_schema_attributes.py +++ b/python/samba/tests/dsdb_schema_attributes.py @@ -74,7 +74,7 @@ objectClass: attributeSchema adminDescription: """ + attr_name + """ adminDisplayName: """ + attr_name + """ cn: """ + attr_name + """ -attributeId: 1.3.6.1.4.1.7165.4.6.1.8.%d.""" % sub_oid + str(random.randint(1,100000)) + """ +attributeId: 1.3.6.1.4.1.7165.4.6.1.8.%d.""" % sub_oid + str(random.randint(1, 100000)) + """ attributeSyntax: 2.5.5.12 omSyntax: 64 instanceType: 4 diff --git a/python/samba/tests/hostconfig.py b/python/samba/tests/hostconfig.py index 526dc0fe4e3..94f511ccf3f 100644 --- a/python/samba/tests/hostconfig.py +++ b/python/samba/tests/hostconfig.py @@ -56,10 +56,10 @@ class ShareTests(TestCase): def test_iter(self): self.assertEquals([], list(self._get_shares({}))) - self.assertEquals([], list(self._get_shares({"global":{}}))) + self.assertEquals([], list(self._get_shares({"global": {}}))) self.assertEquals( ["bla"], - list(self._get_shares({"global":{}, "bla":{}}))) + list(self._get_shares({"global": {}, "bla": {}}))) def test_len(self): shares = self._get_shares({"global": {}}) diff --git a/python/samba/tests/password_hash_fl2003.py b/python/samba/tests/password_hash_fl2003.py index e1a7ec94452..bcf17f8f227 100644 --- a/python/samba/tests/password_hash_fl2003.py +++ b/python/samba/tests/password_hash_fl2003.py @@ -197,5 +197,5 @@ class PassWordHashFl2003Tests(PassWordHashTests): # up = ndr_unpack(drsblobs.package_PrimaryUserPasswordBlob, binascii.a2b_hex(up_package.data)) - self.checkUserPassword(up, [("{CRYPT}", "6",10000)]) + self.checkUserPassword(up, [("{CRYPT}", "6", 10000)]) self.checkNtHash(USER_PASS, up.current_nt_hash.hash) diff --git a/python/samba/tests/password_hash_fl2008.py b/python/samba/tests/password_hash_fl2008.py index 70455a6e9d8..91064b4f11b 100644 --- a/python/samba/tests/password_hash_fl2008.py +++ b/python/samba/tests/password_hash_fl2008.py @@ -112,7 +112,7 @@ class PassWordHashFl2008Tests(PassWordHashTests): # up = ndr_unpack(drsblobs.package_PrimaryUserPasswordBlob, binascii.a2b_hex(up_package.data)) - self.checkUserPassword(up, [("{CRYPT}", "6",None)]) + self.checkUserPassword(up, [("{CRYPT}", "6", None)]) self.checkNtHash(USER_PASS, up.current_nt_hash.hash) def test_supplementalCredentials_cleartext(self): @@ -206,5 +206,5 @@ class PassWordHashFl2008Tests(PassWordHashTests): # up = ndr_unpack(drsblobs.package_PrimaryUserPasswordBlob, binascii.a2b_hex(up_package.data)) - self.checkUserPassword(up, [("{CRYPT}", "5",100)]) + self.checkUserPassword(up, [("{CRYPT}", "5", 100)]) self.checkNtHash(USER_PASS, up.current_nt_hash.hash) diff --git a/python/samba/tests/posixacl.py b/python/samba/tests/posixacl.py index 97ce6bb4a6f..5926c11b158 100644 --- a/python/samba/tests/posixacl.py +++ b/python/samba/tests/posixacl.py @@ -80,7 +80,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf, direct_db_access=True) anysid = security.dom_sid(security.SID_NT_SELF) - self.assertEquals(facl.as_sddl(anysid),acl) + self.assertEquals(facl.as_sddl(anysid), acl) def test_setntacl_smbd_setposixacl_getntacl(self): acl = ACL @@ -147,7 +147,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf, direct_db_access=False) anysid = security.dom_sid(security.SID_NT_SELF) - self.assertEquals(facl.as_sddl(anysid),acl) + self.assertEquals(facl.as_sddl(anysid), acl) def test_setntacl_smbd_getntacl_smbd(self): acl = ACL @@ -155,7 +155,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf, direct_db_access=False) anysid = security.dom_sid(security.SID_NT_SELF) - self.assertEquals(facl.as_sddl(anysid),acl) + self.assertEquals(facl.as_sddl(anysid), acl) def test_setntacl_smbd_setposixacl_getntacl_smbd(self): acl = ACL @@ -176,11 +176,11 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) # This invalidates the hash of the NT acl just set because there is a hook in the posix ACL set code s4_passdb = passdb.PDB(self.lp.get("passdb backend")) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) smbd.set_simple_acl(self.tempf, 0o640, BA_gid) # This should re-calculate an ACL based on the posix details - facl = getntacl(self.lp,self.tempf, direct_db_access=False) + facl = getntacl(self.lp, self.tempf, direct_db_access=False) anysid = security.dom_sid(security.SID_NT_SELF) self.assertEquals(simple_acl_from_posix, facl.as_sddl(anysid)) @@ -190,7 +190,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf, direct_db_access=False) domsid = security.dom_sid(DOM_SID) - self.assertEquals(facl.as_sddl(domsid),acl) + self.assertEquals(facl.as_sddl(domsid), acl) def test_setntacl_getposixacl(self): acl = ACL @@ -198,7 +198,7 @@ class PosixAclMappingTests(TestCaseInTempDir): session_info=self.get_session_info()) facl = getntacl(self.lp, self.tempf) anysid = security.dom_sid(security.SID_NT_SELF) - self.assertEquals(facl.as_sddl(anysid),acl) + self.assertEquals(facl.as_sddl(anysid), acl) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) def test_setposixacl_getntacl(self): @@ -221,10 +221,10 @@ class PosixAclMappingTests(TestCaseInTempDir): user_SID = s4_passdb.uid_to_sid(os.stat(self.tempdir).st_uid) BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) - (BA_id,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_id, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS) - (SO_id,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_id, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) smbd.chown(self.tempdir, BA_id, SO_id) smbd.set_simple_acl(self.tempdir, 0o750) @@ -237,7 +237,7 @@ class PosixAclMappingTests(TestCaseInTempDir): def test_setposixacl_group_getntacl_smbd(self): BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) group_SID = s4_passdb.gid_to_sid(os.stat(self.tempf).st_gid) user_SID = s4_passdb.uid_to_sid(os.stat(self.tempf).st_uid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) @@ -285,7 +285,7 @@ class PosixAclMappingTests(TestCaseInTempDir): def test_setposixacl_group_getposixacl(self): BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS) s4_passdb = passdb.PDB(self.lp.get("passdb backend")) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) smbd.set_simple_acl(self.tempf, 0o670, BA_gid) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) @@ -315,7 +315,7 @@ class PosixAclMappingTests(TestCaseInTempDir): setntacl(self.lp, self.tempf, acl, str(domsid), use_ntvfs=False, session_info=session_info) facl = getntacl(self.lp, self.tempf) - self.assertEquals(facl.as_sddl(domsid),acl) + self.assertEquals(facl.as_sddl(domsid), acl) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) nwrap_module_so_path = os.getenv('NSS_WRAPPER_MODULE_SO_PATH') @@ -335,15 +335,15 @@ class PosixAclMappingTests(TestCaseInTempDir): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) - (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_gid, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) + (SY_gid, SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) + (AU_gid, AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 13, self.print_posix_acl(posix_acl)) @@ -463,7 +463,7 @@ class PosixAclMappingTests(TestCaseInTempDir): setntacl(self.lp, self.tempdir, acl, str(domsid), use_ntvfs=False, session_info=session_info) facl = getntacl(self.lp, self.tempdir) - self.assertEquals(facl.as_sddl(domsid),acl) + 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)) @@ -477,15 +477,15 @@ class PosixAclMappingTests(TestCaseInTempDir): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) - (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_gid, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) + (SY_gid, SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) + (AU_gid, AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 13, self.print_posix_acl(posix_acl)) @@ -558,7 +558,7 @@ class PosixAclMappingTests(TestCaseInTempDir): setntacl(self.lp, self.tempdir, acl, str(domsid), use_ntvfs=False, session_info=session_info) facl = getntacl(self.lp, self.tempdir) - self.assertEquals(facl.as_sddl(domsid),acl) + 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)) @@ -573,17 +573,17 @@ class PosixAclMappingTests(TestCaseInTempDir): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) - (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_gid, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) + (SY_gid, SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) + (AU_gid, AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) - (PA_gid,PA_type) = s4_passdb.sid_to_id(PA_sid) + (PA_gid, PA_type) = s4_passdb.sid_to_id(PA_sid) self.assertEquals(PA_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 15, self.print_posix_acl(posix_acl)) @@ -667,7 +667,7 @@ class PosixAclMappingTests(TestCaseInTempDir): setntacl(self.lp, self.tempf, acl, str(domsid), use_ntvfs=False, session_info=session_info) facl = getntacl(self.lp, self.tempf) - self.assertEquals(facl.as_sddl(domsid),acl) + self.assertEquals(facl.as_sddl(domsid), acl) posix_acl = smbd.get_sys_acl(self.tempf, smb_acl.SMB_ACL_TYPE_ACCESS) nwrap_module_so_path = os.getenv('NSS_WRAPPER_MODULE_SO_PATH') @@ -688,17 +688,17 @@ class PosixAclMappingTests(TestCaseInTempDir): # These assertions correct for current ad_dc selftest # configuration. When other environments have a broad range of # groups mapped via passdb, we can relax some of these checks - (LA_uid,LA_type) = s4_passdb.sid_to_id(LA_sid) + (LA_uid, LA_type) = s4_passdb.sid_to_id(LA_sid) self.assertEquals(LA_type, idmap.ID_TYPE_UID) - (BA_gid,BA_type) = s4_passdb.sid_to_id(BA_sid) + (BA_gid, BA_type) = s4_passdb.sid_to_id(BA_sid) self.assertEquals(BA_type, idmap.ID_TYPE_BOTH) - (SO_gid,SO_type) = s4_passdb.sid_to_id(SO_sid) + (SO_gid, SO_type) = s4_passdb.sid_to_id(SO_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (SY_gid,SY_type) = s4_passdb.sid_to_id(SY_sid) + (SY_gid, SY_type) = s4_passdb.sid_to_id(SY_sid) self.assertEquals(SO_type, idmap.ID_TYPE_BOTH) - (AU_gid,AU_type) = s4_passdb.sid_to_id(AU_sid) + (AU_gid, AU_type) = s4_passdb.sid_to_id(AU_sid) self.assertEquals(AU_type, idmap.ID_TYPE_BOTH) - (PA_gid,PA_type) = s4_passdb.sid_to_id(PA_sid) + (PA_gid, PA_type) = s4_passdb.sid_to_id(PA_sid) self.assertEquals(PA_type, idmap.ID_TYPE_BOTH) self.assertEquals(posix_acl.count, 15, self.print_posix_acl(posix_acl)) diff --git a/python/samba/tests/samba3sam.py b/python/samba/tests/samba3sam.py index a5e39eebe59..1221435fcbc 100644 --- a/python/samba/tests/samba3sam.py +++ b/python/samba/tests/samba3sam.py @@ -203,7 +203,7 @@ class Samba3SamTestCase(MapBaseTestCase): # msg = self.ldb.search(expression="(cn=Foo)", base="cn=Foo", scope=SCOPE_BASE, - attrs=['foo','blah','cn','showInAdvancedViewOnly']) + attrs=['foo', 'blah', 'cn', 'showInAdvancedViewOnly']) self.assertEquals(len(msg), 1) self.assertEquals(str(msg[0]["showInAdvancedViewOnly"]), "TRUE") self.assertEquals(str(msg[0]["foo"]), "bar") @@ -218,14 +218,14 @@ class Samba3SamTestCase(MapBaseTestCase): # Checking for existence of record (remote) msg = self.ldb.search(expression="(unixName=bin)", - attrs=['unixName','cn','dn', 'sambaUnicodePwd']) + attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd']) self.assertEquals(len(msg), 1) self.assertEquals(str(msg[0]["cn"]), "Niemand") self.assertEquals(str(msg[0]["sambaUnicodePwd"]), "geheim") # Checking for existence of record (local && remote) msg = self.ldb.search(expression="(&(unixName=bin)(sambaUnicodePwd=geheim))", - attrs=['unixName','cn','dn', 'sambaUnicodePwd']) + attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd']) self.assertEquals(len(msg), 1) # TODO: should check with more records self.assertEquals(str(msg[0]["cn"]), "Niemand") self.assertEquals(str(msg[0]["unixName"]), "bin") @@ -233,7 +233,7 @@ class Samba3SamTestCase(MapBaseTestCase): # Checking for existence of record (local || remote) msg = self.ldb.search(expression="(|(unixName=bin)(sambaUnicodePwd=geheim))", - attrs=['unixName','cn','dn', 'sambaUnicodePwd']) + attrs=['unixName', 'cn', 'dn', 'sambaUnicodePwd']) #print "got %d replies" % len(msg) self.assertEquals(len(msg), 1) # TODO: should check with more records self.assertEquals(str(msg[0]["cn"]), "Niemand") @@ -806,7 +806,7 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052 self.assertEquals(str(res[4]["lastLogon"]), "z") # Clean up - dns = [self.samba4.dn("cn=%s" % n) for n in ["A","B","C","X","Y","Z"]] + dns = [self.samba4.dn("cn=%s" % n) for n in ["A", "B", "C", "X", "Y", "Z"]] for dn in dns: self.ldb.delete(dn) diff --git a/python/samba/tests/samba_tool/dnscmd.py b/python/samba/tests/samba_tool/dnscmd.py index 5c27c80f783..bc0e133c81c 100644 --- a/python/samba/tests/samba_tool/dnscmd.py +++ b/python/samba/tests/samba_tool/dnscmd.py @@ -88,12 +88,12 @@ class DnsCmdTestCase(SambaToolCmdTest): "::1", "::", "1:1:1:1:1:1:1:1"], - "PTR":good_dns, - "CNAME":good_dns, - "NS":good_dns, - "MX":good_mx, - "SRV":good_srv, - "TXT":["text", "", "@#!", "\n"] + "PTR": good_dns, + "CNAME": good_dns, + "NS": good_dns, + "MX": good_mx, + "SRV": good_srv, + "TXT": ["text", "", "@#!", "\n"] } self.bad_records = { @@ -105,11 +105,11 @@ class DnsCmdTestCase(SambaToolCmdTest): "1234:5678:9ABC:DEF0:1234:5678:9ABC:DEF0:1234", "1234:5678:9ABC:DEF0:1234:5678:9ABC", "1111::1111::1111"], - "PTR":bad_dns, - "CNAME":bad_dns, - "NS":bad_dns, - "MX":bad_mx, - "SRV":bad_srv + "PTR": bad_dns, + "CNAME": bad_dns, + "NS": bad_dns, + "MX": bad_mx, + "SRV": bad_srv } def tearDown(self): diff --git a/python/samba/tests/samba_tool/forest.py b/python/samba/tests/samba_tool/forest.py index 1f2194671e9..11c77e6105e 100644 --- a/python/samba/tests/samba_tool/forest.py +++ b/python/samba/tests/samba_tool/forest.py @@ -49,7 +49,7 @@ class ForestCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("dsheuristics: <NO VALUE>", out) def test_modify_dsheuristics(self): @@ -62,5 +62,5 @@ class ForestCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("set dsheuristics: 0000002", out) diff --git a/python/samba/tests/samba_tool/fsmo.py b/python/samba/tests/samba_tool/fsmo.py index dcef4e5209b..51b735ebcfb 100644 --- a/python/samba/tests/samba_tool/fsmo.py +++ b/python/samba/tests/samba_tool/fsmo.py @@ -26,7 +26,7 @@ class FsmoCmdTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd("fsmo", "show") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") # Check that the output is sensible samdb = self.getSamDB("-H", "ldap://%s" % os.environ["SERVER"], diff --git a/python/samba/tests/samba_tool/group.py b/python/samba/tests/samba_tool/group.py index bc966ff3e22..8b6fc889cf1 100644 --- a/python/samba/tests/samba_tool/group.py +++ b/python/samba/tests/samba_tool/group.py @@ -88,7 +88,7 @@ class GroupCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","There shouldn't be any error message") + self.assertEquals(err, "", "There shouldn't be any error message") self.assertIn("Added group %s" % group["name"], out) found = self._find_group(group["name"]) @@ -177,7 +177,7 @@ class GroupCmdTestCase(SambaToolCmdTest): "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("dn: CN=Domain Users,CN=Users,DC=samba,DC=example,DC=com", out) def _randomGroup(self, base={}): diff --git a/python/samba/tests/samba_tool/join.py b/python/samba/tests/samba_tool/join.py index 1cc688f75dd..bfb534cd297 100644 --- a/python/samba/tests/samba_tool/join.py +++ b/python/samba/tests/samba_tool/join.py @@ -26,4 +26,4 @@ class JoinCmdTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd("domain", "join", os.environ["REALM"], "dc", "-U%s%%%s" % (os.environ["USERNAME"], os.environ["PASSWORD"])) self.assertCmdFail(result) - self.assertTrue("Not removing account" in err,"Should fail with exception") + self.assertTrue("Not removing account" in err, "Should fail with exception") diff --git a/python/samba/tests/samba_tool/ntacl.py b/python/samba/tests/samba_tool/ntacl.py index 3da75065548..4078c271d98 100644 --- a/python/samba/tests/samba_tool/ntacl.py +++ b/python/samba/tests/samba_tool/ntacl.py @@ -32,7 +32,7 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd("ntacl", "sysvolreset", "--use-ntvfs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(out, "", "Shouldn't be any output messages") self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err) def test_s3fs(self): @@ -40,34 +40,34 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest): "--use-s3fs") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") def test_ntvfs_check(self): (result, out, err) = self.runsubcmd("ntacl", "sysvolreset", "--use-ntvfs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(out, "", "Shouldn't be any output messages") self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err) # Now check they were set correctly (result, out, err) = self.runsubcmd("ntacl", "sysvolcheck") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") def test_s3fs_check(self): (result, out, err) = self.runsubcmd("ntacl", "sysvolreset", "--use-s3fs") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") # Now check they were set correctly (result, out, err) = self.runsubcmd("ntacl", "sysvolcheck") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") class NtACLCmdGetSetTestCase(SambaToolCmdTest): """Tests for samba-tool ntacl get/set subcommands""" @@ -77,59 +77,59 @@ 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, "--use-ntvfs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(out, "", "Shouldn't be any output messages") self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err) 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, "--use-s3fs") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") 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, "--use-ntvfs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") + self.assertEquals(out, "", "Shouldn't be any output messages") self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err) # Now check they were set correctly (result, out, err) = self.runsubcmd("ntacl", "get", tempf, "--use-ntvfs", "--as-sddl") self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") 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, "--use-s3fs") self.assertCmdSuccess(result, out, err) - self.assertEquals(out,"","Shouldn't be any output messages") - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(out, "", "Shouldn't be any output messages") + self.assertEquals(err, "", "Shouldn't be any error messages") # Now check they were set correctly (result, out, err) = self.runsubcmd("ntacl", "get", tempf, "--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(err, "", "Shouldn't be any error messages") + self.assertEquals(self.acl + "\n", out, "Output should be the ACL") diff --git a/python/samba/tests/samba_tool/rodc.py b/python/samba/tests/samba_tool/rodc.py index 3ae52449890..2259f06aa7d 100644 --- a/python/samba/tests/samba_tool/rodc.py +++ b/python/samba/tests/samba_tool/rodc.py @@ -35,7 +35,7 @@ class RodcCmdTestCase(SambaToolCmdTest): self.creds.guess(self.lp) self.session = system_session() self.ldb = SamDB("ldap://" + os.environ["DC_SERVER"], - session_info=self.session, credentials=self.creds,lp=self.lp) + session_info=self.session, credentials=self.creds, lp=self.lp) self.base_dn = self.ldb.domain_dn() diff --git a/python/samba/tests/samba_tool/schema.py b/python/samba/tests/samba_tool/schema.py index 56d09a78de7..ae095994e53 100644 --- a/python/samba/tests/samba_tool/schema.py +++ b/python/samba/tests/samba_tool/schema.py @@ -40,7 +40,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("dn: CN=uid,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) def test_modify_attribute_searchflags(self): @@ -60,7 +60,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("modified cn=uid,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) (result, out, err) = self.runsublevelcmd("schema", ("attribute", @@ -71,7 +71,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("modified cn=uid,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) (result, out, err) = self.runsublevelcmd("schema", ("attribute", @@ -82,7 +82,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("modified cn=uid,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) def test_show_oc_attribute(self): @@ -94,7 +94,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("--- MAY contain ---", out) self.assertIn("--- MUST contain ---", out) @@ -107,7 +107,7 @@ class SchemaCmdTestCase(SambaToolCmdTest): os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("dn: CN=Person,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com", out) diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py index 4d264b4027d..4d39e822720 100644 --- a/python/samba/tests/samba_tool/user.py +++ b/python/samba/tests/samba_tool/user.py @@ -52,7 +52,7 @@ class UserCmdTestCase(SambaToolCmdTest): (result, out, err) = user["createUserFn"](user) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("User '%s' created successfully" % user["name"], out) user["checkUserFn"](user) @@ -94,7 +94,7 @@ class UserCmdTestCase(SambaToolCmdTest): "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("User '%s' created successfully" % user["name"], out) found = self._find_user(user["name"]) @@ -194,7 +194,7 @@ class UserCmdTestCase(SambaToolCmdTest): "-H", "ldap://%s" % os.environ["DC_SERVER"], "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err, "Ensure setpassword runs") - self.assertEquals(err,"","setpassword with url") + self.assertEquals(err, "", "setpassword with url") self.assertMatch(out, "Changed password OK", "setpassword with url") attributes = "sAMAccountName,unicodePwd,supplementalCredentials,virtualClearTextUTF8,virtualClearTextUTF16,virtualSSHA,virtualSambaGPG" @@ -203,7 +203,7 @@ class UserCmdTestCase(SambaToolCmdTest): "--attributes=%s" % attributes, "--decrypt-samba-gpg") self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --cache-ldb-initialize runs") - self.assertEqual(err,"","getpassword without url") + self.assertEqual(err, "", "getpassword without url") cache_attrs = { "objectClass": {"value": "userSyncPasswords"}, "samdbUrl": {}, @@ -221,7 +221,7 @@ class UserCmdTestCase(SambaToolCmdTest): (result, out, err) = self.runsubcmd("user", "syncpasswords", "--no-wait") self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --no-wait runs") - self.assertEqual(err,"","syncpasswords --no-wait") + self.assertEqual(err, "", "syncpasswords --no-wait") self.assertMatch(out, "dirsync_loop(): results 0", "syncpasswords --no-wait: 'dirsync_loop(): results 0': out[%s]" % (out)) for user in self.users: @@ -242,12 +242,12 @@ class UserCmdTestCase(SambaToolCmdTest): user["name"], "--newpassword=%s" % newpasswd) self.assertCmdSuccess(result, out, err, "Ensure setpassword runs") - self.assertEquals(err,"","setpassword without url") + self.assertEquals(err, "", "setpassword without url") self.assertMatch(out, "Changed password OK", "setpassword without url") (result, out, err) = self.runsubcmd("user", "syncpasswords", "--no-wait") self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --no-wait runs") - self.assertEqual(err,"","syncpasswords --no-wait") + self.assertEqual(err, "", "syncpasswords --no-wait") self.assertMatch(out, "dirsync_loop(): results 0", "syncpasswords --no-wait: 'dirsync_loop(): results 0': out[%s]" % (out)) self.assertMatch(out, "sAMAccountName: %s" % (user["name"]), @@ -273,7 +273,7 @@ class UserCmdTestCase(SambaToolCmdTest): "--attributes=%s" % attributes, "--decrypt-samba-gpg") self.assertCmdSuccess(result, out, err, "Ensure getpassword runs") - self.assertEqual(err,"","getpassword without url") + self.assertEqual(err, "", "getpassword without url") self.assertMatch(out, "Got password OK", "getpassword without url") self.assertMatch(out, "sAMAccountName: %s" % (user["name"]), "getpassword: 'sAMAccountName': %s out[%s]" % (user["name"], out)) @@ -299,7 +299,7 @@ class UserCmdTestCase(SambaToolCmdTest): "-H", "ldap://%s" % os.environ["DC_SERVER"], "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err, "Ensure setpassword runs") - self.assertEquals(err,"","setpassword with forced change") + self.assertEquals(err, "", "setpassword with forced change") self.assertMatch(out, "Changed password OK", "setpassword with forced change") @@ -464,7 +464,7 @@ sAMAccountName: %s "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("User '%s' created successfully" % user["name"], out) self._check_posix_user(user) @@ -493,7 +493,7 @@ sAMAccountName: %s "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"])) self.assertCmdSuccess(result, out, err) - self.assertEquals(err,"","Shouldn't be any error messages") + self.assertEquals(err, "", "Shouldn't be any error messages") self.assertIn("User '%s' created successfully" % user["name"], out) self._check_posix_user(user) diff --git a/python/samba/tests/security.py b/python/samba/tests/security.py index 02c1e8897f6..ed959ee5499 100644 --- a/python/samba/tests/security.py +++ b/python/samba/tests/security.py @@ -66,10 +66,10 @@ class SecurityDescriptorTests(samba.tests.TestCase): self.assertEquals(desc.type, 0x8004) def test_from_sddl_invalidsddl(self): - self.assertRaises(TypeError,security.descriptor.from_sddl, "foo",security.dom_sid("S-2-0-0")) + self.assertRaises(TypeError, security.descriptor.from_sddl, "foo", security.dom_sid("S-2-0-0")) def test_from_sddl_invalidtype1(self): - self.assertRaises(TypeError, security.descriptor.from_sddl, security.dom_sid('S-2-0-0-512'),security.dom_sid("S-2-0-0")) + self.assertRaises(TypeError, security.descriptor.from_sddl, security.dom_sid('S-2-0-0-512'), security.dom_sid("S-2-0-0")) def test_from_sddl_invalidtype2(self): sddl = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)" @@ -90,7 +90,7 @@ class SecurityDescriptorTests(samba.tests.TestCase): text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)" dom = security.dom_sid("S-2-0-0") desc1 = security.descriptor.from_sddl(text, dom) - self.assertRaises(TypeError, desc1.as_sddl,text) + self.assertRaises(TypeError, desc1.as_sddl, text) def test_as_sddl_no_domainsid(self): diff --git a/python/samba/tests/smb.py b/python/samba/tests/smb.py index 296815f3a97..59fd6ed9d41 100644 --- a/python/samba/tests/smb.py +++ b/python/samba/tests/smb.py @@ -25,7 +25,7 @@ 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 -test_dir = os.path.join(addom, 'testing_%d' % random.randint(0,0xFFFF)) +test_dir = os.path.join(addom, 'testing_%d' % random.randint(0, 0xFFFF)) test_file = os.path.join(test_dir, 'testing').replace('/', '\\') class SMBTests(samba.tests.TestCase): @@ -50,7 +50,7 @@ class SMBTests(samba.tests.TestCase): ls = [f['name'] for f in self.conn.list(addom)] self.assertIn('scripts', ls, msg='"scripts" directory not found in sysvol') - self.assertIn('Policies',ls, + self.assertIn('Policies', ls, msg='"Policies" directory not found in sysvol') def test_unlink(self): diff --git a/python/samba/tests/upgradeprovisionneeddc.py b/python/samba/tests/upgradeprovisionneeddc.py index 9e523961691..73a3152ca46 100644 --- a/python/samba/tests/upgradeprovisionneeddc.py +++ b/python/samba/tests/upgradeprovisionneeddc.py @@ -24,7 +24,7 @@ import shutil from samba import param from samba.credentials import Credentials from samba.auth import system_session -from samba.provision import getpolicypath,find_provision_key_parameters +from samba.provision import getpolicypath, find_provision_key_parameters from samba.upgradehelpers import (get_paths, get_ldbs, identic_rename, updateOEMInfo, getOEMInfo, update_gpo, diff --git a/python/samba/upgrade.py b/python/samba/upgrade.py index 18c8afd3f1b..fe3309af166 100644 --- a/python/samba/upgrade.py +++ b/python/samba/upgrade.py @@ -665,7 +665,7 @@ Please fix this account before attempting to upgrade again creds.guess(samba3.lp) creds.set_bind_dn(ldapuser) creds.set_password(ldappass) - urls = samba3.lp.get("passdb backend").split(":",1)[1].strip('"') + urls = samba3.lp.get("passdb backend").split(":", 1)[1].strip('"') for url in urls.split(): try: ldb_object = Ldb(url, credentials=creds) diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py index 2e6ed1cfdbc..262f664fc10 100644 --- a/python/samba/upgradehelpers.py +++ b/python/samba/upgradehelpers.py @@ -62,8 +62,8 @@ hashAttrNotCopied = set(["dn", "whenCreated", "whenChanged", "objectGUID", "objectCategory", "distinguishedName", "nTMixedDomain", "showInAdvancedViewOnly", "instanceType", "msDS-Behavior-Version", "nextRid", "cn", "versionNumber", "lmPwdHistory", "pwdLastSet", - "ntPwdHistory", "unicodePwd","dBCSPwd", "supplementalCredentials", - "gPCUserExtensionNames", "gPCMachineExtensionNames","maxPwdAge", "secret", + "ntPwdHistory", "unicodePwd", "dBCSPwd", "supplementalCredentials", + "gPCUserExtensionNames", "gPCMachineExtensionNames", "maxPwdAge", "secret", "possibleInferiors", "privilege", "sAMAccountType"]) @@ -221,15 +221,15 @@ def update_policyids(names, samdb): # policy guid res = samdb.search(expression="(displayName=Default Domain Policy)", base="CN=Policies,CN=System," + str(names.rootdn), - scope=SCOPE_ONELEVEL, attrs=["cn","displayName"]) - names.policyid = str(res[0]["cn"]).replace("{","").replace("}","") + scope=SCOPE_ONELEVEL, attrs=["cn", "displayName"]) + names.policyid = str(res[0]["cn"]).replace("{", "").replace("}", "") # dc policy guid res2 = samdb.search(expression="(displayName=Default Domain Controllers" " Policy)", base="CN=Policies,CN=System," + str(names.rootdn), - scope=SCOPE_ONELEVEL, attrs=["cn","displayName"]) + scope=SCOPE_ONELEVEL, attrs=["cn", "displayName"]) if len(res2) == 1: - names.policyid_dc = str(res2[0]["cn"]).replace("{","").replace("}","") + names.policyid_dc = str(res2[0]["cn"]).replace("{", "").replace("}", "") else: names.policyid_dc = None @@ -290,7 +290,7 @@ def dn_sort(x, y): return ret else: if i == minimum - 1: - assert len1 != len2,"PB PB PB" + " ".join(tab1) + " / " + " ".join(tab2) + assert len1 != len2, "PB PB PB" + " ".join(tab1) + " / " + " ".join(tab2) if len1 > len2: return 1 else: @@ -480,7 +480,7 @@ def increment_calculated_keyversion_number(samdb, rootdn, hashDns): have """ entry = samdb.search(expression='(objectClass=user)', - base=ldb.Dn(samdb,str(rootdn)), + base=ldb.Dn(samdb, str(rootdn)), scope=SCOPE_SUBTREE, attrs=["msDs-KeyVersionNumber"], controls=["search_options:1:2"]) done = 0 @@ -560,7 +560,7 @@ def construct_existor_expr(attrs): if len(attrs) > 0: expr = "(|" for att in attrs: - expr = "%s(%s=*)" %(expr,att) + expr = "%s(%s=*)" %(expr, att) expr = "%s)" %expr return expr @@ -681,7 +681,7 @@ def search_constructed_attrs_stored(samdb, rootdn, attrs): return hashAtt entry = samdb.search(expression=expr, base=ldb.Dn(samdb, str(rootdn)), scope=SCOPE_SUBTREE, attrs=attrs, - controls=["search_options:1:2","bypassoperational:0"]) + controls=["search_options:1:2", "bypassoperational:0"]) if len(entry) == 0: # Nothing anymore return hashAtt @@ -809,9 +809,9 @@ def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid): print("To track the USNs modified/created by provision and upgrade proivsion,") print(" the following ranges are proposed to be added to your provision sam.ldb: \n%s" % ldif) print("We recommend to review them, and if it's correct to integrate the following ldif: %s in your sam.ldb" % file) - print("You can load this file like this: ldbadd -H %s %s\n" %(str(samdb_path),file)) + print("You can load this file like this: ldbadd -H %s %s\n" %(str(samdb_path), file)) ldif = "dn: @PROVISION\nprovisionnerID: %s\n%s" % (invocationid, ldif) - open(file,'w').write(ldif) + open(file, 'w').write(ldif) def int64range2str(value): """Display the int64 range stored in value as xxx-yyy diff --git a/python/samba/web_server/__init__.py b/python/samba/web_server/__init__.py index 6aa0872953f..4344fccfaa7 100644 --- a/python/samba/web_server/__init__.py +++ b/python/samba/web_server/__init__.py @@ -61,7 +61,7 @@ def __call__(environ, start_response): if name == "": if have_swat: start_response('301 Redirect', - [('Location', urljoin(application_uri(environ), 'swat')),]) + [('Location', urljoin(application_uri(environ), 'swat')), ]) return [] else: return render_placeholder(environ, start_response) |