mcstrans: fix Python linter warnings on test scripts

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
Nicolas Iooss 2018-12-15 19:14:55 +01:00 committed by Petr Lautrbach
parent 0ec2ed57c3
commit b7227aaec1
2 changed files with 12 additions and 9 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/python -E #!/usr/bin/python -E
import sys import sys
import re import selinux
from selinux import *
verbose = 0 verbose = 0
errors = 0 errors = 0
@ -18,12 +19,12 @@ for arg in sys.argv[1:]:
line = line.rstrip('\n') line = line.rstrip('\n')
# print line # print line
context, expected = line.split("=") context, expected = line.split("=")
rc, raw = selinux_trans_to_raw_context(context) rc, raw = selinux.selinux_trans_to_raw_context(context)
if rc < 0: if rc < 0:
print("Unable to get raw context of '%s'" % (context)) print("Unable to get raw context of '%s'" % (context))
errors += 1 errors += 1
continue continue
rc, colors = selinux_raw_context_to_color(raw) rc, colors = selinux.selinux_raw_context_to_color(raw)
if rc < 0: if rc < 0:
print("Unable to get colors for '%s'" % (context)) print("Unable to get colors for '%s'" % (context))
errors += 1 errors += 1

View File

@ -1,14 +1,15 @@
#!/usr/bin/python -E #!/usr/bin/python -E
import sys import sys
import re import selinux
from selinux import *
verbose = 0 verbose = 0
errors = 0 errors = 0
def untrans(trans, val): def untrans(trans, val):
global errors, verbose global errors, verbose
(rc, raw) = selinux_trans_to_raw_context(trans) (rc, raw) = selinux.selinux_trans_to_raw_context(trans)
if raw != val: if raw != val:
print("untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val)) print("untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val))
errors += 1 errors += 1
@ -19,7 +20,7 @@ def untrans(trans, val):
def trans(raw, val): def trans(raw, val):
global errors, verbose global errors, verbose
(rc, trans) = selinux_raw_to_trans_context(raw) (rc, trans) = selinux.selinux_raw_to_trans_context(raw)
if trans != val: if trans != val:
print("trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val)) print("trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val))
errors += 1 errors += 1
@ -27,6 +28,7 @@ def trans(raw, val):
if verbose: if verbose:
print("trans: %s -> %s != %s SUCCESS" % (raw, trans, val)) print("trans: %s -> %s != %s SUCCESS" % (raw, trans, val))
if len(sys.argv) > 1 and sys.argv[1] == "-v": if len(sys.argv) > 1 and sys.argv[1] == "-v":
verbose = 1 verbose = 1
@ -38,7 +40,7 @@ for arg in sys.argv[1:]:
if not line.strip(): if not line.strip():
continue continue
line = line.rstrip('\n') line = line.rstrip('\n')
if (line.find("==") != -1): if line.find("==") != -1:
t, r = line.split("==") t, r = line.split("==")
untrans("a:b:c:" + t, "a:b:c:" + r) untrans("a:b:c:" + t, "a:b:c:" + r)
trans("a:b:c:" + r, "a:b:c:" + t) trans("a:b:c:" + r, "a:b:c:" + t)