mirror of
https://github.com/samba-team/samba.git
synced 2025-07-31 20:22:15 +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",
|
"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):
|
def set_auto_replication(dc, allow):
|
||||||
credstring = '-U%s%%%s' % (os.environ["USERNAME"], os.environ["PASSWORD"])
|
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',
|
for opt in ['DISABLE_INBOUND_REPL',
|
||||||
'DISABLE_OUTBOUND_REPL']:
|
'DISABLE_OUTBOUND_REPL']:
|
||||||
cmd = ['bin/samba-tool',
|
cmd = adjust_cmd_for_py_version(['bin/samba-tool',
|
||||||
'drs', 'options',
|
'drs', 'options',
|
||||||
credstring, dc,
|
credstring, dc,
|
||||||
"--dsa-option=%s%s" % (on_or_off, opt)]
|
"--dsa-option=%s%s" % (on_or_off, opt)])
|
||||||
|
|
||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
|
||||||
def force_replication(src, dest, base):
|
def force_replication(src, dest, base):
|
||||||
credstring = '-U%s%%%s' % (os.environ["USERNAME"], os.environ["PASSWORD"])
|
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',
|
'drs', 'replicate',
|
||||||
dest, src, base,
|
dest, src, base,
|
||||||
credstring,
|
credstring,
|
||||||
'--sync-forced']
|
'--sync-forced'])
|
||||||
|
|
||||||
subprocess.check_call(cmd)
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
@ -176,11 +176,11 @@ def get_utdv_summary(distances, filters=None):
|
|||||||
maximum = values[-1]
|
maximum = values[-1]
|
||||||
length = len(values)
|
length = len(values)
|
||||||
if length % 2 == 0:
|
if length % 2 == 0:
|
||||||
index = length/2 - 1
|
index = length//2 - 1
|
||||||
median = (values[index] + values[index+1])/2.0
|
median = (values[index] + values[index+1])/2.0
|
||||||
median = round(median, 1) # keep only 1 decimal digit like 2.5
|
median = round(median, 1) # keep only 1 decimal digit like 2.5
|
||||||
else:
|
else:
|
||||||
index = (length - 1)/2
|
index = (length - 1)//2
|
||||||
median = values[index]
|
median = values[index]
|
||||||
median = float(median) # ensure median is always a float like 1.0
|
median = float(median) # ensure median is always a float like 1.0
|
||||||
# if value not exist, that's a failure
|
# if value not exist, that's a failure
|
||||||
|
Reference in New Issue
Block a user