From d7dba6f701fa128803d7f7ead5bb6ddd3372393b Mon Sep 17 00:00:00 2001 From: Noel Power Date: Tue, 20 Nov 2018 17:02:25 +0000 Subject: [PATCH] python/samba: PY3 port samba.tests.samba_tool.visualize_drs * Fix calling samba-tool with correct PYTHON version * Fix integer division needs '//' operator (this was causing 'uncaught exception - list indices must be integers or slices, not float' Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett --- python/samba/tests/samba_tool/visualize_drs.py | 12 ++++++++---- python/samba/uptodateness.py | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/python/samba/tests/samba_tool/visualize_drs.py b/python/samba/tests/samba_tool/visualize_drs.py index 0f566ea80c7..9b1588bd1ef 100644 --- a/python/samba/tests/samba_tool/visualize_drs.py +++ b/python/samba/tests/samba_tool/visualize_drs.py @@ -49,6 +49,10 @@ PARTITION_NAMES = [ "DNSFOREST", ] +def adjust_cmd_for_py_version(parts): + if os.getenv("PYTHON", None): + parts.insert(0, os.environ["PYTHON"]) + return parts def set_auto_replication(dc, allow): credstring = '-U%s%%%s' % (os.environ["USERNAME"], os.environ["PASSWORD"]) @@ -56,21 +60,21 @@ def set_auto_replication(dc, allow): for opt in ['DISABLE_INBOUND_REPL', 'DISABLE_OUTBOUND_REPL']: - cmd = ['bin/samba-tool', + cmd = adjust_cmd_for_py_version(['bin/samba-tool', 'drs', 'options', credstring, dc, - "--dsa-option=%s%s" % (on_or_off, opt)] + "--dsa-option=%s%s" % (on_or_off, opt)]) subprocess.check_call(cmd) def force_replication(src, dest, base): credstring = '-U%s%%%s' % (os.environ["USERNAME"], os.environ["PASSWORD"]) - cmd = ['bin/samba-tool', + cmd = adjust_cmd_for_py_version(['bin/samba-tool', 'drs', 'replicate', dest, src, base, credstring, - '--sync-forced'] + '--sync-forced']) subprocess.check_call(cmd) diff --git a/python/samba/uptodateness.py b/python/samba/uptodateness.py index d2662549dfc..3964bd7d6db 100644 --- a/python/samba/uptodateness.py +++ b/python/samba/uptodateness.py @@ -176,11 +176,11 @@ def get_utdv_summary(distances, filters=None): maximum = values[-1] length = len(values) if length % 2 == 0: - index = length/2 - 1 + index = length//2 - 1 median = (values[index] + values[index+1])/2.0 median = round(median, 1) # keep only 1 decimal digit like 2.5 else: - index = (length - 1)/2 + index = (length - 1)//2 median = values[index] median = float(median) # ensure median is always a float like 1.0 # if value not exist, that's a failure