From c6100d777bbd73c9e58adb372972f02d7655ee13 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Tue, 17 Apr 2018 16:48:03 +0100 Subject: [PATCH] python/samba: changes to make samba.tests.samba_tool.join run under py3 Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett --- python/samba/join.py | 6 +++--- python/samba/netcmd/domain_backup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/samba/join.py b/python/samba/join.py index 9cab604ec4a..e7963eeaa1e 100644 --- a/python/samba/join.py +++ b/python/samba/join.py @@ -354,21 +354,21 @@ class DCJoinContext(object): def get_dnsHostName(ctx): res = ctx.samdb.search(base="", scope=ldb.SCOPE_BASE, attrs=["dnsHostName"]) - return res[0]["dnsHostName"][0] + return str(res[0]["dnsHostName"][0]) def get_domain_name(ctx): '''get netbios name of the domain from the partitions record''' partitions_dn = ctx.samdb.get_partitions_dn() res = ctx.samdb.search(base=partitions_dn, scope=ldb.SCOPE_ONELEVEL, attrs=["nETBIOSName"], expression='ncName=%s' % ldb.binary_encode(str(ctx.samdb.get_default_basedn()))) - return res[0]["nETBIOSName"][0] + return str(res[0]["nETBIOSName"][0]) def get_forest_domain_name(ctx): '''get netbios name of the domain from the partitions record''' partitions_dn = ctx.samdb.get_partitions_dn() res = ctx.samdb.search(base=partitions_dn, scope=ldb.SCOPE_ONELEVEL, attrs=["nETBIOSName"], expression='ncName=%s' % ldb.binary_encode(str(ctx.samdb.get_root_basedn()))) - return res[0]["nETBIOSName"][0] + return str(res[0]["nETBIOSName"][0]) def get_parent_partition_dn(ctx): '''get the parent domain partition DN from parent DNS name''' diff --git a/python/samba/netcmd/domain_backup.py b/python/samba/netcmd/domain_backup.py index c2f056e6ba3..de53c6e5113 100644 --- a/python/samba/netcmd/domain_backup.py +++ b/python/samba/netcmd/domain_backup.py @@ -891,7 +891,7 @@ class cmd_domain_backup_offline(samba.netcmd.Command): # If more than one directory is a parent of this path, then at least # one configured path is a subdir of another. Use closest match. if len(matching_dirs) > 1: - arc_path, fs_path = max(matching_dirs, key=lambda (_, p): len(p)) + arc_path, fs_path = max(matching_dirs, key=lambda p: len(p[1])) arc_path += path[len(fs_path):] return arc_path -- 2.34.1