mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
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 <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user