From c7c3d903c161d21d9b70a6c6d31426e2b351e5f2 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 13:38:42 +0000 Subject: [PATCH 01/14] samba python tests: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- python/samba/tests/auth_log.py | 2 +- python/samba/tests/auth_log_base.py | 2 +- python/samba/tests/auth_log_pass_change.py | 12 ++++---- python/samba/tests/blackbox/ndrdump.py | 2 +- python/samba/tests/dcerpc/dnsserver.py | 4 +-- python/samba/tests/dcerpc/testrpc.py | 32 +++++++++++----------- python/samba/tests/dns.py | 18 ++++++------ python/samba/tests/dns_base.py | 8 +++--- python/samba/tests/dns_forwarder.py | 14 +++++----- python/samba/tests/dns_forwarder_helpers/server.py | 2 +- python/samba/tests/samba3sam.py | 2 +- 11 files changed, 49 insertions(+), 49 deletions(-) diff --git a/python/samba/tests/auth_log.py b/python/samba/tests/auth_log.py index 6b032a80edc..61cfa62f44d 100644 --- a/python/samba/tests/auth_log.py +++ b/python/samba/tests/auth_log.py @@ -140,7 +140,7 @@ def rpc_ncacn_np_krb5_check(self, messages, authTypes, service, binding, protect msg = messages[2] self.assertEquals("Authorization", msg["type"]) serviceDescription = "SMB" - print "binding %s" % binding + print("binding %s" % binding) if binding == "[smb2]": serviceDescription = "SMB2" diff --git a/python/samba/tests/auth_log_base.py b/python/samba/tests/auth_log_base.py index aefd57e5516..94942cb20c0 100644 --- a/python/samba/tests/auth_log_base.py +++ b/python/samba/tests/auth_log_base.py @@ -40,7 +40,7 @@ def setUp(self): def messageHandler( context, msgType, src, message): # This does not look like sub unit output and it # makes these tests much easier to debug. - print message + print(message) jsonMsg = json.loads(message) context["messages"].append( jsonMsg) diff --git a/python/samba/tests/auth_log_pass_change.py b/python/samba/tests/auth_log_pass_change.py index 77758a4430a..7e1349b9e32 100644 --- a/python/samba/tests/auth_log_pass_change.py +++ b/python/samba/tests/auth_log_pass_change.py @@ -50,10 +50,10 @@ def setUp(self): credentials=self.get_credentials(), lp=self.get_loadparm()) - print "ldb %s" % type(self.ldb) + print("ldb %s" % type(self.ldb)) # Gets back the basedn base_dn = self.ldb.domain_dn() - print "base_dn %s" % base_dn + print("base_dn %s" % base_dn) # Gets back the configuration basedn configuration_dn = self.ldb.get_config_basedn().get_linearized() @@ -116,7 +116,7 @@ def isLastExpectedMessage(msg): messages = self.waitForMessages(isLastExpectedMessage) - print "Received %d messages" % len(messages) + print("Received %d messages" % len(messages)) self.assertEquals(8, len(messages), "Did not receive the expected number of messages") @@ -263,7 +263,7 @@ def isLastExpectedMessage(msg): ) messages = self.waitForMessages(isLastExpectedMessage) - print "Received %d messages" % len(messages) + print("Received %d messages" % len(messages)) self.assertEquals(4, len(messages), "Did not receive the expected number of messages") @@ -295,7 +295,7 @@ def isLastExpectedMessage(msg): pass messages = self.waitForMessages(isLastExpectedMessage) - print "Received %d messages" % len(messages) + print("Received %d messages" % len(messages)) self.assertEquals(3, len(messages), "Did not receive the expected number of messages") @@ -326,7 +326,7 @@ def isLastExpectedMessage(msg): pass messages = self.waitForMessages(isLastExpectedMessage) - print "Received %d messages" % len(messages) + print("Received %d messages" % len(messages)) self.assertEquals(4, len(messages), "Did not receive the expected number of messages") diff --git a/python/samba/tests/blackbox/ndrdump.py b/python/samba/tests/blackbox/ndrdump.py index f0cd5f750ec..fe3044a7159 100644 --- a/python/samba/tests/blackbox/ndrdump.py +++ b/python/samba/tests/blackbox/ndrdump.py @@ -25,7 +25,7 @@ for p in [ "../../../../../source4/librpc/tests", "../../../../../librpc/tests"]: data_path_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), p)) - print data_path_dir + print(data_path_dir) if os.path.exists(data_path_dir): break diff --git a/python/samba/tests/dcerpc/dnsserver.py b/python/samba/tests/dcerpc/dnsserver.py index 349349428cb..9d59647bfca 100644 --- a/python/samba/tests/dcerpc/dnsserver.py +++ b/python/samba/tests/dcerpc/dnsserver.py @@ -337,7 +337,7 @@ def test_reject_invalid_commands(self): self.assert_num_records(self.custom_zone, "testrecord", record_type_str, expected_num=0) self.delete_record(self.custom_zone, "testrecord", record_type_str, record_str, assertion=False) except AssertionError as e: - print e + print(e) num_failures = num_failures + 1 # Also try to update valid records to invalid ones, making sure this fails @@ -348,7 +348,7 @@ def test_reject_invalid_commands(self): try: self.add_record(self.custom_zone, "testrecord", record_type_str, record_str, assertion=False) except AssertionError as e: - print e + print(e) num_failures = num_failures + 1 self.delete_record(self.custom_zone, "testrecord", record_type_str, good_record_str) diff --git a/python/samba/tests/dcerpc/testrpc.py b/python/samba/tests/dcerpc/testrpc.py index fc3abf93395..b9f7e6b1d5c 100644 --- a/python/samba/tests/dcerpc/testrpc.py +++ b/python/samba/tests/dcerpc/testrpc.py @@ -35,10 +35,10 @@ def check_blocks(self, object, num_expected): nblocks -= self.initial_blocks leaked_blocks = (nblocks - num_expected) if leaked_blocks != 0: - print "Leaked %d blocks" % leaked_blocks + print("Leaked %d blocks" % leaked_blocks) def check_type(self, interface, typename, type): - print "Checking type %s" % typename + print("Checking type %s" % typename) v = type() for n in dir(v): if n[0] == '_': @@ -47,43 +47,43 @@ def check_type(self, interface, typename, type): value = getattr(v, n) except TypeError as errstr: if str(errstr) == "unknown union level": - print "ERROR: Unknown union level in %s.%s" % (typename, n) + print("ERROR: Unknown union level in %s.%s" % (typename, n)) self.errcount += 1 continue - print str(errstr)[1:21] + print(str(errstr)[1:21]) if str(errstr)[0:21] == "Can not convert C Type": - print "ERROR: Unknown C type for %s.%s" % (typename, n) + print("ERROR: Unknown C type for %s.%s" % (typename, n)) self.errcount += 1 continue else: - print "ERROR: Failed to instantiate %s.%s" % (typename, n) + print("ERROR: Failed to instantiate %s.%s" % (typename, n)) self.errcount += 1 continue except Exception: - print "ERROR: Failed to instantiate %s.%s" % (typename, n) + print("ERROR: Failed to instantiate %s.%s" % (typename, n)) self.errcount += 1 continue # now try setting the value back try: - print "Setting %s.%s" % (typename, n) + print("Setting %s.%s" % (typename, n)) setattr(v, n, value) except Exception as e: if isinstance(e, AttributeError) and str(e).endswith("is read-only"): # readonly, ignore continue else: - print "ERROR: Failed to set %s.%s: %r: %s" % (typename, n, e.__class__, e) + print("ERROR: Failed to set %s.%s: %r: %s" % (typename, n, e.__class__, e)) self.errcount += 1 continue # and try a comparison try: if value != getattr(v, n): - print "ERROR: Comparison failed for %s.%s: %r != %r" % (typename, n, value, getattr(v, n)) + print("ERROR: Comparison failed for %s.%s: %r != %r" % (typename, n, value, getattr(v, n))) continue except Exception as e: - print "ERROR: compare exception for %s.%s: %r: %s" % (typename, n, e.__class__, e) + print("ERROR: compare exception for %s.%s: %r: %s" % (typename, n, e.__class__, e)) continue def check_interface(self, interface, iname): @@ -105,14 +105,14 @@ def check_interface(self, interface, iname): self.check_type(interface, n, value) self.check_blocks(None, initial_blocks) except Exception as e: - print "ERROR: Failed to check_type %s.%s: %r: %s" % (iname, n, e.__class__, e) + print("ERROR: Failed to check_type %s.%s: %r: %s" % (iname, n, e.__class__, e)) self.errcount += 1 elif callable(value): pass # Method else: - print "UNKNOWN: %s=%s" % (n, value) + print("UNKNOWN: %s=%s" % (n, value)) if self.errcount - errcount != 0: - print "Found %d errors in %s" % (self.errcount - errcount, iname) + print("Found %d errors in %s" % (self.errcount - errcount, iname)) def check_all_interfaces(self): for iname in dir(samba.dcerpc): @@ -120,7 +120,7 @@ def check_all_interfaces(self): continue if iname == 'ClientConnection' or iname == 'base': continue - print "Checking interface %s" % iname + print("Checking interface %s" % iname) iface = getattr(samba.dcerpc, iname) initial_blocks = talloc.total_blocks(None) self.check_interface(iface, iname) @@ -137,5 +137,5 @@ def run(self): if errcount == 0: sys.exit(0) else: - print "%d failures" % errcount + print("%d failures" % errcount) sys.exit(1) diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py index 8aecfe3be59..8d9835bab88 100644 --- a/python/samba/tests/dns.py +++ b/python/samba/tests/dns.py @@ -77,7 +77,7 @@ def test_one_a_query(self): name = "%s.%s" % (self.server, self.get_dns_domain()) q = self.make_name_question(name, dns.DNS_QTYPE_A, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) @@ -95,7 +95,7 @@ def test_one_SOA_query(self): name = "%s" % (self.get_dns_domain()) q = self.make_name_question(name, dns.DNS_QTYPE_SOA, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) @@ -113,7 +113,7 @@ def test_one_a_query_tcp(self): name = "%s.%s" % (self.server, self.get_dns_domain()) q = self.make_name_question(name, dns.DNS_QTYPE_A, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) @@ -131,7 +131,7 @@ def test_one_mx_query(self): name = "%s.%s" % (self.server, self.get_dns_domain()) q = self.make_name_question(name, dns.DNS_QTYPE_MX, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) @@ -145,7 +145,7 @@ def test_one_mx_query(self): name = "invalid-%s.%s" % (self.server, self.get_dns_domain()) q = self.make_name_question(name, dns.DNS_QTYPE_MX, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) @@ -185,7 +185,7 @@ def test_qtype_all_query(self): name = "%s.%s" % (self.server, self.get_dns_domain()) q = self.make_name_question(name, dns.DNS_QTYPE_ALL, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) @@ -685,7 +685,7 @@ def test_one_a_query(self): # Check the record name = "cname_test.%s" % self.get_dns_domain() q = self.make_name_question(name, dns.DNS_QTYPE_A, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) @@ -825,7 +825,7 @@ def test_one_a_query(self): name = "%s.%s" % (self.server, self.get_dns_domain()) q = self.make_name_question(name, dns.DNS_QTYPE_A, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) @@ -845,7 +845,7 @@ def test_one_a_reply(self): name = "%s.%s" % ('fakefakefake', self.get_dns_domain()) q = self.make_name_question(name, dns.DNS_QTYPE_A, dns.DNS_QCLASS_IN) - print "asking for ", q.name + print("asking for ", q.name) questions.append(q) self.finish_name_packet(p, questions) diff --git a/python/samba/tests/dns_base.py b/python/samba/tests/dns_base.py index 2a40d999c36..ad52c880753 100644 --- a/python/samba/tests/dns_base.py +++ b/python/samba/tests/dns_base.py @@ -119,14 +119,14 @@ def dns_transaction_udp(self, packet, host, try: send_packet = ndr.ndr_pack(packet) if dump: - print self.hexdump(send_packet) + print(self.hexdump(send_packet)) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) s.settimeout(timeout) s.connect((host, 53)) s.sendall(send_packet, 0) recv_packet = s.recv(2048, 0) if dump: - print self.hexdump(recv_packet) + print(self.hexdump(recv_packet)) response = ndr.ndr_unpack(dns.name_packet, recv_packet) return (response, recv_packet) finally: @@ -142,7 +142,7 @@ def dns_transaction_tcp(self, packet, host, try: send_packet = ndr.ndr_pack(packet) if dump: - print self.hexdump(send_packet) + print(self.hexdump(send_packet)) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) s.settimeout(timeout) s.connect((host, 53)) @@ -152,7 +152,7 @@ def dns_transaction_tcp(self, packet, host, recv_packet = s.recv(0xffff + 2, 0) if dump: - print self.hexdump(recv_packet) + print(self.hexdump(recv_packet)) response = ndr.ndr_unpack(dns.name_packet, recv_packet[2:]) finally: diff --git a/python/samba/tests/dns_forwarder.py b/python/samba/tests/dns_forwarder.py index cf9f537e461..3d46be89658 100644 --- a/python/samba/tests/dns_forwarder.py +++ b/python/samba/tests/dns_forwarder.py @@ -123,14 +123,14 @@ def dns_transaction_udp(self, packet, host=server_ip, try: send_packet = ndr.ndr_pack(packet) if dump: - print self.hexdump(send_packet) + print(self.hexdump(send_packet)) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) s.settimeout(timeout) s.connect((host, 53)) s.send(send_packet, 0) recv_packet = s.recv(2048, 0) if dump: - print self.hexdump(recv_packet) + print(self.hexdump(recv_packet)) return ndr.ndr_unpack(dns.name_packet, recv_packet) finally: if s is not None: @@ -358,7 +358,7 @@ def test_single_forwarder_waiting_forever(self): def test_double_forwarder_first_frozen(self): if len(dns_servers) < 2: - print "Ignoring test_double_forwarder_first_frozen" + print("Ignoring test_double_forwarder_first_frozen") return s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1') s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2') @@ -388,7 +388,7 @@ def test_double_forwarder_first_frozen(self): def test_double_forwarder_first_down(self): if len(dns_servers) < 2: - print "Ignoring test_double_forwarder_first_down" + print("Ignoring test_double_forwarder_first_down") return s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2') ad = contact_real_server(server_ip, 53) @@ -416,7 +416,7 @@ def test_double_forwarder_first_down(self): def test_double_forwarder_both_slow(self): if len(dns_servers) < 2: - print "Ignoring test_double_forwarder_both_slow" + print("Ignoring test_double_forwarder_both_slow") return s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1') s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2') @@ -502,7 +502,7 @@ def test_double_cname(self): def test_cname_forwarding_with_slow_server(self): if len(dns_servers) < 2: - print "Ignoring test_cname_forwarding_with_slow_server" + print("Ignoring test_cname_forwarding_with_slow_server") return s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1') s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2') @@ -535,7 +535,7 @@ def test_cname_forwarding_with_slow_server(self): def test_cname_forwarding_with_server_down(self): if len(dns_servers) < 2: - print "Ignoring test_cname_forwarding_with_server_down" + print("Ignoring test_cname_forwarding_with_server_down") return s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2') diff --git a/python/samba/tests/dns_forwarder_helpers/server.py b/python/samba/tests/dns_forwarder_helpers/server.py index e302485ea1b..ddb7b5f9572 100644 --- a/python/samba/tests/dns_forwarder_helpers/server.py +++ b/python/samba/tests/dns_forwarder_helpers/server.py @@ -31,7 +31,7 @@ def debug(msg): if VERBOSE: sys.stdout.flush() - print "\033[00;36m%s\033[00m" % msg + print("\033[00;36m%s\033[00m" % msg) sys.stdout.flush() timeout = 0 diff --git a/python/samba/tests/samba3sam.py b/python/samba/tests/samba3sam.py index bfc7932689f..67d76d3173a 100644 --- a/python/samba/tests/samba3sam.py +++ b/python/samba/tests/samba3sam.py @@ -41,7 +41,7 @@ def read_datafile(filename): return open(os.path.join(datadir, filename), 'r').read() def ldb_debug(l, text): - print text + print(text) class MapBaseTestCase(TestCaseInTempDir): From 5d947a9eef8b8bcbebc0cd423993a0ba6a06a901 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 13:49:09 +0000 Subject: [PATCH 02/14] samba-tool: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- python/samba/netcmd/domain.py | 4 ++-- python/samba/netcmd/sites.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py index d3b9b0ccf6f..2a2f8627fb9 100644 --- a/python/samba/netcmd/domain.py +++ b/python/samba/netcmd/domain.py @@ -354,9 +354,9 @@ def run(self, sambaopts=None, versionopts=None, def ask(prompt, default=None): if default is not None: - print "%s [%s]: " % (prompt, default), + print("%s [%s]: " % (prompt, default), end=' ') else: - print "%s: " % (prompt,), + print("%s: " % (prompt,), end=' ') return sys.stdin.readline().rstrip("\n") or default try: diff --git a/python/samba/netcmd/sites.py b/python/samba/netcmd/sites.py index 38b251ca8fe..e9d47ce88c8 100644 --- a/python/samba/netcmd/sites.py +++ b/python/samba/netcmd/sites.py @@ -208,8 +208,8 @@ def run(self, subnetname, site_of_subnet, H=None, sambaopts=None, raise CommandError("Error assigning subnet %s to site %s: %s" % (subnetname, site_of_subnet, e)) - print >> self.outf, ("Subnet %s shifted to site %s" % - (subnetname, site_of_subnet)) + print(("Subnet %s shifted to site %s" % + (subnetname, site_of_subnet)), file=self.outf) class cmd_sites_subnet(SuperCommand): From 0f1b1499083ca81dc2dfaa58226a2f254327c746 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 13:53:45 +0000 Subject: [PATCH 03/14] samba python libs: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- python/samba/common.py | 4 +- python/samba/dbchecker.py | 2 +- python/samba/emulate/traffic.py | 101 ++++++++++++++--------------- python/samba/forest_update.py | 2 +- python/samba/getopt.py | 2 +- python/samba/join.py | 52 +++++++-------- python/samba/kcc/graph_utils.py | 6 +- python/samba/ms_display_specifiers.py | 6 +- python/samba/ms_forest_updates_markdown.py | 2 +- python/samba/ms_schema.py | 6 +- python/samba/ms_schema_markdown.py | 2 +- python/samba/ntacls.py | 4 +- python/samba/upgradehelpers.py | 14 ++-- python/samba/web_server/__init__.py | 4 +- 14 files changed, 103 insertions(+), 104 deletions(-) diff --git a/python/samba/common.py b/python/samba/common.py index 1c410a4702d..aa77c1a1f99 100644 --- a/python/samba/common.py +++ b/python/samba/common.py @@ -31,7 +31,7 @@ def confirm(msg, forced=False, allow_all=False): :param forced: Are the answer forced """ if forced: - print("%s [YES]" % msg) + print(("%s [YES]" % msg)) return True mapping = { @@ -54,7 +54,7 @@ def confirm(msg, forced=False, allow_all=False): v = v.upper() if v in mapping: return mapping[v] - print("Unknown response '%s'" % v) + print(("Unknown response '%s'" % v)) def normalise_int32(ivalue): diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py index d4d7e4ead44..613b952427c 100644 --- a/python/samba/dbchecker.py +++ b/python/samba/dbchecker.py @@ -1759,7 +1759,7 @@ def err_replmetadata_incorrect_attid(self, dn, attr, repl_meta_data, wrong_attid # the correct values are above 0x80000000) values first and # remove the 'second' value we see. for o in reversed(ctr.array): - print "%s: 0x%08x" % (dn, o.attid) + print("%s: 0x%08x" % (dn, o.attid)) att = self.samdb_schema.get_lDAPDisplayName_by_attid(o.attid) if att.lower() in set_att: self.report('ERROR: duplicate attributeID values for %s in %s on %s\n' % (att, attr, dn)) diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py index f6cc03063c1..d18458c7afd 100644 --- a/python/samba/emulate/traffic.py +++ b/python/samba/emulate/traffic.py @@ -96,20 +96,20 @@ def debug(level, msg, *args): """ if level <= DEBUG_LEVEL: if not args: - print >> sys.stderr, msg + print(msg, file=sys.stderr) else: - print >> sys.stderr, msg % tuple(args) + print(msg % tuple(args), file=sys.stderr) def debug_lineno(*args): """ Print an unformatted log message to stderr, contaning the line number """ tb = traceback.extract_stack(limit=2) - print >> sys.stderr, (" %s:" "\033[01;33m" - "%s " "\033[00m" % (tb[0][2], tb[0][1])), + print((" %s:" "\033[01;33m" + "%s " "\033[00m" % (tb[0][2], tb[0][1])), end=' ', file=sys.stderr) for a in args: - print >> sys.stderr, a - print >> sys.stderr + print(a, file=sys.stderr) + print(file=sys.stderr) sys.stderr.flush() @@ -120,7 +120,7 @@ def random_colour_print(): def p(*args): for a in args: - print >>sys.stderr, "%s%s\033[00m" % (prefix, a) + print("%s%s\033[00m" % (prefix, a), file=sys.stderr) return p @@ -225,8 +225,8 @@ def play(self, conversation, context): fn = getattr(traffic_packets, fn_name) except AttributeError as e: - print >>sys.stderr, "Conversation(%s) Missing handler %s" % \ - (conversation.conversation_id, fn_name) + print("Conversation(%s) Missing handler %s" % \ + (conversation.conversation_id, fn_name), file=sys.stderr) return # Don't display a message for kerberos packets, they're not directly @@ -273,7 +273,7 @@ def is_really_a_packet(self, missing_packet_stats=None): if fn is traffic_packets.null_packet: return False except AttributeError: - print >>sys.stderr, "missing packet %s" % fn_name + print("missing packet %s" % fn_name, file=sys.stderr) return False return True @@ -370,7 +370,7 @@ def generate_ldap_search_tables(self): for i in range(5): p += ',DC' if p != k and p in dn_map: - print >> sys.stderr, 'dn_map collison %s %s' % (k, p) + print('dn_map collison %s %s' % (k, p), file=sys.stderr) continue dn_map[p] = dn_map[k] @@ -841,11 +841,11 @@ def signal_handler(signal, frame): # the number of concurrent threads, which allows us to make # larger loads. if gap > 0.15 and False: - print >>sys.stderr, "sleeping for %f in main process" % (gap - 0.1) + print("sleeping for %f in main process" % (gap - 0.1), file=sys.stderr) time.sleep(gap - 0.1) now = time.time() - start gap = t - now - print >>sys.stderr, "gap is now %f" % gap + print("gap is now %f" % gap, file=sys.stderr) self.conversation_id = context.next_conversation_id() pid = os.fork() @@ -874,8 +874,7 @@ def signal_handler(signal, frame): self.msg("starting %s [miss %.3f pid %d]" % (self, miss, pid)) self.replay(context) except Exception: - print >>sys.stderr,\ - ("EXCEPTION in child PID %d, conversation %s" % (pid, self)) + print(("EXCEPTION in child PID %d, conversation %s" % (pid, self)), file=sys.stderr) traceback.print_exc(sys.stderr) finally: sys.stderr.close() @@ -1004,7 +1003,7 @@ def ingest_summaries(files, dns_mode='count'): for f in files: if isinstance(f, str): f = open(f) - print >>sys.stderr, "Ingesting %s" % (f.name,) + print("Ingesting %s" % (f.name,), file=sys.stderr) for line in f: p = Packet(line) if p.protocol == 'dns' and dns_mode != 'include': @@ -1020,7 +1019,7 @@ def ingest_summaries(files, dns_mode='count'): start_time = min(p.timestamp for p in packets) last_packet = max(p.timestamp for p in packets) - print >>sys.stderr, "gathering packets into conversations" + print("gathering packets into conversations", file=sys.stderr) conversations = OrderedDict() for p in packets: p.timestamp -= start_time @@ -1241,8 +1240,8 @@ def generate_conversations(self, rate, duration, packet_rate=1): conversations.append(c) client += 1 - print >> sys.stderr, ("we have %d conversations at rate %f" % - (len(conversations), rate)) + print(("we have %d conversations at rate %f" % + (len(conversations), rate)), file=sys.stderr) conversations.sort() return conversations @@ -1389,8 +1388,8 @@ def replay(conversations, **kwargs) if len(accounts) < len(conversations): - print >> sys.stderr, ("we have %d accounts but %d conversations" % - (accounts, conversations)) + print(("we have %d accounts but %d conversations" % + (accounts, conversations)), file=sys.stderr) cstack = zip(sorted(conversations, key=lambda x: x.start_time, reverse=True), @@ -1407,7 +1406,7 @@ def replay(conversations, # to start. Conversations other than the last could still be # going, but we don't care. duration = cstack[0][0].packets[-1].timestamp + 1.0 - print >>sys.stderr, "We will stop after %.1f seconds" % duration + print("We will stop after %.1f seconds" % duration, file=sys.stderr) end = start + duration @@ -1439,12 +1438,12 @@ def replay(conversations, elapsed = t - st fork_time += elapsed fork_n += 1 - print >>sys.stderr, "forked %s in pid %s (in %fs)" % (c, pid, - elapsed) + print("forked %s in pid %s (in %fs)" % (c, pid, + elapsed), file=sys.stderr) if fork_n: - print >>sys.stderr, ("forked %d times in %f seconds (avg %f)" % - (fork_n, fork_time, fork_time / fork_n)) + print(("forked %d times in %f seconds (avg %f)" % + (fork_n, fork_time, fork_time / fork_n)), file=sys.stderr) elif cstack: debug(2, "no forks in batch ending %f" % batch_end) @@ -1458,21 +1457,21 @@ def replay(conversations, break if pid: c = children.pop(pid, None) - print >>sys.stderr, ("process %d finished conversation %s;" + print(("process %d finished conversation %s;" " %d to go" % - (pid, c, len(children))) + (pid, c, len(children))), file=sys.stderr) if time.time() >= end: - print >>sys.stderr, "time to stop" + print("time to stop", file=sys.stderr) break except Exception: - print >>sys.stderr, "EXCEPTION in parent" + print("EXCEPTION in parent", file=sys.stderr) traceback.print_exc() finally: for s in (15, 15, 9): - print >>sys.stderr, ("killing %d children with -%d" % - (len(children), s)) + print(("killing %d children with -%d" % + (len(children), s)), file=sys.stderr) for pid in children: try: os.kill(pid, s) @@ -1489,9 +1488,9 @@ def replay(conversations, raise if pid != 0: c = children.pop(pid, None) - print >>sys.stderr, ("kill -%d %d KILLED conversation %s; " + print(("kill -%d %d KILLED conversation %s; " "%d to go" % - (s, pid, c, len(children))) + (s, pid, c, len(children))), file=sys.stderr) if time.time() >= end: break @@ -1500,7 +1499,7 @@ def replay(conversations, time.sleep(1) if children: - print >>sys.stderr, "%d children are missing" % len(children) + print("%d children are missing" % len(children), file=sys.stderr) # there may be stragglers that were forked just as ^C was hit # and don't appear in the list of children. We can get them @@ -1510,7 +1509,7 @@ def replay(conversations, try: os.killpg(0, 2) except KeyboardInterrupt: - print >>sys.stderr, "ignoring fake ^C" + print("ignoring fake ^C", file=sys.stderr) def openLdb(host, creds, lp): @@ -1586,8 +1585,8 @@ def generate_traffic_accounts(ldb, instance_id, number, password): finds an already existing account or it has generated all the required accounts. """ - print >>sys.stderr, ("Generating machine and conversation accounts, " - "as required for %d conversations" % number) + print(("Generating machine and conversation accounts, " + "as required for %d conversations" % number), file=sys.stderr) added = 0 for i in range(number, 0, -1): try: @@ -1601,7 +1600,7 @@ def generate_traffic_accounts(ldb, instance_id, number, password): else: raise if added > 0: - print >>sys.stderr, "Added %d new machine accounts" % added + print("Added %d new machine accounts" % added, file=sys.stderr) added = 0 for i in range(number, 0, -1): @@ -1617,7 +1616,7 @@ def generate_traffic_accounts(ldb, instance_id, number, password): raise if added > 0: - print >>sys.stderr, "Added %d new user accounts" % added + print("Added %d new user accounts" % added, file=sys.stderr) def create_machine_account(ldb, instance_id, netbios_name, machinepass): @@ -1638,7 +1637,7 @@ def create_machine_account(ldb, instance_id, netbios_name, machinepass): "unicodePwd": utf16pw}) end = time.time() duration = end - start - print("%f\t0\tcreate\tmachine\t%f\tTrue\t" % (end, duration)) + print(("%f\t0\tcreate\tmachine\t%f\tTrue\t" % (end, duration))) def create_user_account(ldb, instance_id, username, userpass): @@ -1658,7 +1657,7 @@ def create_user_account(ldb, instance_id, username, userpass): }) end = time.time() duration = end - start - print("%f\t0\tcreate\tuser\t%f\tTrue\t" % (end, duration)) + print(("%f\t0\tcreate\tuser\t%f\tTrue\t" % (end, duration))) def create_group(ldb, instance_id, name): @@ -1673,7 +1672,7 @@ def create_group(ldb, instance_id, name): }) end = time.time() duration = end - start - print("%f\t0\tcreate\tgroup\t%f\tTrue\t" % (end, duration)) + print(("%f\t0\tcreate\tgroup\t%f\tTrue\t" % (end, duration))) def user_name(instance_id, i): @@ -1745,29 +1744,29 @@ def generate_users_and_groups(ldb, instance_id, password, create_ou(ldb, instance_id) - print >>sys.stderr, "Generating dummy user accounts" + print("Generating dummy user accounts", file=sys.stderr) users_added = generate_users(ldb, instance_id, number_of_users, password) if number_of_groups > 0: - print >>sys.stderr, "Generating dummy groups" + print("Generating dummy groups", file=sys.stderr) groups_added = generate_groups(ldb, instance_id, number_of_groups) if group_memberships > 0: - print >>sys.stderr, "Assigning users to groups" + print("Assigning users to groups", file=sys.stderr) assignments = assign_groups(number_of_groups, groups_added, number_of_users, users_added, group_memberships) - print >>sys.stderr, "Adding users to groups" + print("Adding users to groups", file=sys.stderr) add_users_to_groups(ldb, instance_id, assignments) if (groups_added > 0 and users_added == 0 and number_of_groups != groups_added): - print >>sys.stderr, "Warning: the added groups will contain no members" + print("Warning: the added groups will contain no members", file=sys.stderr) - print >>sys.stderr, ("Added %d users, %d groups and %d group memberships" % - (users_added, groups_added, len(assignments))) + print(("Added %d users, %d groups and %d group memberships" % + (users_added, groups_added, len(assignments))), file=sys.stderr) def assign_groups(number_of_groups, @@ -1911,7 +1910,7 @@ def tw(x): tw(line) except (ValueError, IndexError): # not a valid line print and ignore - print >>sys.stderr, line + print(line, file=sys.stderr) pass duration = last - first if successful == 0: diff --git a/python/samba/forest_update.py b/python/samba/forest_update.py index ba6f859a943..7e2a05cce8e 100644 --- a/python/samba/forest_update.py +++ b/python/samba/forest_update.py @@ -300,7 +300,7 @@ def operation_ldif(self, op): "SCHEMA_DN": str(self.schema_dn)}) if self.verbose: - print("UPDATE (LDIF) ------ OPERATION %d" % op) + print(("UPDATE (LDIF) ------ OPERATION %d" % op)) print(sub_ldif) self.samdb.modify_ldif(sub_ldif) diff --git a/python/samba/getopt.py b/python/samba/getopt.py index b33a5c07ba4..199ab5f5be0 100644 --- a/python/samba/getopt.py +++ b/python/samba/getopt.py @@ -103,7 +103,7 @@ def __init__(self, parser): def _display_version(self, option, opt_str, arg, parser): import samba - print(samba.version) + print((samba.version)) sys.exit(0) diff --git a/python/samba/join.py b/python/samba/join.py index 22deff0d6a7..ee35df10791 100644 --- a/python/samba/join.py +++ b/python/samba/join.py @@ -167,7 +167,7 @@ def __init__(ctx, logger=None, server=None, creds=None, lp=None, site=None, else: if len(res_domaindns) == 0: ctx.dns_backend = "NONE" - print "NO DNS zone information found in source domain, not replicating DNS" + print("NO DNS zone information found in source domain, not replicating DNS") else: ctx.dns_backend = dns_backend @@ -209,7 +209,7 @@ def del_noerror(ctx, dn, recursive=False): ctx.del_noerror(r.dn, recursive=True) try: ctx.samdb.delete(dn) - print "Deleted %s" % dn + print("Deleted %s" % dn) except Exception: pass @@ -414,7 +414,7 @@ def dn_exists(ctx, dn): def add_krbtgt_account(ctx): '''RODCs need a special krbtgt account''' - print "Adding %s" % ctx.krbtgt_dn + print("Adding %s" % ctx.krbtgt_dn) rec = { "dn" : ctx.krbtgt_dn, "objectclass" : "user", @@ -429,7 +429,7 @@ def add_krbtgt_account(ctx): res = ctx.samdb.search(base=ctx.krbtgt_dn, scope=ldb.SCOPE_BASE, attrs=["samAccountName"]) ctx.krbtgt_name = res[0]["samAccountName"][0] - print "Got krbtgt_name=%s" % ctx.krbtgt_name + print("Got krbtgt_name=%s" % ctx.krbtgt_name) m = ldb.Message() m.dn = ldb.Dn(ctx.samdb, ctx.acct_dn) @@ -438,7 +438,7 @@ def add_krbtgt_account(ctx): ctx.samdb.modify(m) ctx.new_krbtgt_dn = "CN=%s,CN=Users,%s" % (ctx.krbtgt_name, ctx.base_dn) - print "Renaming %s to %s" % (ctx.krbtgt_dn, ctx.new_krbtgt_dn) + print("Renaming %s to %s" % (ctx.krbtgt_dn, ctx.new_krbtgt_dn)) ctx.samdb.rename(ctx.krbtgt_dn, ctx.new_krbtgt_dn) def drsuapi_connect(ctx): @@ -535,7 +535,7 @@ def DsAddEntry(ctx, recs): def join_ntdsdsa_obj(ctx): '''return the ntdsdsa object to add''' - print "Adding %s" % ctx.ntds_dn + print("Adding %s" % ctx.ntds_dn) rec = { "dn" : ctx.ntds_dn, "objectclass" : "nTDSDSA", @@ -583,7 +583,7 @@ def join_add_ntdsdsa(ctx): def join_add_objects(ctx): '''add the various objects needed for the join''' if ctx.acct_dn: - print "Adding %s" % ctx.acct_dn + print("Adding %s" % ctx.acct_dn) rec = { "dn" : ctx.acct_dn, "objectClass": "computer", @@ -621,7 +621,7 @@ def join_add_objects(ctx): ctx.add_krbtgt_account() if ctx.server_dn: - print "Adding %s" % ctx.server_dn + print("Adding %s" % ctx.server_dn) rec = { "dn": ctx.server_dn, "objectclass" : "server", @@ -675,7 +675,7 @@ def join_add_objects(ctx): ctx.samdb.modify(m) if ctx.connection_dn is not None: - print "Adding %s" % ctx.connection_dn + print("Adding %s" % ctx.connection_dn) rec = { "dn" : ctx.connection_dn, "objectclass" : "nTDSConnection", @@ -685,7 +685,7 @@ def join_add_objects(ctx): ctx.samdb.add(rec) if ctx.acct_dn: - print "Adding SPNs to %s" % ctx.acct_dn + print("Adding SPNs to %s" % ctx.acct_dn) m = ldb.Message() m.dn = ldb.Dn(ctx.samdb, ctx.acct_dn) for i in range(len(ctx.SPNs)): @@ -700,7 +700,7 @@ def join_add_objects(ctx): # connections which are hard to set up and otherwise refuse with # ERR_UNWILLING_TO_PERFORM. In this case we fall back to libnet # over SAMR. - print "Setting account password for %s" % ctx.samname + print("Setting account password for %s" % ctx.samname) try: ctx.samdb.setpassword("(&(objectClass=user)(sAMAccountName=%s))" % ldb.binary_encode(ctx.samname), @@ -746,7 +746,7 @@ def join_add_objects(ctx): for changetype, msg in recs: assert changetype == ldb.CHANGETYPE_NONE dns_acct_dn = msg["dn"] - print "Adding DNS account %s with dns/ SPN" % msg["dn"] + print("Adding DNS account %s with dns/ SPN" % msg["dn"]) # Remove dns password (we will set it as a modify, as we can't do clearTextPassword over LDAP) del msg["clearTextPassword"] @@ -767,7 +767,7 @@ def join_add_objects(ctx): # connections which are hard to set up and otherwise refuse with # ERR_UNWILLING_TO_PERFORM. In this case we fall back to libnet # over SAMR. - print "Setting account password for dns-%s" % ctx.myname + print("Setting account password for dns-%s" % ctx.myname) try: ctx.samdb.setpassword("(&(objectClass=user)(samAccountName=dns-%s))" % ldb.binary_encode(ctx.myname), @@ -792,7 +792,7 @@ def join_add_objects(ctx): def join_add_objects2(ctx): """add the various objects needed for the join, for subdomains post replication""" - print "Adding %s" % ctx.partition_dn + print("Adding %s" % ctx.partition_dn) name_map = {'SubdomainAdmins': "%s-%s" % (str(ctx.domsid), security.DOMAIN_RID_ADMINS)} sd_binary = descriptor.get_paritions_crossref_subdomain_descriptor(ctx.forestsid, name_map=name_map) rec = { @@ -835,7 +835,7 @@ def join_add_objects2(ctx): def join_provision(ctx): """Provision the local SAM.""" - print "Calling bare provision" + print("Calling bare provision") smbconf = ctx.lp.configfile @@ -849,7 +849,7 @@ def join_provision(ctx): sitename=ctx.site, lp=ctx.lp, ntdsguid=ctx.ntds_guid, use_ntvfs=ctx.use_ntvfs, dns_backend=ctx.dns_backend, plaintext_secrets=ctx.plaintext_secrets) - print "Provision OK for domain DN %s" % presult.domaindn + print("Provision OK for domain DN %s" % presult.domaindn) ctx.local_samdb = presult.samdb ctx.lp = presult.lp ctx.paths = presult.paths @@ -901,7 +901,7 @@ def join_provision_own_domain(ctx): def join_replicate(ctx): """Replicate the SAM.""" - print "Starting replication" + print("Starting replication") ctx.local_samdb.transaction_start() try: source_dsa_invocation_id = misc.GUID(ctx.samdb.get_invocation_id()) @@ -936,7 +936,7 @@ def join_replicate(ctx): if not ctx.subdomain: # Replicate first the critical object for the basedn if not ctx.domain_replica_flags & drsuapi.DRSUAPI_DRS_CRITICAL_ONLY: - print "Replicating critical objects from the base DN of the domain" + print("Replicating critical objects from the base DN of the domain") ctx.domain_replica_flags |= drsuapi.DRSUAPI_DRS_CRITICAL_ONLY repl.replicate(ctx.base_dn, source_dsa_invocation_id, destination_dsa_guid, rodc=ctx.RODC, @@ -945,14 +945,14 @@ def join_replicate(ctx): repl.replicate(ctx.base_dn, source_dsa_invocation_id, destination_dsa_guid, rodc=ctx.RODC, replica_flags=ctx.domain_replica_flags) - print "Done with always replicated NC (base, config, schema)" + print("Done with always replicated NC (base, config, schema)") # At this point we should already have an entry in the ForestDNS # and DomainDNS NC (those under CN=Partions,DC=...) in order to # indicate that we hold a replica for this NC. for nc in (ctx.domaindns_zone, ctx.forestdns_zone): if nc in ctx.nc_list: - print "Replicating %s" % (str(nc)) + print("Replicating %s" % (str(nc))) repl.replicate(nc, source_dsa_invocation_id, destination_dsa_guid, rodc=ctx.RODC, replica_flags=ctx.replica_flags) @@ -973,8 +973,8 @@ def join_replicate(ctx): except samba.DsExtendedError as e1: (enum, estr) = e1.args if enum == drsuapi.DRSUAPI_EXOP_ERR_FSMO_NOT_OWNER: - print "WARNING: Unable to replicate own RID Set, as server %s (the server we joined) is not the RID Master." % ctx.server - print "NOTE: This is normal and expected, Samba will be able to create users after it contacts the RID Master at first startup." + print("WARNING: Unable to replicate own RID Set, as server %s (the server we joined) is not the RID Master." % ctx.server) + print("NOTE: This is normal and expected, Samba will be able to create users after it contacts the RID Master at first startup.") else: raise @@ -982,7 +982,7 @@ def join_replicate(ctx): ctx.source_dsa_invocation_id = source_dsa_invocation_id ctx.destination_dsa_guid = destination_dsa_guid - print "Committing SAM database" + print("Committing SAM database") except: ctx.local_samdb.transaction_cancel() raise @@ -1190,7 +1190,7 @@ def join_finalise(ctx): ctx.send_DsReplicaUpdateRefs(nc) if not ctx.clone_only and ctx.RODC: - print "Setting RODC invocationId" + print("Setting RODC invocationId") ctx.local_samdb.set_invocation_id(str(ctx.invocation_id)) ctx.local_samdb.set_opaque_integer("domainFunctionality", ctx.behavior_version) @@ -1256,7 +1256,7 @@ def join_finalise(ctx): def join_setup_trusts(ctx): """provision the local SAM.""" - print "Setup domain trusts with server %s" % ctx.server + print("Setup domain trusts with server %s" % ctx.server) binding_options = "" # why doesn't signing work here? w2k8r2 claims no session key lsaconn = lsa.lsarpc("ncacn_np:%s[%s]" % (ctx.server, binding_options), ctx.lp, ctx.creds) @@ -1399,7 +1399,7 @@ def do_join(ctx): ctx.join_finalise() except: try: - print "Join failed - cleaning up" + print("Join failed - cleaning up") except IOError: pass if not ctx.clone_only: diff --git a/python/samba/kcc/graph_utils.py b/python/samba/kcc/graph_utils.py index a3b51092076..fbf661d0a9f 100644 --- a/python/samba/kcc/graph_utils.py +++ b/python/samba/kcc/graph_utils.py @@ -339,8 +339,8 @@ def verify_and_dot(basename, edges, vertices=None, label=None, def list_verify_tests(): for k, v in sorted(globals().items()): if k.startswith('verify_graph_'): - print k.replace('verify_graph_', '') + print(k.replace('verify_graph_', '')) if v.__doc__: - print ' %s%s%s' % (GREY, v.__doc__.rstrip(), C_NORMAL) + print(' %s%s%s' % (GREY, v.__doc__.rstrip(), C_NORMAL)) else: - print + print() diff --git a/python/samba/ms_display_specifiers.py b/python/samba/ms_display_specifiers.py index 44dfba07b39..96994cca344 100644 --- a/python/samba/ms_display_specifiers.py +++ b/python/samba/ms_display_specifiers.py @@ -81,7 +81,7 @@ def __read_raw_entries(f): entry.append(l) else: - print >>sys.stderr, "Invalid line: %s" % l, + print("Invalid line: %s" % l, end=' ', file=sys.stderr) sys.exit(1) if len(entry): @@ -180,8 +180,8 @@ def read_ms_ldif(filename): try: display_specifiers_file = sys.argv[1] except IndexError: - print >>sys.stderr, "Usage: %s display-specifiers-ldif-file.txt" % (sys.argv[0]) + print("Usage: %s display-specifiers-ldif-file.txt" % (sys.argv[0]), file=sys.stderr) sys.exit(1) - print read_ms_ldif(display_specifiers_file) + print(read_ms_ldif(display_specifiers_file)) diff --git a/python/samba/ms_forest_updates_markdown.py b/python/samba/ms_forest_updates_markdown.py index c4086b3e150..cdea25e29a8 100644 --- a/python/samba/ms_forest_updates_markdown.py +++ b/python/samba/ms_forest_updates_markdown.py @@ -264,7 +264,7 @@ def read_ms_markdown(in_file, out_folder=None, out_dict={}): out_folder = '' if len(sys.argv) == 0: - print >>sys.stderr, "Usage: %s []" % (sys.argv[0]) + print("Usage: %s []" % (sys.argv[0]), file=sys.stderr) sys.exit(1) in_file = sys.argv[1] diff --git a/python/samba/ms_schema.py b/python/samba/ms_schema.py index a8c936300bf..a9a01a6aae0 100644 --- a/python/samba/ms_schema.py +++ b/python/samba/ms_schema.py @@ -144,7 +144,7 @@ def __read_raw_entries(f): entry.append(l) else: - print >>sys.stderr, "Invalid line: %s" % l, + print("Invalid line: %s" % l, end=' ', file=sys.stderr) sys.exit(1) if len(entry): @@ -313,7 +313,7 @@ def read_ms_schema(attr_file, classes_file, dump_attributes = True, dump_classes attr_file = sys.argv[1] classes_file = sys.argv[2] except IndexError: - print >>sys.stderr, "Usage: %s attr-file.txt classes-file.txt" % (sys.argv[0]) + print("Usage: %s attr-file.txt classes-file.txt" % (sys.argv[0]), file=sys.stderr) sys.exit(1) - print read_ms_schema(attr_file, classes_file) + print(read_ms_schema(attr_file, classes_file)) diff --git a/python/samba/ms_schema_markdown.py b/python/samba/ms_schema_markdown.py index c695f8bd7f1..c2ecbe49415 100644 --- a/python/samba/ms_schema_markdown.py +++ b/python/samba/ms_schema_markdown.py @@ -61,7 +61,7 @@ def read_ms_markdown(in_file, out_folder): out_folder = '' if len(sys.argv) == 0: - print >>sys.stderr, "Usage: %s []" % (sys.argv[0]) + print("Usage: %s []" % (sys.argv[0]), file=sys.stderr) sys.exit(1) in_file = sys.argv[1] diff --git a/python/samba/ntacls.py b/python/samba/ntacls.py index 0eeb4977c12..13beb613828 100644 --- a/python/samba/ntacls.py +++ b/python/samba/ntacls.py @@ -73,7 +73,7 @@ def getntacl(lp, file, backend=None, eadbfile=None, direct_db_access=True, servi except Exception: # FIXME: Don't catch all exceptions, just those related to opening # xattrdb - print "Fail to open %s" % dbname + print("Fail to open %s" % dbname) attribute = samba.xattr_native.wrap_getxattr(file, xattr.XATTR_NTACL_NAME) else: @@ -152,7 +152,7 @@ def setntacl(lp, file, sddl, domsid, backend=None, eadbfile=None, use_ntvfs=True except Exception: # FIXME: Don't catch all exceptions, just those related to opening # xattrdb - print "Fail to open %s" % dbname + print("Fail to open %s" % dbname) samba.xattr_native.wrap_setxattr(file, xattr.XATTR_NTACL_NAME, ndr_pack(ntacl)) else: diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py index 9f017bce594..30e90dc253f 100644 --- a/python/samba/upgradehelpers.py +++ b/python/samba/upgradehelpers.py @@ -776,9 +776,9 @@ def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid): obj = hash_ts[k] if obj["num"] > limit_print: dt = _glue.nttime2string(_glue.unix2nttime(k*60)) - print "%s # of modification: %d \tmin: %d max: %d" % (dt , obj["num"], + print("%s # of modification: %d \tmin: %d max: %d" % (dt , obj["num"], obj["min"], - obj["max"]) + obj["max"])) if hash_ts[k]["num"] > 600: kept_record.append(k) @@ -803,11 +803,11 @@ def print_provision_ranges(dic, limit_print, dest, samdb_path, invocationid): if ldif != "": file = tempfile.mktemp(dir=dest, prefix="usnprov", suffix=".ldif") - print - 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() + 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)) ldif = "dn: @PROVISION\nprovisionnerID: %s\n%s" % (invocationid, ldif) open(file,'w').write(ldif) diff --git a/python/samba/web_server/__init__.py b/python/samba/web_server/__init__.py index 9fbd0ddfb9a..a2653bbc92a 100644 --- a/python/samba/web_server/__init__.py +++ b/python/samba/web_server/__init__.py @@ -48,7 +48,7 @@ def __call__(environ, start_response): try: import swat except ImportError as e: - print "NO SWAT: %r" % e + print("NO SWAT: %r" % e) have_swat = False else: have_swat = True @@ -75,5 +75,5 @@ def __call__(environ, start_response): if __name__ == '__main__': from wsgiref import simple_server httpd = simple_server.make_server('localhost', 8090, __call__) - print "Serving HTTP on port 8090..." + print("Serving HTTP on port 8090...") httpd.serve_forever() From 8ca137aa534fde69eee97fd249c876104ea616ec Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 13:57:01 +0000 Subject: [PATCH 04/14] s3/dsdb: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- .../samdb/ldb_modules/tests/possibleinferiors.py | 18 ++++---- source4/dsdb/tests/python/acl.py | 24 +++++----- .../dsdb/tests/python/ad_dc_medley_performance.py | 16 +++---- source4/dsdb/tests/python/ad_dc_performance.py | 8 ++-- .../dsdb/tests/python/ad_dc_search_performance.py | 14 +++--- source4/dsdb/tests/python/deletetest.py | 16 +++---- source4/dsdb/tests/python/dirsync.py | 16 +++---- source4/dsdb/tests/python/ldap.py | 4 +- source4/dsdb/tests/python/ldap_schema.py | 2 +- source4/dsdb/tests/python/linked_attributes.py | 14 +++--- source4/dsdb/tests/python/notification.py | 4 +- source4/dsdb/tests/python/password_lockout.py | 10 ++-- source4/dsdb/tests/python/password_lockout_base.py | 24 +++++----- source4/dsdb/tests/python/passwords.py | 6 +-- source4/dsdb/tests/python/rodc.py | 6 +-- source4/dsdb/tests/python/rodc_rwdc.py | 38 +++++++-------- source4/dsdb/tests/python/sam.py | 34 +++++++------- source4/dsdb/tests/python/sec_descriptor.py | 14 +++--- source4/dsdb/tests/python/sites.py | 16 +++---- source4/dsdb/tests/python/sort.py | 54 +++++++++++----------- source4/dsdb/tests/python/token_group.py | 8 ++-- source4/dsdb/tests/python/tombstone_reanimation.py | 24 +++++----- source4/dsdb/tests/python/urgent_replication.py | 4 +- source4/dsdb/tests/python/user_account_control.py | 2 +- source4/dsdb/tests/python/vlv.py | 26 +++++------ 25 files changed, 201 insertions(+), 201 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py b/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py index b1c4c2e2a33..411f7776b36 100755 --- a/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py +++ b/source4/dsdb/samdb/ldb_modules/tests/possibleinferiors.py @@ -222,20 +222,20 @@ def possible_inferiors_constructed(db, classinfo, c): def test_class(db, classinfo, oc): """test to see if one objectclass returns the correct possibleInferiors""" - print "test: objectClass.%s" % oc + print("test: objectClass.%s" % oc) poss1 = possible_inferiors_search(db, oc) poss2 = possible_inferiors_constructed(db, classinfo, oc) if poss1 != poss2: - print "failure: objectClass.%s [" % oc - print "Returned incorrect list for objectclass %s" % oc - print "search: %s" % poss1 - print "constructed: %s" % poss2 + print("failure: objectClass.%s [" % oc) + print("Returned incorrect list for objectclass %s" % oc) + print("search: %s" % poss1) + print("constructed: %s" % poss2) for i in range(0,min(len(poss1),len(poss2))): - print "%30s %30s" % (poss1[i], poss2[i]) - print "]" + print("%30s %30s" % (poss1[i], poss2[i])) + print("]") sys.exit(1) else: - print "success: objectClass.%s" % oc + print("success: objectClass.%s" % oc) def get_object_classes(db): """return a list of all object classes""" @@ -252,4 +252,4 @@ def get_object_classes(db): else: test_class(db,classinfo,objectclass) -print "Lists match OK" +print("Lists match OK") diff --git a/source4/dsdb/tests/python/acl.py b/source4/dsdb/tests/python/acl.py index fe118988353..ae29451b785 100755 --- a/source4/dsdb/tests/python/acl.py +++ b/source4/dsdb/tests/python/acl.py @@ -82,7 +82,7 @@ def setUp(self): self.creds_tmp.set_domain(creds.get_domain()) self.creds_tmp.set_realm(creds.get_realm()) self.creds_tmp.set_workstation(creds.get_workstation()) - print "baseDN: %s" % self.base_dn + print("baseDN: %s" % self.base_dn) def get_user_dn(self, name): return "CN=%s,CN=Users,%s" % (name, self.base_dn) @@ -307,7 +307,7 @@ def test_modify_u1(self): """5 Modify one attribute if you have DS_WRITE_PROPERTY for it""" mod = "(OA;;WP;bf967953-0de6-11d0-a285-00aa003049e2;;%s)" % str(self.user_sid) # First test object -- User - print "Testing modify on User object" + print("Testing modify on User object") self.ldb_admin.newuser("test_modify_user1", self.user_pass) self.sd_utils.dacl_add_ace(self.get_user_dn("test_modify_user1"), mod) ldif = """ @@ -320,7 +320,7 @@ def test_modify_u1(self): expression="(distinguishedName=%s)" % self.get_user_dn("test_modify_user1")) self.assertEqual(res[0]["displayName"][0], "test_changed") # Second test object -- Group - print "Testing modify on Group object" + print("Testing modify on Group object") self.ldb_admin.newgroup("test_modify_group1", grouptype=samba.dsdb.GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP) self.sd_utils.dacl_add_ace("CN=test_modify_group1,CN=Users," + self.base_dn, mod) @@ -333,7 +333,7 @@ def test_modify_u1(self): res = self.ldb_admin.search(self.base_dn, expression="(distinguishedName=%s)" % str("CN=test_modify_group1,CN=Users," + self.base_dn)) self.assertEqual(res[0]["displayName"][0], "test_changed") # Third test object -- Organizational Unit - print "Testing modify on OU object" + print("Testing modify on OU object") #delete_force(self.ldb_admin, "OU=test_modify_ou1," + self.base_dn) self.ldb_admin.create_ou("OU=test_modify_ou1," + self.base_dn) self.sd_utils.dacl_add_ace("OU=test_modify_ou1," + self.base_dn, mod) @@ -350,7 +350,7 @@ def test_modify_u2(self): """6 Modify two attributes as you have DS_WRITE_PROPERTY granted only for one of them""" mod = "(OA;;WP;bf967953-0de6-11d0-a285-00aa003049e2;;%s)" % str(self.user_sid) # First test object -- User - print "Testing modify on User object" + print("Testing modify on User object") #delete_force(self.ldb_admin, self.get_user_dn("test_modify_user1")) self.ldb_admin.newuser("test_modify_user1", self.user_pass) self.sd_utils.dacl_add_ace(self.get_user_dn("test_modify_user1"), mod) @@ -380,7 +380,7 @@ def test_modify_u2(self): # This 'modify' operation should always throw ERR_INSUFFICIENT_ACCESS_RIGHTS self.fail() # Second test object -- Group - print "Testing modify on Group object" + print("Testing modify on Group object") self.ldb_admin.newgroup("test_modify_group1", grouptype=samba.dsdb.GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP) self.sd_utils.dacl_add_ace("CN=test_modify_group1,CN=Users," + self.base_dn, mod) @@ -425,7 +425,7 @@ def test_modify_u2(self): # This 'modify' operation should always throw ERR_INSUFFICIENT_ACCESS_RIGHTS self.fail() # Second test object -- Organizational Unit - print "Testing modify on OU object" + print("Testing modify on OU object") self.ldb_admin.create_ou("OU=test_modify_ou1," + self.base_dn) self.sd_utils.dacl_add_ace("OU=test_modify_ou1," + self.base_dn, mod) ldif = """ @@ -456,7 +456,7 @@ def test_modify_u2(self): def test_modify_u3(self): """7 Modify one attribute as you have no what so ever rights granted""" # First test object -- User - print "Testing modify on User object" + print("Testing modify on User object") self.ldb_admin.newuser("test_modify_user1", self.user_pass) # Modify on attribute you do not have rights for granted ldif = """ @@ -474,7 +474,7 @@ def test_modify_u3(self): self.fail() # Second test object -- Group - print "Testing modify on Group object" + print("Testing modify on Group object") self.ldb_admin.newgroup("test_modify_group1", grouptype=samba.dsdb.GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP) # Modify on attribute you do not have rights for granted @@ -493,7 +493,7 @@ def test_modify_u3(self): self.fail() # Second test object -- Organizational Unit - print "Testing modify on OU object" + print("Testing modify on OU object") #delete_force(self.ldb_admin, "OU=test_modify_ou1," + self.base_dn) self.ldb_admin.create_ou("OU=test_modify_ou1," + self.base_dn) # Modify on attribute you do not have rights for granted @@ -871,7 +871,7 @@ def test_search3(self): self.ldb_admin.create_ou("OU=ou5,OU=ou3,OU=ou2,OU=ou1," + self.base_dn, sd=tmp_desc) self.ldb_admin.create_ou("OU=ou6,OU=ou4,OU=ou2,OU=ou1," + self.base_dn, sd=tmp_desc) - print "Testing correct behavior on nonaccessible search base" + print("Testing correct behavior on nonaccessible search base") try: self.ldb_user3.search("OU=ou3,OU=ou2,OU=ou1," + self.base_dn, expression="(objectClass=*)", scope=SCOPE_BASE) @@ -1870,7 +1870,7 @@ def tearDown(self): del self.ldb_user1 def replace_spn(self, _ldb, dn, spn): - print "Setting spn %s on %s" % (spn, dn) + print("Setting spn %s on %s" % (spn, dn)) res = self.ldb_admin.search(dn, expression="(objectClass=*)", scope=SCOPE_BASE, attrs=["servicePrincipalName"]) if "servicePrincipalName" in res[0].keys(): diff --git a/source4/dsdb/tests/python/ad_dc_medley_performance.py b/source4/dsdb/tests/python/ad_dc_medley_performance.py index 3e8f87ce186..59e7a1420b8 100644 --- a/source4/dsdb/tests/python/ad_dc_medley_performance.py +++ b/source4/dsdb/tests/python/ad_dc_medley_performance.py @@ -191,8 +191,8 @@ def _test_unindexed_search(self): expression=expression, scope=SCOPE_SUBTREE, attrs=['cn']) - print >> sys.stderr, '%d %s took %s' % (i, expression, - time.time() - t) + print('%d %s took %s' % (i, expression, + time.time() - t), file=sys.stderr) def _test_indexed_search(self): expressions = ['(objectclass=group)', @@ -205,8 +205,8 @@ def _test_indexed_search(self): expression=expression, scope=SCOPE_SUBTREE, attrs=['cn']) - print >> sys.stderr, '%d runs %s took %s' % (i, expression, - time.time() - t) + print('%d runs %s took %s' % (i, expression, + time.time() - t), file=sys.stderr) def _test_base_search(self): for dn in [self.base_dn, self.ou, self.ou_users, @@ -238,8 +238,8 @@ def search_expression_list(self, expressions, rounds, expression=expression, scope=SCOPE_SUBTREE, attrs=['cn']) - print >> sys.stderr, '%d runs %s took %s' % (i, expression, - time.time() - t) + print('%d runs %s took %s' % (i, expression, + time.time() - t), file=sys.stderr) def _test_complex_search(self, n=100): classes = ['samaccountname', 'objectCategory', 'dn', 'member'] @@ -365,8 +365,8 @@ def _test_link_many_users_batch(self, n=(LINK_BATCH_SIZE * 10)): try: self.ldb.modify(m) except LdbError as e: - print e - print m + print(e) + print(m) def _test_remove_some_links(self, n=(LINK_BATCH_SIZE // 2)): victims = random.sample(list(self.state.active_links), n) diff --git a/source4/dsdb/tests/python/ad_dc_performance.py b/source4/dsdb/tests/python/ad_dc_performance.py index 09af52f2fd7..ab4514224e7 100644 --- a/source4/dsdb/tests/python/ad_dc_performance.py +++ b/source4/dsdb/tests/python/ad_dc_performance.py @@ -160,8 +160,8 @@ def _test_unindexed_search(self): expression=expression, scope=SCOPE_SUBTREE, attrs=['cn']) - print >> sys.stderr, '%d %s took %s' % (i, expression, - time.time() - t) + print('%d %s took %s' % (i, expression, + time.time() - t), file=sys.stderr) def _test_indexed_search(self): expressions = ['(objectclass=group)', @@ -174,8 +174,8 @@ def _test_indexed_search(self): expression=expression, scope=SCOPE_SUBTREE, attrs=['cn']) - print >> sys.stderr, '%d runs %s took %s' % (i, expression, - time.time() - t) + print('%d runs %s took %s' % (i, expression, + time.time() - t), file=sys.stderr) def _test_add_many_users(self, n=BATCH_SIZE): s = self.state.next_user_id diff --git a/source4/dsdb/tests/python/ad_dc_search_performance.py b/source4/dsdb/tests/python/ad_dc_search_performance.py index 151fb69b666..fd978542024 100644 --- a/source4/dsdb/tests/python/ad_dc_search_performance.py +++ b/source4/dsdb/tests/python/ad_dc_search_performance.py @@ -153,8 +153,8 @@ def _test_unindexed_search(self): expression=expression, scope=SCOPE_SUBTREE, attrs=['cn']) - print >> sys.stderr, '%d %s took %s' % (i, expression, - time.time() - t) + print('%d %s took %s' % (i, expression, + time.time() - t), file=sys.stderr) def _test_indexed_search(self): expressions = ['(objectclass=group)', @@ -167,8 +167,8 @@ def _test_indexed_search(self): expression=expression, scope=SCOPE_SUBTREE, attrs=['cn']) - print >> sys.stderr, '%d runs %s took %s' % (i, expression, - time.time() - t) + print('%d runs %s took %s' % (i, expression, + time.time() - t), file=sys.stderr) def _test_complex_search(self): classes = ['samaccountname', 'objectCategory', 'dn', 'member'] @@ -196,7 +196,7 @@ def _test_complex_search(self): '(', n2, c2, o2, v2, '))' if n2 else ')', ')']) - print expression + print(expression) self.ldb.search(self.ou, expression=expression, scope=SCOPE_SUBTREE, @@ -219,8 +219,8 @@ def _test_member_search(self, rounds=10): expression=expression, scope=SCOPE_SUBTREE, attrs=['cn']) - print >> sys.stderr, '%d runs %s took %s' % (i, expression, - time.time() - t) + print('%d runs %s took %s' % (i, expression, + time.time() - t), file=sys.stderr) def _test_add_many_users(self, n=BATCH_SIZE): s = self.state.next_user_id diff --git a/source4/dsdb/tests/python/deletetest.py b/source4/dsdb/tests/python/deletetest.py index 88695024d5d..ad7704eaf7e 100755 --- a/source4/dsdb/tests/python/deletetest.py +++ b/source4/dsdb/tests/python/deletetest.py @@ -52,7 +52,7 @@ def setUp(self): self.configuration_dn = self.ldb.get_config_basedn().get_linearized() def search_guid(self, guid): - print "SEARCH by GUID %s" % self.GUID_string(guid) + print("SEARCH by GUID %s" % self.GUID_string(guid)) res = self.ldb.search(base="" % self.GUID_string(guid), scope=SCOPE_BASE, controls=["show_deleted:1"]) @@ -60,7 +60,7 @@ def search_guid(self, guid): return res[0] def search_dn(self,dn): - print "SEARCH by DN %s" % dn + print("SEARCH by DN %s" % dn) res = self.ldb.search(expression="(objectClass=*)", base=dn, @@ -76,14 +76,14 @@ def setUp(self): super(BasicDeleteTests, self).setUp() def del_attr_values(self, delObj): - print "Checking attributes for %s" % delObj["dn"] + print("Checking attributes for %s" % delObj["dn"]) self.assertEquals(delObj["isDeleted"][0],"TRUE") self.assertTrue(not("objectCategory" in delObj)) self.assertTrue(not("sAMAccountType" in delObj)) def preserved_attributes_list(self, liveObj, delObj): - print "Checking for preserved attributes list" + print("Checking for preserved attributes list") preserved_list = ["nTSecurityDescriptor", "attributeID", "attributeSyntax", "dNReferenceUpdate", "dNSHostName", "flatName", "governsID", "groupType", "instanceType", "lDAPDisplayName", "legacyExchangeDN", @@ -98,7 +98,7 @@ def preserved_attributes_list(self, liveObj, delObj): self.assertTrue(a in delObj) def check_rdn(self, liveObj, delObj, rdnName): - print "Checking for correct rDN" + print("Checking for correct rDN") rdn=liveObj[rdnName][0] rdn2=delObj[rdnName][0] name2=delObj["name"][0] @@ -109,7 +109,7 @@ def check_rdn(self, liveObj, delObj, rdnName): self.assertEquals(name2, dn_rdn) def delete_deleted(self, ldb, dn): - print "Testing the deletion of the already deleted dn %s" % dn + print("Testing the deletion of the already deleted dn %s" % dn) try: ldb.delete(dn) @@ -121,7 +121,7 @@ def delete_deleted(self, ldb, dn): def test_delete_protection(self): """Delete protection tests""" - print self.base_dn + print(self.base_dn) delete_force(self.ldb, "cn=entry1,cn=ldaptestcontainer," + self.base_dn) delete_force(self.ldb, "cn=entry2,cn=ldaptestcontainer," + self.base_dn) @@ -268,7 +268,7 @@ def test_delete_protection(self): def test_all(self): """Basic delete tests""" - print self.base_dn + print(self.base_dn) # user current time in ms to make unique objects import time diff --git a/source4/dsdb/tests/python/dirsync.py b/source4/dsdb/tests/python/dirsync.py index 2da776a5766..280a96bab62 100755 --- a/source4/dsdb/tests/python/dirsync.py +++ b/source4/dsdb/tests/python/dirsync.py @@ -83,7 +83,7 @@ def setUp(self): self.configuration_dn = self.ldb_admin.get_config_basedn().get_linearized() self.sd_utils = sd_utils.SDUtils(self.ldb_admin) #used for anonymous login - print "baseDN: %s" % self.base_dn + print("baseDN: %s" % self.base_dn) def get_user_dn(self, name): return "CN=%s,CN=Users,%s" % (name, self.base_dn) @@ -178,7 +178,7 @@ def test_dirsync_errors(self): expression="samaccountname=*", controls=["dirsync:1:0:1"]) except LdbError as l: - print l + print(l) self.assertTrue(str(l).find("LDAP_INSUFFICIENT_ACCESS_RIGHTS") != -1) try: @@ -186,7 +186,7 @@ def test_dirsync_errors(self): expression="samaccountname=*", controls=["dirsync:1:0:1"]) except LdbError as l: - print l + print(l) self.assertTrue(str(l).find("LDAP_INSUFFICIENT_ACCESS_RIGHTS") != -1) try: @@ -194,7 +194,7 @@ def test_dirsync_errors(self): expression="samaccountname=*", controls=["dirsync:1:1:1"]) except LdbError as l: - print l + print(l) self.assertTrue(str(l).find("LDAP_UNWILLING_TO_PERFORM") != -1) try: @@ -202,7 +202,7 @@ def test_dirsync_errors(self): expression="samaccountname=*", controls=["dirsync:1:0:1"]) except LdbError as l: - print l + print(l) self.assertTrue(str(l).find("LDAP_INSUFFICIENT_ACCESS_RIGHTS") != -1) try: @@ -210,7 +210,7 @@ def test_dirsync_errors(self): expression="samaccountname=*", controls=["dirsync:1:0:1"]) except LdbError as l: - print l + print(l) self.assertTrue(str(l).find("LDAP_INSUFFICIENT_ACCESS_RIGHTS") != -1) try: @@ -218,7 +218,7 @@ def test_dirsync_errors(self): expression="samaccountname=*", controls=["dirsync:1:1:1"]) except LdbError as l: - print l + print(l) self.assertTrue(str(l).find("LDAP_UNWILLING_TO_PERFORM") != -1) def test_dirsync_attributes(self): @@ -516,7 +516,7 @@ def test_dirsync_linkedattributes(self): # Check that reasking the same question but with an updated cookie # didn't return any results. - print control1 + print(control1) res = self.ldb_admin.search(self.base_dn, expression="(name=testgroup)", controls=[control1]) diff --git a/source4/dsdb/tests/python/ldap.py b/source4/dsdb/tests/python/ldap.py index db0b68c8405..e7773996933 100755 --- a/source4/dsdb/tests/python/ldap.py +++ b/source4/dsdb/tests/python/ldap.py @@ -2584,11 +2584,11 @@ def test_all(self): res = ldb.search(self.base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs, controls=["extended_dn:1:1"]) self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))") - print res[0]["member"] + print(res[0]["member"]) memberUP = [] for m in res[0]["member"]: memberUP.append(m.upper()) - print (";;CN=ldaptestuser2,CN=Users," + self.base_dn).upper() + print((";;CN=ldaptestuser2,CN=Users," + self.base_dn).upper()) self.assertTrue((";;CN=ldaptestuser2,CN=Users," + self.base_dn).upper() in memberUP) diff --git a/source4/dsdb/tests/python/ldap_schema.py b/source4/dsdb/tests/python/ldap_schema.py index fff47374722..a56393a26ef 100755 --- a/source4/dsdb/tests/python/ldap_schema.py +++ b/source4/dsdb/tests/python/ldap_schema.py @@ -1615,7 +1615,7 @@ def test_verify_msDS_IntId(self): #self.assertTrue("msDS-IntId" in ldb_msg, "msDS-IntId expected on: %s" % ldb_msg.dn) if "msDS-IntId" not in ldb_msg: count = count + 1 - print "%3d warning: msDS-IntId expected on: %-30s %s" % (count, ldb_msg["attributeID"], ldb_msg["cn"]) + print("%3d warning: msDS-IntId expected on: %-30s %s" % (count, ldb_msg["attributeID"], ldb_msg["cn"])) else: self.assertTrue("msDS-IntId" not in ldb_msg) diff --git a/source4/dsdb/tests/python/linked_attributes.py b/source4/dsdb/tests/python/linked_attributes.py index 96ea75dc953..56c65aa54ee 100644 --- a/source4/dsdb/tests/python/linked_attributes.py +++ b/source4/dsdb/tests/python/linked_attributes.py @@ -65,7 +65,7 @@ def setUp(self): try: self.samdb.delete(self.ou, ['tree_delete:1']) except ldb.LdbError as e: - print "tried deleting %s, got error %s" % (self.ou, e) + print("tried deleting %s, got error %s" % (self.ou, e)) self.samdb.add({'objectclass': 'organizationalUnit', 'dn': self.ou}) @@ -145,9 +145,9 @@ def assert_links(self, obj, expected, attr, msg='', **kwargs): results = sorted(results) if expected != results: - print msg - print "expected %s" % expected - print "received %s" % results + print(msg) + print("expected %s" % expected) + print("received %s" % results) self.assertEqual(results, expected) @@ -208,7 +208,7 @@ def test_la_backlinks(self): def test_la_backlinks_reveal(self): if opts.no_reveal_internals: - print 'skipping because --no-reveal-internals' + print('skipping because --no-reveal-internals') return self._test_la_backlinks(True) @@ -236,7 +236,7 @@ def test_la_backlinks_delete_group(self): def test_la_backlinks_delete_group_reveal(self): if opts.no_reveal_internals: - print 'skipping because --no-reveal-internals' + print('skipping because --no-reveal-internals') return self._test_la_backlinks_delete_group(True) @@ -350,7 +350,7 @@ def _test_la_links_delete_link_reveal(self): def test_la_links_delete_link_reveal(self): if opts.no_reveal_internals: - print 'skipping because --no-reveal-internals' + print('skipping because --no-reveal-internals') return self._test_la_links_delete_link_reveal() diff --git a/source4/dsdb/tests/python/notification.py b/source4/dsdb/tests/python/notification.py index 974aba5a0ca..49e044e155b 100755 --- a/source4/dsdb/tests/python/notification.py +++ b/source4/dsdb/tests/python/notification.py @@ -341,7 +341,7 @@ def test_invalid_filter(self): except LdbError as e9: (num, _) = e9.args if num != ERR_UNWILLING_TO_PERFORM: - print "va[%s]" % va + print("va[%s]" % va) self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) try: @@ -359,7 +359,7 @@ def test_invalid_filter(self): except LdbError as e11: (num, _) = e11.args if num != ERR_UNWILLING_TO_PERFORM: - print "va[%s]" % va + print("va[%s]" % va) self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) if not "://" in url: diff --git a/source4/dsdb/tests/python/password_lockout.py b/source4/dsdb/tests/python/password_lockout.py index ee3932ccf00..422cc9b1da6 100755 --- a/source4/dsdb/tests/python/password_lockout.py +++ b/source4/dsdb/tests/python/password_lockout.py @@ -130,11 +130,11 @@ def _test_userPassword_lockout_with_clear_change(self, creds, other_ldb, method, if use_kerberos == MUST_USE_KERBEROS: logoncount_relation = 'greater' lastlogon_relation = 'greater' - print "Performs a password cleartext change operation on 'userPassword' using Kerberos" + print("Performs a password cleartext change operation on 'userPassword' using Kerberos") else: logoncount_relation = 'equal' lastlogon_relation = 'equal' - print "Performs a password cleartext change operation on 'userPassword' using NTLMSSP" + print("Performs a password cleartext change operation on 'userPassword' using NTLMSSP") if initial_lastlogon_relation is not None: lastlogon_relation = initial_lastlogon_relation @@ -232,7 +232,7 @@ def _test_userPassword_lockout_with_clear_change(self, creds, other_ldb, method, msDSUserAccountControlComputed=0) badPasswordTime = int(res[0]["badPasswordTime"][0]) - print "two failed password change" + print("two failed password change") # Wrong old password try: @@ -580,7 +580,7 @@ def test_userPassword_lockout_with_clear_change_ntlm_samr(self): def _test_unicodePwd_lockout_with_clear_change(self, creds, other_ldb, initial_logoncount_relation=None): - print "Performs a password cleartext change operation on 'unicodePwd'" + print("Performs a password cleartext change operation on 'unicodePwd'") username = creds.get_username() userpass = creds.get_password() userdn = "cn=%s,cn=users,%s" % (username, self.base_dn) @@ -702,7 +702,7 @@ def _test_unicodePwd_lockout_with_clear_change(self, creds, other_ldb, dsdb.UF_NORMAL_ACCOUNT, msDSUserAccountControlComputed=0) - print "two failed password change" + print("two failed password change") # Wrong old password try: diff --git a/source4/dsdb/tests/python/password_lockout_base.py b/source4/dsdb/tests/python/password_lockout_base.py index 92448649695..bd004042f66 100644 --- a/source4/dsdb/tests/python/password_lockout_base.py +++ b/source4/dsdb/tests/python/password_lockout_base.py @@ -54,7 +54,7 @@ def _check_attribute(self, res, name, value): (name, res[0][name], res[0].dn)) - print "%s = '%s'" % (name, res[0][name][0]) + print("%s = '%s'" % (name, res[0][name][0])) if mode == "present": return @@ -107,9 +107,9 @@ def _check_account(self, dn, effective_bad_password_count=None, msg=None, badPwdCountOnly=False): - print '-=' * 36 + print('-=' * 36) if msg is not None: - print "\033[01;32m %s \033[00m\n" % msg + print("\033[01;32m %s \033[00m\n" % msg) attrs = [ "objectSid", "badPwdCount", @@ -385,11 +385,11 @@ def _test_login_lockout(self, creds): if use_kerberos == MUST_USE_KERBEROS: logoncount_relation = 'greater' lastlogon_relation = 'greater' - print "Performs a lockout attempt against LDAP using Kerberos" + print("Performs a lockout attempt against LDAP using Kerberos") else: logoncount_relation = 'equal' lastlogon_relation = 'equal' - print "Performs a lockout attempt against LDAP using NTLM" + print("Performs a lockout attempt against LDAP using NTLM") # Change password on a connection as another user res = self._check_account(userdn, @@ -406,8 +406,8 @@ def _test_login_lockout(self, creds): lastLogon = int(res[0]["lastLogon"][0]) firstLogon = lastLogon lastLogonTimestamp = int(res[0]["lastLogonTimestamp"][0]) - print firstLogon - print lastLogonTimestamp + print(firstLogon) + print(lastLogonTimestamp) self.assertGreater(lastLogon, badPasswordTime) @@ -496,7 +496,7 @@ def _test_login_lockout(self, creds): msDSUserAccountControlComputed=0) badPasswordTime = int(res[0]["badPasswordTime"][0]) - print "two failed password change" + print("two failed password change") # The wrong password creds_lockout.set_password("thatsAcomplPASS1x") @@ -584,7 +584,7 @@ def _test_login_lockout(self, creds): # wait for the lockout to end time.sleep(self.account_lockout_duration + 1) - print self.account_lockout_duration + 1 + print(self.account_lockout_duration + 1) res = self._check_account(userdn, badPwdCount=3, effective_bad_password_count=0, @@ -726,11 +726,11 @@ def _test_multiple_logon(self, creds): use_kerberos = creds.get_kerberos_state() if use_kerberos == MUST_USE_KERBEROS: - print "Testing multiple logon with Kerberos" + print("Testing multiple logon with Kerberos") logoncount_relation = 'greater' lastlogon_relation = 'greater' else: - print "Testing multiple logon with NTLM" + print("Testing multiple logon with NTLM") logoncount_relation = 'equal' lastlogon_relation = 'equal' @@ -750,7 +750,7 @@ def _test_multiple_logon(self, creds): lastLogon = int(res[0]["lastLogon"][0]) lastLogonTimestamp = int(res[0]["lastLogonTimestamp"][0]) firstLogon = lastLogon - print "last logon is %d" % lastLogon + print("last logon is %d" % lastLogon) self.assertGreater(lastLogon, badPasswordTime) self.assertGreaterEqual(lastLogon, lastLogonTimestamp) diff --git a/source4/dsdb/tests/python/passwords.py b/source4/dsdb/tests/python/passwords.py index 357b3404d59..3ea1dff48f3 100755 --- a/source4/dsdb/tests/python/passwords.py +++ b/source4/dsdb/tests/python/passwords.py @@ -716,7 +716,7 @@ def test_failures(self): "userPassword": ["thatsAcomplPASS1", "thatsAcomplPASS1"] }) def test_empty_passwords(self): - print "Performs some empty passwords testing" + print("Performs some empty passwords testing") try: self.ldb.add({ @@ -885,7 +885,7 @@ def test_empty_passwords(self): num == ERR_NO_SUCH_ATTRIBUTE) # for Windows def test_plain_userPassword(self): - print "Performs testing about the standard 'userPassword' behaviour" + print("Performs testing about the standard 'userPassword' behaviour") # Delete the "dSHeuristics" self.ldb.set_dsheuristics(None) @@ -961,7 +961,7 @@ def test_plain_userPassword(self): self.ldb.set_dsheuristics("000000001") def test_modify_dsheuristics_userPassword(self): - print "Performs testing about reading userPassword between dsHeuristic modifies" + print("Performs testing about reading userPassword between dsHeuristic modifies") # Make sure userPassword cannot be read self.ldb.set_dsheuristics("000000000") diff --git a/source4/dsdb/tests/python/rodc.py b/source4/dsdb/tests/python/rodc.py index e1a4cd942bc..67c1fea74ec 100755 --- a/source4/dsdb/tests/python/rodc.py +++ b/source4/dsdb/tests/python/rodc.py @@ -70,7 +70,7 @@ def test_add_replicated_objects(self): except ldb.LdbError as e: (ecode, emsg) = e.args if ecode != ldb.ERR_REFERRAL: - print emsg + print(emsg) self.fail("Adding %s: ldb error: %s %s, wanted referral" % (o['dn'], ecode, emsg)) else: @@ -197,7 +197,7 @@ def test_delete_special_objects(self): except ldb.LdbError as e4: (ecode, emsg) = e4.args if ecode != ldb.ERR_REFERRAL: - print ecode, emsg + print(ecode, emsg) self.fail("Failed to REFER when trying to delete %s" % dn) else: m = re.search(r'(ldap://[^>]+)>', emsg) @@ -216,7 +216,7 @@ def test_no_delete_nonexistent_objects(self): except ldb.LdbError as e5: (ecode, emsg) = e5.args if ecode != ldb.ERR_NO_SUCH_OBJECT: - print ecode, emsg + print(ecode, emsg) self.fail("Failed to NO_SUCH_OBJECT when trying to delete " "%s (which does not exist)" % dn) diff --git a/source4/dsdb/tests/python/rodc_rwdc.py b/source4/dsdb/tests/python/rodc_rwdc.py index 4d9f893d98d..3d2b986c684 100644 --- a/source4/dsdb/tests/python/rodc_rwdc.py +++ b/source4/dsdb/tests/python/rodc_rwdc.py @@ -50,13 +50,13 @@ def make_creds(username, password, kerberos_state=None): kerberos_state = CREDS.get_kerberos_state() c.set_kerberos_state(kerberos_state) - print '-' * 73 + print('-' * 73) if kerberos_state == MUST_USE_KERBEROS: - print "we seem to be using kerberos for %s %s" % (username, password) + print("we seem to be using kerberos for %s %s" % (username, password)) elif kerberos_state == DONT_USE_KERBEROS: - print "NOT using kerberos for %s %s" % (username, password) + print("NOT using kerberos for %s %s" % (username, password)) else: - print "kerberos state is %s" % kerberos_state + print("kerberos state is %s" % kerberos_state) c.set_gensec_features(c.get_gensec_features() | gensec.FEATURE_SEAL) @@ -98,7 +98,7 @@ def preload_rodc_user(user_dn): credstring, '--server', RWDC,] - print ' '.join(cmd) + print(' '.join(cmd)) subprocess.check_call(cmd) set_auto_replication(RWDC, False) @@ -164,12 +164,12 @@ def force_replication(self, base=None): stdout=subprocess.PIPE) stdout, stderr = p.communicate() if p.returncode: - print "failed with code %s" % p.returncode - print ' '.join(cmd) - print "stdout" - print stdout - print "stderr" - print stderr + print("failed with code %s" % p.returncode) + print(' '.join(cmd)) + print("stdout") + print(stdout) + print("stderr") + print(stderr) raise RodcRwdcTestException() def _change_password(self, user_dn, old_password, new_password): @@ -486,7 +486,7 @@ def _test_login_lockout_rodc_rwdc(self, creds, userdn): msDSUserAccountControlComputed=0) badPasswordTime = int(res[0]["badPasswordTime"][0]) - print "two failed password change" + print("two failed password change") # The wrong password creds_lockout.set_password("thatsAcomplPASS1x") @@ -574,7 +574,7 @@ def _test_login_lockout_rodc_rwdc(self, creds, userdn): # wait for the lockout to end time.sleep(self.account_lockout_duration + 1) - print self.account_lockout_duration + 1 + print(self.account_lockout_duration + 1) res = self._check_account(userdn, badPwdCount=3, effective_bad_password_count=0, @@ -720,12 +720,12 @@ def force_replication(self, base=None): stdout=subprocess.PIPE) stdout, stderr = p.communicate() if p.returncode: - print "failed with code %s" % p.returncode - print ' '.join(cmd) - print "stdout" - print stdout - print "stderr" - print stderr + print("failed with code %s" % p.returncode) + print(' '.join(cmd)) + print("stdout") + print(stdout) + print("stderr") + print(stderr) raise RodcRwdcTestException() def _check_account_initial(self, dn): diff --git a/source4/dsdb/tests/python/sam.py b/source4/dsdb/tests/python/sam.py index 38b90bda32e..5726b67c81d 100755 --- a/source4/dsdb/tests/python/sam.py +++ b/source4/dsdb/tests/python/sam.py @@ -80,7 +80,7 @@ def setUp(self): self.ldb = ldb self.base_dn = ldb.domain_dn() - print "baseDN: %s\n" % self.base_dn + print("baseDN: %s\n" % self.base_dn) delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn) delete_force(self.ldb, "cn=ldaptestuser2,cn=users," + self.base_dn) @@ -91,7 +91,7 @@ def setUp(self): def test_users_groups(self): """This tests the SAM users and groups behaviour""" - print "Testing users and groups behaviour\n" + print("Testing users and groups behaviour\n") ldb.add({ "dn": "cn=ldaptestgroup,cn=users," + self.base_dn, @@ -616,7 +616,7 @@ def test_users_groups(self): def test_sam_attributes(self): """Test the behaviour of special attributes of SAM objects""" - print "Testing the behaviour of special attributes of SAM objects\n" + print("Testing the behaviour of special attributes of SAM objects\n") ldb.add({ "dn": "cn=ldaptestuser,cn=users," + self.base_dn, @@ -749,7 +749,7 @@ def test_sam_attributes(self): def test_primary_group_token_constructed(self): """Test the primary group token behaviour (hidden-generated-readonly attribute on groups) and some other constructed attributes""" - print "Testing primary group token behaviour and other constructed attributes\n" + print("Testing primary group token behaviour and other constructed attributes\n") try: ldb.add({ @@ -825,7 +825,7 @@ def test_primary_group_token_constructed(self): def test_tokenGroups(self): """Test the tokenGroups behaviour (hidden-generated-readonly attribute on SAM objects)""" - print "Testing tokenGroups behaviour\n" + print("Testing tokenGroups behaviour\n") # The domain object shouldn't contain any "tokenGroups" entry res = ldb.search(self.base_dn, scope=SCOPE_BASE, attrs=["tokenGroups"]) @@ -869,7 +869,7 @@ def test_tokenGroups(self): def test_groupType(self): """Test the groupType behaviour""" - print "Testing groupType behaviour\n" + print("Testing groupType behaviour\n") # You can never create or change to a # "GTYPE_SECURITY_BUILTIN_LOCAL_GROUP" @@ -1469,7 +1469,7 @@ def test_groupType(self): def test_pwdLastSet(self): """Test the pwdLastSet behaviour""" - print "Testing pwdLastSet behaviour\n" + print("Testing pwdLastSet behaviour\n") ldb.add({ "dn": "cn=ldaptestuser,cn=users," + self.base_dn, @@ -1682,7 +1682,7 @@ def test_pwdLastSet(self): def test_ldap_bind_must_change_pwd(self): """Test the error messages for failing LDAP binds""" - print "Test the error messages for failing LDAP binds\n" + print("Test the error messages for failing LDAP binds\n") delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn) @@ -1863,7 +1863,7 @@ def assertLDAPErrorMsg(msg, expected_msg): def test_userAccountControl(self): """Test the userAccountControl behaviour""" - print "Testing userAccountControl behaviour\n" + print("Testing userAccountControl behaviour\n") # With a user object @@ -2543,7 +2543,7 @@ def find_repl_meta_data(self, rpmd, attid): def test_smartcard_required1(self): """Test the UF_SMARTCARD_REQUIRED behaviour""" - print "Testing UF_SMARTCARD_REQUIRED behaviour\n" + print("Testing UF_SMARTCARD_REQUIRED behaviour\n") delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn) @@ -2647,7 +2647,7 @@ def test_smartcard_required1(self): def test_smartcard_required2(self): """Test the UF_SMARTCARD_REQUIRED behaviour""" - print "Testing UF_SMARTCARD_REQUIRED behaviour\n" + print("Testing UF_SMARTCARD_REQUIRED behaviour\n") delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn) @@ -2795,7 +2795,7 @@ def test_smartcard_required2(self): def test_smartcard_required3(self): """Test the UF_SMARTCARD_REQUIRED behaviour""" - print "Testing UF_SMARTCARD_REQUIRED behaviour\n" + print("Testing UF_SMARTCARD_REQUIRED behaviour\n") delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn) @@ -2896,7 +2896,7 @@ def test_smartcard_required3(self): def test_isCriticalSystemObject(self): """Test the isCriticalSystemObject behaviour""" - print "Testing isCriticalSystemObject behaviour\n" + print("Testing isCriticalSystemObject behaviour\n") # Add tests @@ -3028,7 +3028,7 @@ def test_isCriticalSystemObject(self): def test_service_principal_name_updates(self): """Test the servicePrincipalNames update behaviour""" - print "Testing servicePrincipalNames update behaviour\n" + print("Testing servicePrincipalNames update behaviour\n") ldb.add({ "dn": "cn=ldaptestcomputer,cn=computers," + self.base_dn, @@ -3416,7 +3416,7 @@ def test_service_principal_name_updates(self): def test_sam_description_attribute(self): """Test SAM description attribute""" - print "Test SAM description attribute" + print("Test SAM description attribute") self.ldb.add({ "dn": "cn=ldaptestgroup,cn=users," + self.base_dn, @@ -3589,7 +3589,7 @@ def test_sam_description_attribute(self): def test_fSMORoleOwner_attribute(self): """Test fSMORoleOwner attribute""" - print "Test fSMORoleOwner attribute" + print("Test fSMORoleOwner attribute") ds_service_name = self.ldb.get_dsServiceName() @@ -3702,7 +3702,7 @@ def test_protected_sid_objects(self): def test_new_user_default_attributes(self): """Test default attributes for new user objects""" - print "Test default attributes for new User objects\n" + print("Test default attributes for new User objects\n") user_name = "ldaptestuser" user_dn = "CN=%s,CN=Users,%s" % (user_name, self.base_dn) diff --git a/source4/dsdb/tests/python/sec_descriptor.py b/source4/dsdb/tests/python/sec_descriptor.py index 1417dc4f3f1..907bf199ec2 100755 --- a/source4/dsdb/tests/python/sec_descriptor.py +++ b/source4/dsdb/tests/python/sec_descriptor.py @@ -152,7 +152,7 @@ def setUp(self): self.domain_sid = security.dom_sid(self.ldb_admin.get_domain_sid()) self.sd_utils = sd_utils.SDUtils(self.ldb_admin) self.addCleanup(self.delete_admin_connection) - print "baseDN: %s" % self.base_dn + print("baseDN: %s" % self.base_dn) def delete_admin_connection(self): del self.sd_utils @@ -364,7 +364,7 @@ def check_modify_inheritance(self, _ldb, object_dn, owner_group=""): self.assertTrue(ace in desc_sddl) # Make sure we have identical result for both "add" and "modify" res = re.search("(O:.*G:.*?)D:", desc_sddl).group(1) - print self._testMethodName + print(self._testMethodName) test_number = self._testMethodName[5:] self.assertEqual(self.results[self.DS_BEHAVIOR][test_number], res) @@ -1971,7 +1971,7 @@ def test_sDRightsEffective(self): object_dn = "OU=test_domain_ou1," + self.base_dn delete_force(self.ldb_admin, object_dn) self.ldb_admin.create_ou(object_dn) - print self.get_users_domain_dn("testuser_attr") + print(self.get_users_domain_dn("testuser_attr")) user_sid = self.sd_utils.get_object_sid(self.get_users_domain_dn("testuser_attr")) #give testuser1 read access so attributes can be retrieved mod = "(A;CI;RP;;;%s)" % str(user_sid) @@ -2121,12 +2121,12 @@ def test_301(self): self.assertFalse(sub_sddl2 == sub_sddl0) if ace not in ou_sddl2: - print "ou0: %s" % ou_sddl0 - print "ou2: %s" % ou_sddl2 + print("ou0: %s" % ou_sddl0) + print("ou2: %s" % ou_sddl2) if sub_ace not in sub_sddl2: - print "sub0: %s" % sub_sddl0 - print "sub2: %s" % sub_sddl2 + print("sub0: %s" % sub_sddl0) + print("sub2: %s" % sub_sddl2) self.assertTrue(ace in ou_sddl2) self.assertTrue(sub_ace in sub_sddl2) diff --git a/source4/dsdb/tests/python/sites.py b/source4/dsdb/tests/python/sites.py index 3bb53d9bc4c..045752d6cf5 100755 --- a/source4/dsdb/tests/python/sites.py +++ b/source4/dsdb/tests/python/sites.py @@ -473,18 +473,18 @@ def test_create_bad_ranges(self): try: subnets.create_subnet(self.ldb, basedn, cidr, self.sitename) except subnets.SubnetInvalid: - print >> sys.stderr, "%s fails properly" % (cidr,) + print("%s fails properly" % (cidr,), file=sys.stderr) continue # we are here because it succeeded when it shouldn't have. - print >> sys.stderr, "CIDR %s fails to fail" % (cidr,) + print("CIDR %s fails to fail" % (cidr,), file=sys.stderr) failures.append(cidr) subnets.delete_subnet(self.ldb, basedn, cidr) if failures: - print "These bad subnet names were accepted:" + print("These bad subnet names were accepted:") for cidr in failures: - print " %s" % cidr + print(" %s" % cidr) self.fail() def test_create_good_ranges(self): @@ -613,7 +613,7 @@ def test_create_good_ranges(self): try: subnets.create_subnet(self.ldb, basedn, cidr, self.sitename) except subnets.SubnetInvalid as e: - print e + print(e) failures.append(cidr) continue @@ -622,15 +622,15 @@ def test_create_good_ranges(self): cidr)) if len(ret) != 1: - print "%s was not created" % cidr + print("%s was not created" % cidr) failures.append(cidr) continue subnets.delete_subnet(self.ldb, basedn, cidr) if failures: - print "These good subnet names were not accepted:" + print("These good subnet names were not accepted:") for cidr in failures: - print " %s" % cidr + print(" %s" % cidr) self.fail() diff --git a/source4/dsdb/tests/python/sort.py b/source4/dsdb/tests/python/sort.py index 089e4b520cc..59cef7692ff 100644 --- a/source4/dsdb/tests/python/sort.py +++ b/source4/dsdb/tests/python/sort.py @@ -134,7 +134,7 @@ def setUp(self): try: self.ldb.delete(self.ou, ['tree_delete:1']) except ldb.LdbError as e: - print "tried deleting %s, got error %s" % (self.ou, e) + print("tried deleting %s, got error %s" % (self.ou, e)) self.ldb.add({ "dn": self.ou, @@ -222,12 +222,12 @@ def _test_server_sort_default(self): expected_order = self.expected_results[attr][rev] received_order = [norm(x[attr][0]) for x in res] if expected_order != received_order: - print attr, ['forward', 'reverse'][rev] - print "expected", expected_order - print "recieved", received_order - print "unnormalised:", [x[attr][0] for x in res] - print "unnormalised: «%s»" % '» «'.join(x[attr][0] - for x in res) + print(attr, ['forward', 'reverse'][rev]) + print("expected", expected_order) + print("recieved", received_order) + print("unnormalised:", [x[attr][0] for x in res]) + print("unnormalised: «%s»" % '» «'.join(x[attr][0] + for x in res)) self.assertEquals(expected_order, received_order) def _test_server_sort_binary(self): @@ -242,9 +242,9 @@ def _test_server_sort_binary(self): expected_order = self.expected_results_binary[attr][rev] received_order = [x[attr][0] for x in res] if expected_order != received_order: - print attr - print expected_order - print received_order + print(attr) + print(expected_order) + print(received_order) self.assertEquals(expected_order, received_order) def _test_server_sort_us_english(self): @@ -268,13 +268,13 @@ def _test_server_sort_us_english(self): expected_order = self.expected_results[attr][rev] received_order = [norm(x[attr][0]) for x in res] if expected_order != received_order: - print attr, lang - print ['forward', 'reverse'][rev] - print "expected: ", expected_order - print "recieved: ", received_order - print "unnormalised:", [x[attr][0] for x in res] - print "unnormalised: «%s»" % '» «'.join(x[attr][0] - for x in res) + print(attr, lang) + print(['forward', 'reverse'][rev]) + print("expected: ", expected_order) + print("recieved: ", received_order) + print("unnormalised:", [x[attr][0] for x in res]) + print("unnormalised: «%s»" % '» «'.join(x[attr][0] + for x in res)) self.assertEquals(expected_order, received_order) @@ -318,22 +318,22 @@ def cmp_numeric(a, b): received_order = [norm(x[result_attr][0]) for x in res] if expected_order != received_order: - print sort_attr, result_attr, ['forward', 'reverse'][rev] - print "expected", expected_order - print "recieved", received_order - print "unnormalised:", [x[result_attr][0] for x in res] - print "unnormalised: «%s»" % '» «'.join(x[result_attr][0] - for x in res) - print "pairs:", pairs + print(sort_attr, result_attr, ['forward', 'reverse'][rev]) + print("expected", expected_order) + print("recieved", received_order) + print("unnormalised:", [x[result_attr][0] for x in res]) + print("unnormalised: «%s»" % '» «'.join(x[result_attr][0] + for x in res)) + print("pairs:", pairs) # There are bugs in Windows that we don't want (or # know how) to replicate regarding timestamp sorting. # Let's remind ourselves. if result_attr == "msTSExpireDate4": - print '-' * 72 + print('-' * 72) print ("This test fails against Windows with the " "default number of elements (33).") - print "Try with --elements=27 (or similar)." - print '-' * 72 + print("Try with --elements=27 (or similar).") + print('-' * 72) self.assertEquals(expected_order, received_order) for x in res: diff --git a/source4/dsdb/tests/python/token_group.py b/source4/dsdb/tests/python/token_group.py index 6a9c8677541..fb63564f82b 100755 --- a/source4/dsdb/tests/python/token_group.py +++ b/source4/dsdb/tests/python/token_group.py @@ -151,10 +151,10 @@ def test_pac_groups(self): # Run the actual call loop. while client_finished == False and server_finished == False: if not client_finished: - print "running client gensec_update" + print("running client gensec_update") (client_finished, client_to_server) = gensec_client.update(server_to_client) if not server_finished: - print "running server gensec_update" + print("running server gensec_update") (server_finished, server_to_client) = gensec_server.update(client_to_server) session = gensec_server.session_info() @@ -383,10 +383,10 @@ def test_pac_groups(self): # Run the actual call loop. while client_finished == False and server_finished == False: if not client_finished: - print "running client gensec_update" + print("running client gensec_update") (client_finished, client_to_server) = gensec_client.update(server_to_client) if not server_finished: - print "running server gensec_update" + print("running server gensec_update") (server_finished, server_to_client) = gensec_server.update(client_to_server) session = gensec_server.session_info() diff --git a/source4/dsdb/tests/python/tombstone_reanimation.py b/source4/dsdb/tests/python/tombstone_reanimation.py index 87f600268af..242c880a6d4 100755 --- a/source4/dsdb/tests/python/tombstone_reanimation.py +++ b/source4/dsdb/tests/python/tombstone_reanimation.py @@ -210,7 +210,7 @@ def enable_recycle_bin(self): self.assertEquals(num, ERR_ATTRIBUTE_OR_VALUE_EXISTS) def test_undelete(self): - print "Testing standard undelete operation" + print("Testing standard undelete operation") usr1 = "cn=testuser,cn=users," + self.base_dn samba.tests.delete_force(self.samdb, usr1) self.samdb.add({ @@ -228,7 +228,7 @@ def test_undelete(self): samba.tests.delete_force(self.samdb, usr1) def test_rename(self): - print "Testing attempt to rename deleted object" + print("Testing attempt to rename deleted object") usr1 = "cn=testuser,cn=users," + self.base_dn self.samdb.add({ "dn": usr1, @@ -255,7 +255,7 @@ def test_rename(self): self.assertEquals(num, ERR_UNWILLING_TO_PERFORM) def test_undelete_with_mod(self): - print "Testing standard undelete operation with modification of additional attributes" + print("Testing standard undelete operation with modification of additional attributes") usr1 = "cn=testuser,cn=users," + self.base_dn self.samdb.add({ "dn": usr1, @@ -272,7 +272,7 @@ def test_undelete_with_mod(self): samba.tests.delete_force(self.samdb, usr1) def test_undelete_newuser(self): - print "Testing undelete user with a different dn" + print("Testing undelete user with a different dn") usr1 = "cn=testuser,cn=users," + self.base_dn usr2 = "cn=testuser2,cn=users," + self.base_dn samba.tests.delete_force(self.samdb, usr1) @@ -291,7 +291,7 @@ def test_undelete_newuser(self): samba.tests.delete_force(self.samdb, usr2) def test_undelete_existing(self): - print "Testing undelete user after a user with the same dn has been created" + print("Testing undelete user after a user with the same dn has been created") usr1 = "cn=testuser,cn=users," + self.base_dn self.samdb.add({ "dn": usr1, @@ -315,7 +315,7 @@ def test_undelete_existing(self): self.assertEquals(num, ERR_ENTRY_ALREADY_EXISTS) def test_undelete_cross_nc(self): - print "Cross NC undelete" + print("Cross NC undelete") c1 = "cn=ldaptestcontainer," + self.base_dn c2 = "cn=ldaptestcontainer2," + self.configuration_dn c3 = "cn=ldaptestcontainer," + self.configuration_dn @@ -525,7 +525,7 @@ def _expected_user_restore_metadata(self): (DRSUAPI_ATTID_isRecycled, 2)] def test_restore_user(self): - print "Test restored user attributes" + print("Test restored user attributes") username = "restore_user" usr_dn = "CN=%s,CN=Users,%s" % (username, self.base_dn) samba.tests.delete_force(self.samdb, usr_dn) @@ -732,7 +732,7 @@ def _expected_userpw_restore_metadata(self): (DRSUAPI_ATTID_isRecycled, 2)] def test_restorepw_user(self): - print "Test restored user attributes" + print("Test restored user attributes") username = "restorepw_user" usr_dn = "CN=%s,CN=Users,%s" % (username, self.base_dn) samba.tests.delete_force(self.samdb, usr_dn) @@ -827,7 +827,7 @@ def _expected_group_attributes(self, groupname, group_dn, category): 'cn': groupname } def test_plain_group(self): - print "Test restored Group attributes" + print("Test restored Group attributes") # create test group obj = self._create_test_group("r_group") guid = obj["objectGUID"][0] @@ -846,7 +846,7 @@ def test_plain_group(self): self.assertAttributesExists(self._expected_group_attributes("r_group", str(obj.dn), "Group"), obj_restore) def test_group_with_members(self): - print "Test restored Group with members attributes" + print("Test restored Group with members attributes") # create test group usr1 = self._create_test_user("r_user_1") usr2 = self._create_test_user("r_user_2") @@ -900,7 +900,7 @@ def _create_test_ou(self, rdn, name=None, description=None): return self.search_dn(ou_dn) def test_ou_with_name_description(self): - print "Test OU reanimation" + print("Test OU reanimation") # create OU to test with obj = self._create_test_ou(rdn="r_ou", name="r_ou name", @@ -924,7 +924,7 @@ def test_ou_with_name_description(self): self.assertAttributesExists(expected_attrs, obj_restore) def test_container(self): - print "Test Container reanimation" + print("Test Container reanimation") # create test Container obj = self._create_object({ "dn": "CN=r_container,CN=Users,%s" % self.base_dn, diff --git a/source4/dsdb/tests/python/urgent_replication.py b/source4/dsdb/tests/python/urgent_replication.py index aca6309b0e9..0dab52366cf 100755 --- a/source4/dsdb/tests/python/urgent_replication.py +++ b/source4/dsdb/tests/python/urgent_replication.py @@ -47,7 +47,7 @@ def setUp(self): self.ldb = samba.tests.connect_samdb(host, global_schema=False) self.base_dn = self.ldb.domain_dn() - print "baseDN: %s\n" % self.base_dn + print("baseDN: %s\n" % self.base_dn) def test_nonurgent_object(self): """Test if the urgent replication is not activated when handling a non urgent object.""" @@ -208,7 +208,7 @@ def test_classSchema_object(self): self.assertEquals(res["uSNHighest"], res["uSNUrgent"]) except LdbError: - print "Not testing urgent replication when creating classSchema object ...\n" + print("Not testing urgent replication when creating classSchema object ...\n") # urgent replication should be enabled when modifying m = Message() diff --git a/source4/dsdb/tests/python/user_account_control.py b/source4/dsdb/tests/python/user_account_control.py index e82c9557d87..79ddf83d747 100755 --- a/source4/dsdb/tests/python/user_account_control.py +++ b/source4/dsdb/tests/python/user_account_control.py @@ -102,7 +102,7 @@ def add_computer_ldap(self, computername, others=None, samdb=None): msg = ldb.Message.from_dict(self.samdb, msg_dict ) msg["sAMAccountName"] = samaccountname - print "Adding computer account %s" % computername + print("Adding computer account %s" % computername) samdb.add(msg) def get_creds(self, target_username, target_password): diff --git a/source4/dsdb/tests/python/vlv.py b/source4/dsdb/tests/python/vlv.py index d62d01db829..489197f6782 100644 --- a/source4/dsdb/tests/python/vlv.py +++ b/source4/dsdb/tests/python/vlv.py @@ -155,7 +155,7 @@ def setUp(self): try: self.ldb.delete(self.ou, ['tree_delete:1']) except ldb.LdbError as e: - print "tried deleting %s, got error %s" % (self.ou, e) + print("tried deleting %s, got error %s" % (self.ou, e)) self.ldb.add({ "dn": self.ou, "objectclass": "organizationalUnit"}) @@ -317,9 +317,9 @@ def get_gte_tests_and_order(self, attr, expression=None): gte_map[k] = len(expected_order) if False: - print "gte_map:" + print("gte_map:") for k in gte_order: - print " %10s => %10s" % (k, gte_map[k]) + print(" %10s => %10s" % (k, gte_map[k])) return gte_order, expected_order, gte_map @@ -340,14 +340,14 @@ def assertCorrectResults(self, results, expected_order, return if expected_order is not None: - print "expected order: %s" % expected_order[:20] + print("expected order: %s" % expected_order[:20]) if len(expected_order) > 20: - print "... and %d more not shown" % (len(expected_order) - 20) + print("... and %d more not shown" % (len(expected_order) - 20)) - print "offset %d before %d after %d" % (offset, before, after) - print "start %d end %d" % (start, end) - print "expected: %s" % expected_results - print "got : %s" % results + print("offset %d before %d after %d" % (offset, before, after)) + print("start %d end %d" % (start, end)) + print("expected: %s" % expected_results) + print("got : %s" % results) self.assertEquals(expected_results, results) def test_server_vlv_with_cookie(self): @@ -1005,10 +1005,10 @@ def test_server_vlv_gte_no_cookie(self): iteration += 1 if expected_results != results: middle = expected_order[len(expected_order) // 2] - print expected_results, results - print middle - print expected_order - print + print(expected_results, results) + print(middle) + print(expected_order) + print() print ("\nattr %s offset %d before %d " "after %d gte %s" % (attr, offset, before, after, gte)) From c845ef0688d29ea347d6183ce6c972a5f4eef0d8 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 13:59:50 +0000 Subject: [PATCH 05/14] s4/script: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- source4/script/depfilter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/script/depfilter.py b/source4/script/depfilter.py index 440b5604571..eaff2fe877a 100755 --- a/source4/script/depfilter.py +++ b/source4/script/depfilter.py @@ -9,7 +9,7 @@ import sys, sre if len(sys.argv) != 2: - print 'Usage: depfilter.py NODE' + print('Usage: depfilter.py NODE') sys.exit(1) top = sys.argv[1] @@ -41,10 +41,10 @@ def add_deps(node): # Generate output -print lines[0], +print(lines[0], end=' ') for key, value in subgraph.items(): for n in value: - print '\t"%s" -> "%s"' % (key, n) + print('\t"%s" -> "%s"' % (key, n)) -print lines[-1], +print(lines[-1], end=' ') From 5cbfe8fe4b99998eb2171f2ec4d346784df29ce7 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:00:28 +0000 Subject: [PATCH 06/14] s4/heimdal: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- source4/heimdal/lib/wind/gen-bidi.py | 2 +- source4/heimdal/lib/wind/gen-combining.py | 2 +- source4/heimdal/lib/wind/gen-errorlist.py | 4 ++-- source4/heimdal/lib/wind/gen-map.py | 6 +++--- source4/heimdal/lib/wind/gen-normalize.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source4/heimdal/lib/wind/gen-bidi.py b/source4/heimdal/lib/wind/gen-bidi.py index 21839c2550b..e2efcbb555a 100644 --- a/source4/heimdal/lib/wind/gen-bidi.py +++ b/source4/heimdal/lib/wind/gen-bidi.py @@ -42,7 +42,7 @@ import rfc3454 if len(sys.argv) != 3: - print "usage: %s rfc3454.txt outdir" % sys.argv[0] + print("usage: %s rfc3454.txt outdir" % sys.argv[0]) sys.exit(1) tables = rfc3454.read(sys.argv[1]) diff --git a/source4/heimdal/lib/wind/gen-combining.py b/source4/heimdal/lib/wind/gen-combining.py index 86cbc6d50f0..b22fdaa8e72 100644 --- a/source4/heimdal/lib/wind/gen-combining.py +++ b/source4/heimdal/lib/wind/gen-combining.py @@ -42,7 +42,7 @@ import UnicodeData if len(sys.argv) != 3: - print "usage: %s UnicodeData.txt out-dir" % sys.argv[0] + print("usage: %s UnicodeData.txt out-dir" % sys.argv[0]) sys.exit(1) ud = UnicodeData.read(sys.argv[1]) diff --git a/source4/heimdal/lib/wind/gen-errorlist.py b/source4/heimdal/lib/wind/gen-errorlist.py index f0b9524783b..d2cb0f9ac85 100644 --- a/source4/heimdal/lib/wind/gen-errorlist.py +++ b/source4/heimdal/lib/wind/gen-errorlist.py @@ -44,7 +44,7 @@ import stringprep if len(sys.argv) != 3: - print "usage: %s rfc3454.txt out-dir" % sys.argv[0] + print("usage: %s rfc3454.txt out-dir" % sys.argv[0]) sys.exit(1) tables = rfc3454.read(sys.argv[1]) @@ -104,7 +104,7 @@ (start, length, description, tables) = x symbols = stringprep.symbols(error_list, tables) if len(symbols) == 0: - print "no symbol for %s" % description + print("no symbol for %s" % description) sys.exit(1) errorlist_c.file.write(" {0x%x, 0x%x, %s}, /* %s: %s */\n" % (start, length, symbols, ",".join(tables), description)) diff --git a/source4/heimdal/lib/wind/gen-map.py b/source4/heimdal/lib/wind/gen-map.py index d4f02af1f29..dddca530bd7 100644 --- a/source4/heimdal/lib/wind/gen-map.py +++ b/source4/heimdal/lib/wind/gen-map.py @@ -45,7 +45,7 @@ import util if len(sys.argv) != 3: - print "usage: %s rfc3454.txt out-dir" % sys.argv[0] + print("usage: %s rfc3454.txt out-dir" % sys.argv[0]) sys.exit(1) tables = rfc3454.read(sys.argv[1]) @@ -114,7 +114,7 @@ for x in trans: if x[0] == 0xad: - print "fooresult %s" % ",".join(x[3]) + print("fooresult %s" % ",".join(x[3])) for x in trans: (key, value, description, table) = x @@ -130,7 +130,7 @@ (key, value, description, tables) = x symbols = stringprep.symbols(map_list, tables) if len(symbols) == 0: - print "no symbol for %s %s (%s)" % (key, description, tables) + print("no symbol for %s %s (%s)" % (key, description, tables)) sys.exit(1) v = value.split() map_c.file.write(" {0x%x, %u, %u, %s}, /* %s: %s */\n" diff --git a/source4/heimdal/lib/wind/gen-normalize.py b/source4/heimdal/lib/wind/gen-normalize.py index 9b3553c46d0..8adeca754d5 100644 --- a/source4/heimdal/lib/wind/gen-normalize.py +++ b/source4/heimdal/lib/wind/gen-normalize.py @@ -43,7 +43,7 @@ import util if len(sys.argv) != 4: - print "usage: %s UnicodeData.txt" + print("usage: %s UnicodeData.txt") " CompositionExclusions-3.2.0.txt out-dir" % sys.argv[0] sys.exit(1) From f079096e079aacc59727c7ea8bb0ce0380b6808f Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:01:17 +0000 Subject: [PATCH 07/14] s4/scripting: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- source4/scripting/bin/gen_hresult.py | 6 +-- source4/scripting/bin/gen_ntstatus.py | 2 +- source4/scripting/bin/w32err_code.py | 12 +++--- source4/scripting/devel/demodirsync.py | 58 +++++++++++++-------------- source4/scripting/devel/pfm_verify.py | 14 +++---- source4/scripting/devel/repl_cleartext_pwd.py | 6 +-- source4/scripting/devel/speedtest.py | 24 +++++------ 7 files changed, 61 insertions(+), 61 deletions(-) diff --git a/source4/scripting/bin/gen_hresult.py b/source4/scripting/bin/gen_hresult.py index d80903390c4..67d4f9edbba 100755 --- a/source4/scripting/bin/gen_hresult.py +++ b/source4/scripting/bin/gen_hresult.py @@ -63,7 +63,7 @@ def parseErrorDescriptions( input_file, isWinError ): Errors.append(newError) else: if len(Errors) == 0: - print "Error parsing file as line %d"%count + print("Error parsing file as line %d"%count) sys.exit() err = Errors[-1] if err.err_define == None: @@ -78,7 +78,7 @@ def parseErrorDescriptions( input_file, isWinError ): err.err_string = err.err_string + " " + desc count = count + 1 fileContents.close() - print "parsed %d lines generated %d error definitions"%(count,len(Errors)) + print("parsed %d lines generated %d error definitions"%(count,len(Errors))) def write_license(out_file): out_file.write("/*\n") @@ -213,7 +213,7 @@ def main (): if len(sys.argv) > 1: input_file1 = sys.argv[1] else: - print "usage: %s winerrorfile"%(sys.argv[0]) + print("usage: %s winerrorfile"%(sys.argv[0])) sys.exit() parseErrorDescriptions(input_file1, False) diff --git a/source4/scripting/bin/gen_ntstatus.py b/source4/scripting/bin/gen_ntstatus.py index cace4c08ce5..91c3b288d79 100755 --- a/source4/scripting/bin/gen_ntstatus.py +++ b/source4/scripting/bin/gen_ntstatus.py @@ -130,7 +130,7 @@ def main (): gen_sourcefile_name = sys.argv[3] gen_pythonfile_name = sys.argv[4] else: - print("usage: %s winerrorfile headerfile sourcefile pythonfile" % (sys.argv[0])) + print(("usage: %s winerrorfile headerfile sourcefile pythonfile" % (sys.argv[0]))) sys.exit() # read in the data diff --git a/source4/scripting/bin/w32err_code.py b/source4/scripting/bin/w32err_code.py index 6687c8222a0..bf20a396278 100755 --- a/source4/scripting/bin/w32err_code.py +++ b/source4/scripting/bin/w32err_code.py @@ -100,9 +100,9 @@ def parse_url(self, url): # print skipped errors if self.opt.print_skipped and len(self._errors_skipped): - print "\nErrors skipped during HTML parsing:" + print("\nErrors skipped during HTML parsing:") pprint.pprint(self._errors_skipped) - print "\n" + print("\n") return errors @@ -114,7 +114,7 @@ def _load_url(self, url): html_str += line.strip() fp.close() except IOError as e: - print "error loading url: " + e.strerror + print("error loading url: " + e.strerror) pass # currently ERROR codes are rendered as table @@ -244,12 +244,12 @@ def generate(self, errors): (defined_errors, no_value_errors) = werr_parser.load_err_codes(self.opt.werror_file) if not defined_errors: - print "\nUnable to load existing errors file: %s" % self.opt.werror_file + print("\nUnable to load existing errors file: %s" % self.opt.werror_file) sys.exit(1) if self.opt.verbose and len(no_value_errors): - print "\nWarning: there are errors defines using macro value:" + print("\nWarning: there are errors defines using macro value:") pprint.pprint(no_value_errors) - print "" + print("") # filter generated error codes (new_errors, diff_code_errors, diff --git a/source4/scripting/devel/demodirsync.py b/source4/scripting/devel/demodirsync.py index 41dac6ff517..0f308f8c350 100755 --- a/source4/scripting/devel/demodirsync.py +++ b/source4/scripting/devel/demodirsync.py @@ -30,14 +30,14 @@ def printdirsync(ctl): arr = ctl.split(':') if arr[0] == 'dirsync': - print "Need to continue: %s" % arr[1] + print("Need to continue: %s" % arr[1]) cookie = ndr_unpack(drsblobs.ldapControlDirSyncCookie, base64.b64decode(arr[3])) - print "DC's NTDS guid: %s " % cookie.blob.guid1 - print "highest usn %s" % cookie.blob.highwatermark.highest_usn - print "tmp higest usn %s" % cookie.blob.highwatermark.tmp_highest_usn - print "reserved usn %s" % cookie.blob.highwatermark.reserved_usn + print("DC's NTDS guid: %s " % cookie.blob.guid1) + print("highest usn %s" % cookie.blob.highwatermark.highest_usn) + print("tmp higest usn %s" % cookie.blob.highwatermark.tmp_highest_usn) + print("reserved usn %s" % cookie.blob.highwatermark.reserved_usn) if cookie.blob.extra_length >0: - print "highest usn in extra %s" % cookie.blob.extra.ctr.cursors[0].highest_usn + print("highest usn in extra %s" % cookie.blob.extra.ctr.cursors[0].highest_usn) return cookie remote_ldb= Ldb("ldap://" + opts.host + ":389", credentials=creds, lp=lp) @@ -57,36 +57,36 @@ def printdirsync(ctl): guid = cookie.blob.guid1 pass if not guid: - print "No dirsync control ... strange" + print("No dirsync control ... strange") sys.exit(1) -print "" -print "Getting first guest without any cookie" +print("") +print("Getting first guest without any cookie") (msgs, ctrls) = remote_ldb.searchex(expression="(samaccountname=guest)", base=base, attrs=["objectClass"], controls=["dirsync:1:1:50"]) cookie = None if (len(ctrls)): for ctl in ctrls: cookie = printdirsync(ctl) - print "Returned %d entries" % len(msgs) + print("Returned %d entries" % len(msgs)) savedcookie = cookie -print "" -print "Getting allusers with cookie" +print("") +print("Getting allusers with cookie") controls=["dirsync:1:1:50:%s" % base64.b64encode(ndr_pack(cookie))] (msgs, ctrls) = remote_ldb.searchex(expression="(samaccountname=*)", base=base, attrs=["objectClass"], controls=controls) if (len(ctrls)): for ctl in ctrls: cookie = printdirsync(ctl) - print "Returned %d entries" % len(msgs) + print("Returned %d entries" % len(msgs)) cookie = savedcookie cookie.blob.guid1 = misc.GUID("128a99bf-e2df-4832-ac0a-1fb625e530db") if cookie.blob.extra_length > 0: cookie.blob.extra.ctr.cursors[0].source_dsa_invocation_id = misc.GUID("128a99bf-e2df-4832-ac0a-1fb625e530db") -print "" -print "Getting all the entries" +print("") +print("Getting all the entries") controls=["dirsync:1:1:50:%s" % base64.b64encode(ndr_pack(cookie))] (msgs, ctrls) = remote_ldb.searchex(expression="(objectclass=*)", base=base, controls=controls) cont = 0 @@ -95,7 +95,7 @@ def printdirsync(ctl): cookie = printdirsync(ctl) if cookie != None: cont = (ctl.split(':'))[1] - print "Returned %d entries" % len(msgs) + print("Returned %d entries" % len(msgs)) usn = cookie.blob.highwatermark.tmp_highest_usn if cookie.blob.extra_length > 0: @@ -103,7 +103,7 @@ def printdirsync(ctl): else: bigusn = usn + 1000 while (cont == "1"): - print "" + print("") controls=["dirsync:1:1:50:%s" % base64.b64encode(ndr_pack(cookie))] (msgs, ctrls) = remote_ldb.searchex(expression="(objectclass=*)", base=base, controls=controls) if (len(ctrls)): @@ -111,25 +111,25 @@ def printdirsync(ctl): cookie = printdirsync(ctl) if cookie != None: cont = (ctl.split(':'))[1] - print "Returned %d entries" % len(msgs) + print("Returned %d entries" % len(msgs)) -print "" -print "Getting with cookie but usn changed to %d we should use the one in extra" % (bigusn - 1) +print("") +print("Getting with cookie but usn changed to %d we should use the one in extra" % (bigusn - 1)) cookie.blob.highwatermark.highest_usn = 0 cookie.blob.highwatermark.tmp_highest_usn = usn - 2 if cookie.blob.extra_length > 0: - print "here" + print("here") cookie.blob.extra.ctr.cursors[0].highest_usn = bigusn - 1 controls=["dirsync:1:1:50:%s" % base64.b64encode(ndr_pack(cookie))] (msgs, ctrls) = remote_ldb.searchex(expression="(objectclass=*)", base=base, controls=controls) if (len(ctrls)): for ctl in ctrls: cookie = printdirsync(ctl) - print "Returned %d entries" % len(msgs) + print("Returned %d entries" % len(msgs)) -print "" -print "Getting with cookie but usn %d changed and extra/cursor GUID too" % (usn - 2) -print " so that it's (tmp)highest_usn that drives the limit" +print("") +print("Getting with cookie but usn %d changed and extra/cursor GUID too" % (usn - 2)) +print(" so that it's (tmp)highest_usn that drives the limit") cookie.blob.highwatermark.highest_usn = 0 cookie.blob.highwatermark.tmp_highest_usn = usn - 2 if cookie.blob.extra_length > 0: @@ -140,10 +140,10 @@ def printdirsync(ctl): if (len(ctrls)): for ctl in ctrls: cookie = printdirsync(ctl) - print "Returned %d entries" % len(msgs) + print("Returned %d entries" % len(msgs)) -print "" -print "Getting with cookie but usn changed to %d" % (usn - 2) +print("") +print("Getting with cookie but usn changed to %d" % (usn - 2)) cookie.blob.highwatermark.highest_usn = 0 cookie.blob.highwatermark.tmp_highest_usn = (usn - 2) if cookie.blob.extra_length > 0: @@ -153,4 +153,4 @@ def printdirsync(ctl): if (len(ctrls)): for ctl in ctrls: cookie = printdirsync(ctl) - print "Returned %d entries" % len(msgs) + print("Returned %d entries" % len(msgs)) diff --git a/source4/scripting/devel/pfm_verify.py b/source4/scripting/devel/pfm_verify.py index 2b54aadeb41..f236c7a395e 100755 --- a/source4/scripting/devel/pfm_verify.py +++ b/source4/scripting/devel/pfm_verify.py @@ -65,7 +65,7 @@ def _drs_fetch_pfm(server, samdb, creds, lp): drs = drsuapi.drsuapi(binding_str, lp, creds) (drs_handle, supported_extensions) = drs_DsBind(drs) - print "DRS Handle: %s" % drs_handle + print("DRS Handle: %s" % drs_handle) req8 = drsuapi.DsGetNCChangesRequest8() @@ -128,8 +128,8 @@ def _pfm_verify(drs_pfm, ldb_pfm): def _pfm_schi_verify(drs_schi, ldb_schi): errors = [] - print drs_schi.revision - print drs_schi.invocation_id + print(drs_schi.revision) + print(drs_schi.invocation_id) if drs_schi.marker != ldb_schi.marker: errors.append("Different marker in schemaInfo: drs = %d, ldb = %d" % (drs_schi.marker, ldb_schi.marker)) @@ -177,14 +177,14 @@ def _pfm_schi_verify(drs_schi, ldb_schi): # verify prefixMaps errors = _pfm_verify(drs_pfm, ldb_pfm) if len(errors): - print "prefixMap verification errors:" - print "%s" % errors + print("prefixMap verification errors:") + print("%s" % errors) exit_code = 1 # verify schemaInfos errors = _pfm_schi_verify(drs_schi, ldb_schi) if len(errors): - print "schemaInfo verification errors:" - print "%s" % errors + print("schemaInfo verification errors:") + print("%s" % errors) exit_code = 2 if exit_code != 0: diff --git a/source4/scripting/devel/repl_cleartext_pwd.py b/source4/scripting/devel/repl_cleartext_pwd.py index 9637d885e08..370cac55515 100755 --- a/source4/scripting/devel/repl_cleartext_pwd.py +++ b/source4/scripting/devel/repl_cleartext_pwd.py @@ -232,7 +232,7 @@ def attid_equal(a1,a2): user_session_key = drs_conn.user_session_key - print "# starting at usn[%d]" % (highwatermark.highest_usn) + print("# starting at usn[%d]" % (highwatermark.highest_usn)) while True: (level, ctr) = drs_conn.DsGetNCChanges(drs_handle, 8, req8) @@ -403,7 +403,7 @@ def attid_equal(a1,a2): f.close() os.rename(tmp_file, cookie_file) - print "# up to usn[%d]" % (ctr.new_highwatermark.highest_usn) + print("# up to usn[%d]" % (ctr.new_highwatermark.highest_usn)) break - print "# up to tmp_usn[%d]" % (ctr.new_highwatermark.highest_usn) + print("# up to tmp_usn[%d]" % (ctr.new_highwatermark.highest_usn)) req8.highwatermark = ctr.new_highwatermark diff --git a/source4/scripting/devel/speedtest.py b/source4/scripting/devel/speedtest.py index 581966b6174..789f801ff75 100755 --- a/source4/scripting/devel/speedtest.py +++ b/source4/scripting/devel/speedtest.py @@ -83,7 +83,7 @@ def setUp(self): self.base_dn = ldb.domain_dn() self.domain_sid = security.dom_sid(ldb.get_domain_sid()) self.user_pass = "samba123@" - print "baseDN: %s" % self.base_dn + print("baseDN: %s" % self.base_dn) def create_user(self, user_dn): ldif = """ @@ -125,7 +125,7 @@ def setUp(self): super(SpeedTestAddDel, self).setUp() def run_bundle(self, num): - print "\n=== Test ADD/DEL %s user objects ===\n" % num + print("\n=== Test ADD/DEL %s user objects ===\n" % num) avg_add = Decimal("0.0") avg_del = Decimal("0.0") for x in [1, 2, 3]: @@ -133,16 +133,16 @@ def run_bundle(self, num): self.create_bundle(num) res_add = Decimal( str(time.time() - start) ) avg_add += res_add - print " Attempt %s ADD: %.3fs" % ( x, float(res_add) ) + print(" Attempt %s ADD: %.3fs" % ( x, float(res_add) )) # start = time.time() self.remove_bundle(num) res_del = Decimal( str(time.time() - start) ) avg_del += res_del - print " Attempt %s DEL: %.3fs" % ( x, float(res_del) ) - print "Average ADD: %.3fs" % float( Decimal(avg_add) / Decimal("3.0") ) - print "Average DEL: %.3fs" % float( Decimal(avg_del) / Decimal("3.0") ) - print "" + print(" Attempt %s DEL: %.3fs" % ( x, float(res_del) )) + print("Average ADD: %.3fs" % float( Decimal(avg_add) / Decimal("3.0") )) + print("Average DEL: %.3fs" % float( Decimal(avg_del) / Decimal("3.0") )) + print("") def test_00000(self): """ Remove possibly undeleted test users from previous test @@ -178,22 +178,22 @@ def tearDown(self): delete_force(self.ldb_admin, self.get_user_dn("acltestuser")) def run_search_bundle(self, num, _ldb): - print "\n=== Creating %s user objects ===\n" % num + print("\n=== Creating %s user objects ===\n" % num) self.create_bundle(num) mod = "(A;;LC;;;%s)(D;;RP;;;%s)" % (str(self.user_sid), str(self.user_sid)) for i in range(num): self.sd_utils.dacl_add_ace("cn=speedtestuser%d,cn=Users,%s" % (i+1, self.base_dn), mod) - print "\n=== %s user objects created ===\n" % num - print "\n=== Test search on %s user objects ===\n" % num + print("\n=== %s user objects created ===\n" % num) + print("\n=== Test search on %s user objects ===\n" % num) avg_search = Decimal("0.0") for x in [1, 2, 3]: start = time.time() res = _ldb.search(base=self.base_dn, expression="(objectClass=*)", scope=SCOPE_SUBTREE) res_search = Decimal( str(time.time() - start) ) avg_search += res_search - print " Attempt %s SEARCH: %.3fs" % ( x, float(res_search) ) - print "Average Search: %.3fs" % float( Decimal(avg_search) / Decimal("3.0") ) + print(" Attempt %s SEARCH: %.3fs" % ( x, float(res_search) )) + print("Average Search: %.3fs" % float( Decimal(avg_search) / Decimal("3.0") )) self.remove_bundle(num) def get_user_dn(self, name): From 88cc146fc3f72b3151b005e8240f2ed0827de77e Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:02:18 +0000 Subject: [PATCH 08/14] s4/torture/drs: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- source4/torture/drs/python/delete_object.py | 4 +-- source4/torture/drs/python/drs_base.py | 14 ++++---- source4/torture/drs/python/fsmo.py | 6 ++-- source4/torture/drs/python/getncchanges.py | 2 +- source4/torture/drs/python/repl_move.py | 34 +++++++++--------- source4/torture/drs/python/replica_sync.py | 56 ++++++++++++++--------------- 6 files changed, 58 insertions(+), 58 deletions(-) diff --git a/source4/torture/drs/python/delete_object.py b/source4/torture/drs/python/delete_object.py index 620a44659e7..a5506a046b4 100644 --- a/source4/torture/drs/python/delete_object.py +++ b/source4/torture/drs/python/delete_object.py @@ -121,7 +121,7 @@ def test_ReplicateDeletedObject1(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) # trigger replication from DC1 to DC2 @@ -277,7 +277,7 @@ def test_ReplicateDeletedObject2(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) # trigger replication from DC1 to DC2 diff --git a/source4/torture/drs/python/drs_base.py b/source4/torture/drs/python/drs_base.py index 66a0d8d6d77..7a91e79f694 100644 --- a/source4/torture/drs/python/drs_base.py +++ b/source4/torture/drs/python/drs_base.py @@ -251,7 +251,7 @@ def _ctr6_debug(self, ctr6): next_object = ctr6.first_object for i in range(0, ctr6.object_count): - print("Obj %d: %s %s" %(i, next_object.object.identifier.dn[:25], + print(("Obj %d: %s %s" %(i, next_object.object.identifier.dn[:25], next_object.object.identifier.guid)) next_object = next_object.next_object @@ -511,19 +511,19 @@ def __internal_cmp__(self, other, verbose=False): """See CompareLinks() in MS-DRSR section 4.1.10.5.17""" if not isinstance(other, AbstractLink): if verbose: - print "AbstractLink.__internal_cmp__(%r, %r) => wrong type" % (self, other) + print("AbstractLink.__internal_cmp__(%r, %r) => wrong type" % (self, other)) return NotImplemented c = cmp(self.selfGUID_blob, other.selfGUID_blob) if c != 0: if verbose: - print "AbstractLink.__internal_cmp__(%r, %r) => %d different identifier" % (self, other, c) + print("AbstractLink.__internal_cmp__(%r, %r) => %d different identifier" % (self, other, c)) return c c = other.attid - self.attid if c != 0: if verbose: - print "AbstractLink.__internal_cmp__(%r, %r) => %d different attid" % (self, other, c) + print("AbstractLink.__internal_cmp__(%r, %r) => %d different attid" % (self, other, c)) return c self_active = self.flags & drsuapi.DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE @@ -532,19 +532,19 @@ def __internal_cmp__(self, other, verbose=False): c = self_active - other_active if c != 0: if verbose: - print "AbstractLink.__internal_cmp__(%r, %r) => %d different FLAG_ACTIVE" % (self, other, c) + print("AbstractLink.__internal_cmp__(%r, %r) => %d different FLAG_ACTIVE" % (self, other, c)) return c c = cmp(self.targetGUID_blob, other.targetGUID_blob) if c != 0: if verbose: - print "AbstractLink.__internal_cmp__(%r, %r) => %d different target" % (self, other, c) + print("AbstractLink.__internal_cmp__(%r, %r) => %d different target" % (self, other, c)) return c c = self.flags - other.flags if c != 0: if verbose: - print "AbstractLink.__internal_cmp__(%r, %r) => %d different flags" % (self, other, c) + print("AbstractLink.__internal_cmp__(%r, %r) => %d different flags" % (self, other, c)) return c return 0 diff --git a/source4/torture/drs/python/fsmo.py b/source4/torture/drs/python/fsmo.py index 50b7dc3b2c4..7511100ee07 100644 --- a/source4/torture/drs/python/fsmo.py +++ b/source4/torture/drs/python/fsmo.py @@ -98,7 +98,7 @@ def _role_transfer(self, role, role_dn): """Triggers transfer of role from DC1 to DC2 and vice versa so the role goes back to the original dc""" # dc2 gets the role from dc1 - print "Testing for %s role transfer from %s to %s" % (role, self.dnsname_dc1, self.dnsname_dc2) + print("Testing for %s role transfer from %s to %s" % (role, self.dnsname_dc1, self.dnsname_dc2)) self._net_fsmo_role_transfer(DC=self.dnsname_dc2, role=role) # check if the role is transfered @@ -109,7 +109,7 @@ def _role_transfer(self, role, role_dn): "Transferring %s role to %s has failed, master is: %s!"%(role, self.dsServiceName_dc2, master)) # dc1 gets back the role from dc2 - print "Testing for %s role transfer from %s to %s" % (role, self.dnsname_dc2, self.dnsname_dc1) + print("Testing for %s role transfer from %s to %s" % (role, self.dnsname_dc2, self.dnsname_dc1)) self._net_fsmo_role_transfer(DC=self.dnsname_dc1, role=role) # check if the role is transfered (res, master) = self._wait_for_role_transfer(ldb_dc=self.ldb_dc1, @@ -119,7 +119,7 @@ def _role_transfer(self, role, role_dn): "Transferring %s role to %s has failed, master is: %s!"%(role, self.dsServiceName_dc1, master)) # dc1 keeps the role - print "Testing for no-op %s role transfer from %s to %s" % (role, self.dnsname_dc2, self.dnsname_dc1) + print("Testing for no-op %s role transfer from %s to %s" % (role, self.dnsname_dc2, self.dnsname_dc1)) self._net_fsmo_role_transfer(DC=self.dnsname_dc1, role=role, noop=True) # check if the role is transfered (res, master) = self._wait_for_role_transfer(ldb_dc=self.ldb_dc1, diff --git a/source4/torture/drs/python/getncchanges.py b/source4/torture/drs/python/getncchanges.py index b60ec533c9a..43f7f57d570 100644 --- a/source4/torture/drs/python/getncchanges.py +++ b/source4/torture/drs/python/getncchanges.py @@ -296,7 +296,7 @@ def repl_get_next(self, get_anc=False, get_tgt=False, assert_links=False): # we receive the parents before the child self.assertFalse(get_anc, "Unknown parent for object %s" % dn) - print("Unknown parent for %s - try GET_ANC" % dn) + print("Unknown parent for %s - try GET_ANC" % d) # try the same thing again with the GET_ANC flag set this time return self.repl_get_next(get_anc=True, get_tgt=get_tgt, diff --git a/source4/torture/drs/python/repl_move.py b/source4/torture/drs/python/repl_move.py index 43a6caece82..897453df1eb 100644 --- a/source4/torture/drs/python/repl_move.py +++ b/source4/torture/drs/python/repl_move.py @@ -275,7 +275,7 @@ def test_ReplicateMoveObject1(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) initial_metadata = [ (DRSUAPI_ATTID_objectClass, self.dc1_guid, 1), (DRSUAPI_ATTID_cn, self.dc1_guid, 1), @@ -548,7 +548,7 @@ def test_ReplicateMoveObject2(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) initial_metadata = [ (DRSUAPI_ATTID_objectClass, self.dc1_guid, 1), (DRSUAPI_ATTID_cn, self.dc1_guid, 1), @@ -730,7 +730,7 @@ def test_ReplicateMoveObject3(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) initial_metadata = [ (DRSUAPI_ATTID_objectClass, self.dc1_guid, 1), (DRSUAPI_ATTID_cn, self.dc1_guid, 1), @@ -910,7 +910,7 @@ def test_ReplicateMoveObject3b(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) initial_metadata = [ (DRSUAPI_ATTID_objectClass, self.dc1_guid, 1), (DRSUAPI_ATTID_cn, self.dc1_guid, 1), @@ -1091,7 +1091,7 @@ def test_ReplicateMoveObject4(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) initial_metadata = [ (DRSUAPI_ATTID_objectClass, self.dc1_guid, 1), (DRSUAPI_ATTID_cn, self.dc1_guid, 1), @@ -1419,7 +1419,7 @@ def test_ReplicateMoveObject5(self): user_cur = self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) new_dn = ldb.Dn(self.ldb_dc1, "CN=%s" % username) @@ -1480,7 +1480,7 @@ def test_ReplicateMoveObject6(self): ou_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=ou_orig, is_deleted=False) # trigger replication from DC1 to DC2 @@ -1546,7 +1546,7 @@ def test_ReplicateMoveObject7(self): ou_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=ou_orig, is_deleted=False) # trigger replication from DC1 to DC2 @@ -1612,7 +1612,7 @@ def test_ReplicateMoveObject8(self): ou_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=ou_orig, is_deleted=False) # trigger replication from DC1 to DC2 @@ -1679,7 +1679,7 @@ def test_ReplicateMoveObject9(self): ou_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=ou_orig, is_deleted=False) # trigger replication from DC1 to DC2 @@ -1745,7 +1745,7 @@ def test_ReplicateMoveObject10(self): ou_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=ou_orig, is_deleted=False) # trigger replication from DC1 to DC2 @@ -1794,7 +1794,7 @@ def test_ReplicateMoveObject11(self): ou_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (self.ou1_dn, self._GUID_string(ou_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=ou_orig, is_deleted=False) # trigger replication from DC1 to DC2 @@ -1958,7 +1958,7 @@ def test_ReplicateMoveInTree1(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) self.ldb_dc1.add(self.ou2) @@ -2014,7 +2014,7 @@ def test_ReplicateMoveInTree2(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) self.ldb_dc1.add(self.ou2) @@ -2108,7 +2108,7 @@ def test_ReplicateMoveInTree3(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) self.ldb_dc1.add(self.ou2) @@ -2197,7 +2197,7 @@ def test_ReplicateMoveInTree3b(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) self.ldb_dc1.add(self.ou2) @@ -2297,7 +2297,7 @@ def test_ReplicateMoveInTree4(self): user_dn = ldb_res[0]["dn"] # check user info on DC1 - print "Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0])) + print("Testing for %s with GUID %s" % (username, self._GUID_string(user_orig["objectGUID"][0]))) self._check_obj(sam_ldb=self.ldb_dc1, obj_orig=user_orig, is_deleted=False) self.ldb_dc1.add(self.ou2) diff --git a/source4/torture/drs/python/replica_sync.py b/source4/torture/drs/python/replica_sync.py index fe013e63259..144db59ba2d 100644 --- a/source4/torture/drs/python/replica_sync.py +++ b/source4/torture/drs/python/replica_sync.py @@ -155,8 +155,8 @@ def test_ReplConflictsFullSync(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc2.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertFalse('CNF:%s' % self.ou2 in str(res2[0]["name"][0])) self.assertTrue('CNF:%s' % self.ou1 in str(res1[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc2, self.domain_dn) not in str(res1[0].dn)) @@ -195,8 +195,8 @@ def test_ReplConflictsRemoteWin(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou1 in str(res1[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res2[0].dn)) @@ -234,8 +234,8 @@ def test_ReplConflictsLocalWin(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou2 in str(res2[0]["name"][0]), "Got %s for %s" % (str(res2[0]["name"][0]), self.ou2)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res2[0].dn)) @@ -276,8 +276,8 @@ def test_ReplConflictsRemoteWin_with_child(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou1 in str(res1[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res2[0].dn)) @@ -325,8 +325,8 @@ def test_ReplConflictsRenamedVsNewRemoteWin(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou1 in str(res1[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res2[0].dn)) @@ -364,8 +364,8 @@ def test_ReplConflictsRenamedVsNewLocalWin(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou2 in str(res2[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res2[0].dn)) @@ -407,8 +407,8 @@ def test_ReplConflictsRenameRemoteWin(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou1 in str(res1[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res2[0].dn)) @@ -455,8 +455,8 @@ def test_ReplConflictsRenameRemoteWin_with_child(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou1 in str(res1[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res2[0].dn)) @@ -506,8 +506,8 @@ def test_ReplConflictsRenameLocalWin(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou2 in str(res2[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) not in str(res2[0].dn)) @@ -558,8 +558,8 @@ def test_ReplLostAndFound(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % ou2_child, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % ou1_child in str(res1[0]["name"][0]) or 'CNF:%s' % ou2_child in str(res2[0]["name"][0])) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) in str(res1[0].dn)) self.assertTrue(self._lost_and_found_dn(self.ldb_dc1, self.domain_dn) in str(res2[0].dn)) @@ -625,9 +625,9 @@ def test_ReplRenames(self): scope=SCOPE_BASE, attrs=["name"]) res3 = self.ldb_dc2.search(base="" % ou3_child, scope=SCOPE_BASE, attrs=["name"]) - print res1[0].dn - print res2[0].dn - print res3[0].dn + print(res1[0].dn) + print(res2[0].dn) + print(res3[0].dn) self.assertEqual('Test Child 2', res1[0]["name"][0]) self.assertEqual('Test Child', res2[0]["name"][0]) self.assertEqual('Test CASE Child', res3[0]["name"][0]) @@ -645,9 +645,9 @@ def test_ReplRenames(self): scope=SCOPE_BASE, attrs=["name"]) res3 = self.ldb_dc1.search(base="" % ou3_child, scope=SCOPE_BASE, attrs=["name"]) - print res1[0].dn - print res2[0].dn - print res3[0].dn + print(res1[0].dn) + print(res2[0].dn) + print(res3[0].dn) self.assertEqual('Test Child 2', res1[0]["name"][0]) self.assertEqual('Test Child', res2[0]["name"][0]) self.assertEqual('Test CASE Child', res3[0]["name"][0]) @@ -723,8 +723,8 @@ def test_ReplReanimationConflict(self): scope=SCOPE_BASE, attrs=["name"]) res2 = self.ldb_dc1.search(base="" % self.ou2, scope=SCOPE_BASE, attrs=["name"]) - print res1[0]["name"][0] - print res2[0]["name"][0] + print(res1[0]["name"][0]) + print(res2[0]["name"][0]) self.assertTrue('CNF:%s' % self.ou1 in str(res1[0]["name"][0])) self.assertFalse('CNF:%s' % self.ou2 in str(res2[0]["name"][0])) From b1956c8a0e8528880ba4ea42d548c31df369d49f Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:02:52 +0000 Subject: [PATCH 09/14] s4/selftest: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- source4/selftest/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index ef752a51cdf..9b3a16dce93 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -23,7 +23,7 @@ import selftesthelpers from selftesthelpers import * -print >>sys.stderr, "OPTIONS %s" % " ".join(smbtorture4_options) +print("OPTIONS %s" % " ".join(smbtorture4_options), file=sys.stderr) def plansmbtorture4testsuite(name, env, options, modname=None): return selftesthelpers.plansmbtorture4testsuite(name, env, options, From 8c6e438bc2dfdb0af7041545b89150f0edead6a4 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:03:29 +0000 Subject: [PATCH 10/14] selftest: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- selftest/selftesthelpers.py | 20 ++++++++++---------- selftest/subunithelper.py | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py index 8b885b59419..3501cce1fbc 100644 --- a/selftest/selftesthelpers.py +++ b/selftest/selftesthelpers.py @@ -66,18 +66,18 @@ def plantestsuite(name, env, cmdline): :param env: Environment to run the testsuite in :param cmdline: Command line to run """ - print "-- TEST --" + print("-- TEST --") if env == "none": fullname = name else: fullname = "%s(%s)" % (name, env) - print fullname - print env + print(fullname) + print(env) if isinstance(cmdline, list): cmdline = " ".join(cmdline) if "$LISTOPT" in cmdline: raise AssertionError("test %s supports --list, but not --load-list" % name) - print cmdline + " 2>&1 " + " | " + add_prefix(name, env) + print(cmdline + " 2>&1 " + " | " + add_prefix(name, env)) def add_prefix(prefix, env, support_list=False): @@ -89,13 +89,13 @@ def add_prefix(prefix, env, support_list=False): def plantestsuite_loadlist(name, env, cmdline): - print "-- TEST-LOADLIST --" + print("-- TEST-LOADLIST --") if env == "none": fullname = name else: fullname = "%s(%s)" % (name, env) - print fullname - print env + print(fullname) + print(env) if isinstance(cmdline, list): cmdline = " ".join(cmdline) support_list = ("$LISTOPT" in cmdline) @@ -103,8 +103,8 @@ def plantestsuite_loadlist(name, env, cmdline): raise AssertionError("loadlist test %s does not support not --list" % name) if not "$LOADLIST" in cmdline: raise AssertionError("loadlist test %s does not support --load-list" % name) - print ("%s | %s" % (cmdline.replace("$LOADLIST", ""), add_prefix(name, env, support_list))).replace("$LISTOPT", "--list") - print cmdline.replace("$LISTOPT", "") + " 2>&1 " + " | " + add_prefix(name, env, False) + print(("%s | %s" % (cmdline.replace("$LOADLIST", ""), add_prefix(name, env, support_list))).replace("$LISTOPT", "--list")) + print(cmdline.replace("$LISTOPT", "") + " 2>&1 " + " | " + add_prefix(name, env, False)) def skiptestsuite(name, reason): @@ -114,7 +114,7 @@ def skiptestsuite(name, reason): :param reason: Reason the test suite was skipped """ # FIXME: Report this using subunit, but re-adjust the testsuite count somehow - print >>sys.stderr, "skipping %s (%s)" % (name, reason) + print("skipping %s (%s)" % (name, reason), file=sys.stderr) def planperltestsuite(name, path): diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index bcd25ffc8b5..c86ededcada 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -65,7 +65,7 @@ def parse_results(msg_ops, statistics, fh): try: dt = iso8601.parse_date(arg.rstrip("\n")) except TypeError as e: - print "Unable to parse time line: %s" % arg.rstrip("\n") + print("Unable to parse time line: %s" % arg.rstrip("\n")) else: msg_ops.time(dt) elif command in VALID_RESULTS: @@ -600,7 +600,7 @@ def end_testsuite(self, name, result, reason): unexpected = False if not name in self.test_output: - print "no output for name[%s]" % name + print("no output for name[%s]" % name) if result in ("success", "xfail"): self.suites_ok+=1 @@ -686,11 +686,11 @@ def write_summary(self, path): if not self.immediate and not self.verbose: for suite in self.suitesfailed: - print "=" * 78 - print "FAIL: %s" % suite + print("=" * 78) + print("FAIL: %s" % suite) if suite in self.test_output: - print self.test_output[suite] - print "" + print(self.test_output[suite]) + print("") f.write("= Skipped tests =\n") for reason in self.skips.keys(): @@ -706,13 +706,13 @@ def write_summary(self, path): not self.statistics['TESTS_ERROR']): ok = (self.statistics['TESTS_EXPECTED_OK'] + self.statistics['TESTS_EXPECTED_FAIL']) - print "\nALL OK (%d tests in %d testsuites)" % (ok, self.suites_ok) + print("\nALL OK (%d tests in %d testsuites)" % (ok, self.suites_ok)) else: - print "\nFAILED (%d failures, %d errors and %d unexpected successes in %d testsuites)" % ( + print("\nFAILED (%d failures, %d errors and %d unexpected successes in %d testsuites)" % ( self.statistics['TESTS_UNEXPECTED_FAIL'], self.statistics['TESTS_ERROR'], self.statistics['TESTS_UNEXPECTED_OK'], - len(self.suitesfailed)) + len(self.suitesfailed))) def skip_testsuite(self, name, reason="UNKNOWN"): self.skips.setdefault(reason, []).append(name) From c1a7b9bf556e83ed8e3df99669c6741d23075f43 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:04:29 +0000 Subject: [PATCH 11/14] s3/script/tests: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- source3/script/tests/test_wbinfo_sids2xids_int.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source3/script/tests/test_wbinfo_sids2xids_int.py b/source3/script/tests/test_wbinfo_sids2xids_int.py index 21804452365..7b62e47c1af 100755 --- a/source3/script/tests/test_wbinfo_sids2xids_int.py +++ b/source3/script/tests/test_wbinfo_sids2xids_int.py @@ -4,7 +4,7 @@ if len(sys.argv) != 3: - print "Usage: test_wbinfo_sids2xids_int.py wbinfo net" + print("Usage: test_wbinfo_sids2xids_int.py wbinfo net") sys.exit(1) wbinfo = sys.argv[1] @@ -78,7 +78,7 @@ def check_singular(sids, ids, idtype='gid'): outid = subprocess.Popen([wbinfo, '--sid-to-%s' % idtype, sid], stdout=subprocess.PIPE).communicate()[0].strip() if outid != ids[i]: - print "Expected %s, got %s\n" % (outid, ids[i]) + print("Expected %s, got %s\n" % (outid, ids[i])) flush_cache(sids=sids, uids=uids, gids=gids) sys.exit(1) i += 1 @@ -94,7 +94,7 @@ def check_multiple(sids, idtypes): result = line.split(' ')[2:] if result[0] != idtypes[i]: - print "Expected %s, got %s\n" % (idtypes[i], result[0]) + print("Expected %s, got %s\n" % (idtypes[i], result[0])) flush_cache(sids=sids, uids=uids, gids=gids) sys.exit(1) i += 1 From ef12aaa80bc07d5bd1e9f8319d06186887fffda6 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:06:21 +0000 Subject: [PATCH 12/14] script: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- script/autobuild.py | 12 ++++++------ script/compare_cc_results.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/script/autobuild.py b/script/autobuild.py index ebe49bb75cb..3e1fd529073 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -263,7 +263,7 @@ } def do_print(msg): - print "%s" % msg + print("%s" % msg) sys.stdout.flush() sys.stderr.flush() @@ -438,9 +438,9 @@ def write_system_info(self): filename = 'system-info.txt' f = open(filename, 'w') for cmd in ['uname -a', 'free', 'cat /proc/cpuinfo']: - print >>f, '### %s' % cmd - print >>f, run_cmd(cmd, output=True, checkfail=False) - print >>f + print('### %s' % cmd, file=f) + print(run_cmd(cmd, output=True, checkfail=False), file=f) + print(file=f) f.close() return filename @@ -833,7 +833,7 @@ def email_success(elapsed_time, log_base=None): elapsed_time, log_base=options.log_base) else: elapsed_minutes = elapsed_time / 60.0 - print ''' + print(''' #################################################################### @@ -848,7 +848,7 @@ def email_success(elapsed_time, log_base=None): #################################################################### -''' % (options.branch, platform.node(), elapsed_minutes, failed_task, errstr) +''' % (options.branch, platform.node(), elapsed_minutes, failed_task, errstr)) cleanup() do_print(errstr) diff --git a/script/compare_cc_results.py b/script/compare_cc_results.py index 1ab92490426..a9cd4758797 100755 --- a/script/compare_cc_results.py +++ b/script/compare_cc_results.py @@ -35,7 +35,7 @@ if base_fname: diff = list(difflib.unified_diff(base_lines,lines,base_fname,fname)) if diff: - print 'configuration files %s and %s do not match' % (base_fname, fname) + print('configuration files %s and %s do not match' % (base_fname, fname)) for l in diff: sys.stdout.write(l) found_diff = True From 8face52a9660578d582808ab8e3fbc07e1e21f7d Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:06:55 +0000 Subject: [PATCH 13/14] auth/credentials/test: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- auth/credentials/tests/bind.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/auth/credentials/tests/bind.py b/auth/credentials/tests/bind.py index 4aa44985cc1..ab4c80d3e1d 100755 --- a/auth/credentials/tests/bind.py +++ b/auth/credentials/tests/bind.py @@ -101,7 +101,7 @@ def test_computer_account_bind(self): # do a simple bind and search with the machine account creds_machine.set_bind_dn(self.computer_dn) creds_machine.set_password(self.password) - print "BindTest with: " + creds_machine.get_bind_dn() + print("BindTest with: " + creds_machine.get_bind_dn()) ldb_machine = samba.tests.connect_samdb(host, credentials=creds_machine, lp=lp, ldap_only=True) res = ldb_machine.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) @@ -119,7 +119,7 @@ def test_user_account_bind(self): # do a simple bind and search with the user account in format user@realm creds_user1.set_bind_dn(self.username + "@" + creds.get_realm()) creds_user1.set_password(self.password) - print "BindTest with: " + creds_user1.get_bind_dn() + print("BindTest with: " + creds_user1.get_bind_dn()) ldb_user1 = samba.tests.connect_samdb(host, credentials=creds_user1, lp=lp, ldap_only=True) res = ldb_user1.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) @@ -127,7 +127,7 @@ def test_user_account_bind(self): # do a simple bind and search with the user account in format domain\user creds_user2.set_bind_dn(creds.get_domain() + "\\" + self.username) creds_user2.set_password(self.password) - print "BindTest with: " + creds_user2.get_bind_dn() + print("BindTest with: " + creds_user2.get_bind_dn()) ldb_user2 = samba.tests.connect_samdb(host, credentials=creds_user2, lp=lp, ldap_only=True) res = ldb_user2.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) @@ -135,7 +135,7 @@ def test_user_account_bind(self): # do a simple bind and search with the user account DN creds_user3.set_bind_dn(str(user_dn)) creds_user3.set_password(self.password) - print "BindTest with: " + creds_user3.get_bind_dn() + print("BindTest with: " + creds_user3.get_bind_dn()) ldb_user3 = samba.tests.connect_samdb(host, credentials=creds_user3, lp=lp, ldap_only=True) res = ldb_user3.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) @@ -154,7 +154,7 @@ def test_user_account_bind_no_domain(self): creds_user4.set_password(self.password) creds_user4.set_domain('') creds_user4.set_workstation('') - print "BindTest (no domain) with: " + self.username + print("BindTest (no domain) with: " + self.username) try: ldb_user4 = samba.tests.connect_samdb(host, credentials=creds_user4, lp=lp, ldap_only=True) From 0358f2489726e51358f11748680791fceadc5179 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 9 Mar 2018 14:07:31 +0000 Subject: [PATCH 14/14] lib/tdb: convert print func to be py2/py3 compatible Signed-off-by: Noel Power --- lib/tdb/python/tdbdump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tdb/python/tdbdump.py b/lib/tdb/python/tdbdump.py index 01859ebce26..475d0de370b 100644 --- a/lib/tdb/python/tdbdump.py +++ b/lib/tdb/python/tdbdump.py @@ -4,9 +4,9 @@ import tdb, sys if len(sys.argv) < 2: - print "Usage: tdbdump.py " + print("Usage: tdbdump.py ") sys.exit(1) db = tdb.Tdb(sys.argv[1]) for (k, v) in db.iteritems(): - print "{\nkey(%d) = %r\ndata(%d) = %r\n}" % (len(k), k, len(v), v) + print("{\nkey(%d) = %r\ndata(%d) = %r\n}" % (len(k), k, len(v), v))