selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mcstrans: convert test scripts to Python 3
@ 2018-12-15 18:14 Nicolas Iooss
  2018-12-15 18:14 ` [PATCH 2/2] mcstrans: fix Python linter warnings on test scripts Nicolas Iooss
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Iooss @ 2018-12-15 18:14 UTC (permalink / raw)
  To: selinux

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 mcstrans/share/util/mlscolor-test |  8 ++++----
 mcstrans/share/util/mlstrans-test | 11 +++++------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/mcstrans/share/util/mlscolor-test b/mcstrans/share/util/mlscolor-test
index 7b8d809b7ac5..447389704beb 100644
--- a/mcstrans/share/util/mlscolor-test
+++ b/mcstrans/share/util/mlscolor-test
@@ -20,17 +20,17 @@ for arg in sys.argv[1:]:
         context, expected = line.split("=")
         rc, raw = selinux_trans_to_raw_context(context)
         if rc < 0:
-            print "Unable to get raw context of '%s'" % (context)
+            print("Unable to get raw context of '%s'" % (context))
             errors += 1
             continue
         rc, colors = selinux_raw_context_to_color(raw)
         if rc < 0:
-            print "Unable to get colors for '%s'" % (context)
+            print("Unable to get colors for '%s'" % (context))
             errors += 1
             continue
         colors = colors.rstrip()
         if colors != expected:
-            print "For '%s' got\n\t'%s' expected\n\t'%s'" % (context, colors, expected)
+            print("For '%s' got\n\t'%s' expected\n\t'%s'" % (context, colors, expected))
             errors += 1
             continue
     f.close()
@@ -38,6 +38,6 @@ for arg in sys.argv[1:]:
 s = "s"
 if errors == 1:
     s = ""
-print "mlscolor-test done with %d error%s" % (errors, s)
+print("mlscolor-test done with %d error%s" % (errors, s))
 
 sys.exit(errors)
diff --git a/mcstrans/share/util/mlstrans-test b/mcstrans/share/util/mlstrans-test
index f854f7b3c2d6..3ff4444ab000 100644
--- a/mcstrans/share/util/mlstrans-test
+++ b/mcstrans/share/util/mlstrans-test
@@ -10,22 +10,22 @@ def untrans(trans, val):
     global errors, verbose
     (rc, raw) = selinux_trans_to_raw_context(trans)
     if raw != val:
-        print "untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val)
+        print("untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val))
         errors += 1
     else:
         if verbose:
-            print "untrans: %s -> %s != %s SUCCESS" % (trans, raw, val)
+            print("untrans: %s -> %s != %s SUCCESS" % (trans, raw, val))
 
 
 def trans(raw, val):
     global errors, verbose
     (rc, trans) = selinux_raw_to_trans_context(raw)
     if trans != val:
-        print "trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val)
+        print("trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val))
         errors += 1
     else:
         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":
     verbose = 1
@@ -38,7 +38,6 @@ for arg in sys.argv[1:]:
         if not line.strip():
             continue
         line = line.rstrip('\n')
-#       print line
         if (line.find("==") != -1):
             t, r = line.split("==")
             untrans("a:b:c:" + t, "a:b:c:" + r)
@@ -51,6 +50,6 @@ for arg in sys.argv[1:]:
 s = "s"
 if errors == 1:
     s = ""
-print "mlstrans-test done with %d error%s" % (errors, s)
+print("mlstrans-test done with %d error%s" % (errors, s))
 
 sys.exit(errors)
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] mcstrans: fix Python linter warnings on test scripts
  2018-12-15 18:14 [PATCH 1/2] mcstrans: convert test scripts to Python 3 Nicolas Iooss
@ 2018-12-15 18:14 ` Nicolas Iooss
  2018-12-19 11:08   ` Petr Lautrbach
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Iooss @ 2018-12-15 18:14 UTC (permalink / raw)
  To: selinux

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 mcstrans/share/util/mlscolor-test |  9 +++++----
 mcstrans/share/util/mlstrans-test | 12 +++++++-----
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/mcstrans/share/util/mlscolor-test b/mcstrans/share/util/mlscolor-test
index 447389704beb..03fc4be40375 100644
--- a/mcstrans/share/util/mlscolor-test
+++ b/mcstrans/share/util/mlscolor-test
@@ -1,7 +1,8 @@
 #!/usr/bin/python -E
 import sys
-import re
-from selinux import *
+import selinux
+
+
 verbose = 0
 errors = 0
 
@@ -18,12 +19,12 @@ for arg in sys.argv[1:]:
         line = line.rstrip('\n')
 #       print line
         context, expected = line.split("=")
-        rc, raw = selinux_trans_to_raw_context(context)
+        rc, raw = selinux.selinux_trans_to_raw_context(context)
         if rc < 0:
             print("Unable to get raw context of '%s'" % (context))
             errors += 1
             continue
-        rc, colors = selinux_raw_context_to_color(raw)
+        rc, colors = selinux.selinux_raw_context_to_color(raw)
         if rc < 0:
             print("Unable to get colors for '%s'" % (context))
             errors += 1
diff --git a/mcstrans/share/util/mlstrans-test b/mcstrans/share/util/mlstrans-test
index 3ff4444ab000..c026d00ef9c7 100644
--- a/mcstrans/share/util/mlstrans-test
+++ b/mcstrans/share/util/mlstrans-test
@@ -1,14 +1,15 @@
 #!/usr/bin/python -E
 import sys
-import re
-from selinux import *
+import selinux
+
+
 verbose = 0
 errors = 0
 
 
 def untrans(trans, val):
     global errors, verbose
-    (rc, raw) = selinux_trans_to_raw_context(trans)
+    (rc, raw) = selinux.selinux_trans_to_raw_context(trans)
     if raw != val:
         print("untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val))
         errors += 1
@@ -19,7 +20,7 @@ def untrans(trans, val):
 
 def trans(raw, val):
     global errors, verbose
-    (rc, trans) = selinux_raw_to_trans_context(raw)
+    (rc, trans) = selinux.selinux_raw_to_trans_context(raw)
     if trans != val:
         print("trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val))
         errors += 1
@@ -27,6 +28,7 @@ def trans(raw, val):
         if verbose:
             print("trans: %s -> %s != %s SUCCESS" % (raw, trans, val))
 
+
 if len(sys.argv) > 1 and sys.argv[1] == "-v":
     verbose = 1
 
@@ -38,7 +40,7 @@ for arg in sys.argv[1:]:
         if not line.strip():
             continue
         line = line.rstrip('\n')
-        if (line.find("==") != -1):
+        if line.find("==") != -1:
             t, r = line.split("==")
             untrans("a:b:c:" + t, "a:b:c:" + r)
             trans("a:b:c:" + r, "a:b:c:" + t)
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] mcstrans: fix Python linter warnings on test scripts
  2018-12-15 18:14 ` [PATCH 2/2] mcstrans: fix Python linter warnings on test scripts Nicolas Iooss
@ 2018-12-19 11:08   ` Petr Lautrbach
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Lautrbach @ 2018-12-19 11:08 UTC (permalink / raw)
  To: selinux; +Cc: Nicolas Iooss

Nicolas Iooss <nicolas.iooss@m4x.org> writes:

> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Both merged. Thanks!

> ---
>  mcstrans/share/util/mlscolor-test |  9 +++++----
>  mcstrans/share/util/mlstrans-test | 12 +++++++-----
>  2 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/mcstrans/share/util/mlscolor-test b/mcstrans/share/util/mlscolor-test
> index 447389704beb..03fc4be40375 100644
> --- a/mcstrans/share/util/mlscolor-test
> +++ b/mcstrans/share/util/mlscolor-test
> @@ -1,7 +1,8 @@
>  #!/usr/bin/python -E
>  import sys
> -import re
> -from selinux import *
> +import selinux
> +
> +
>  verbose = 0
>  errors = 0
>  
> @@ -18,12 +19,12 @@ for arg in sys.argv[1:]:
>          line = line.rstrip('\n')
>  #       print line
>          context, expected = line.split("=")
> -        rc, raw = selinux_trans_to_raw_context(context)
> +        rc, raw = selinux.selinux_trans_to_raw_context(context)
>          if rc < 0:
>              print("Unable to get raw context of '%s'" % (context))
>              errors += 1
>              continue
> -        rc, colors = selinux_raw_context_to_color(raw)
> +        rc, colors = selinux.selinux_raw_context_to_color(raw)
>          if rc < 0:
>              print("Unable to get colors for '%s'" % (context))
>              errors += 1
> diff --git a/mcstrans/share/util/mlstrans-test b/mcstrans/share/util/mlstrans-test
> index 3ff4444ab000..c026d00ef9c7 100644
> --- a/mcstrans/share/util/mlstrans-test
> +++ b/mcstrans/share/util/mlstrans-test
> @@ -1,14 +1,15 @@
>  #!/usr/bin/python -E
>  import sys
> -import re
> -from selinux import *
> +import selinux
> +
> +
>  verbose = 0
>  errors = 0
>  
>  
>  def untrans(trans, val):
>      global errors, verbose
> -    (rc, raw) = selinux_trans_to_raw_context(trans)
> +    (rc, raw) = selinux.selinux_trans_to_raw_context(trans)
>      if raw != val:
>          print("untrans: '%s' -> '%s' != '%s' FAILED" % (trans, raw, val))
>          errors += 1
> @@ -19,7 +20,7 @@ def untrans(trans, val):
>  
>  def trans(raw, val):
>      global errors, verbose
> -    (rc, trans) = selinux_raw_to_trans_context(raw)
> +    (rc, trans) = selinux.selinux_raw_to_trans_context(raw)
>      if trans != val:
>          print("trans: '%s' -> '%s' != '%s' FAILED" % (raw, trans, val))
>          errors += 1
> @@ -27,6 +28,7 @@ def trans(raw, val):
>          if verbose:
>              print("trans: %s -> %s != %s SUCCESS" % (raw, trans, val))
>  
> +
>  if len(sys.argv) > 1 and sys.argv[1] == "-v":
>      verbose = 1
>  
> @@ -38,7 +40,7 @@ for arg in sys.argv[1:]:
>          if not line.strip():
>              continue
>          line = line.rstrip('\n')
> -        if (line.find("==") != -1):
> +        if line.find("==") != -1:
>              t, r = line.split("==")
>              untrans("a:b:c:" + t, "a:b:c:" + r)
>              trans("a:b:c:" + r, "a:b:c:" + t)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-19 11:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-15 18:14 [PATCH 1/2] mcstrans: convert test scripts to Python 3 Nicolas Iooss
2018-12-15 18:14 ` [PATCH 2/2] mcstrans: fix Python linter warnings on test scripts Nicolas Iooss
2018-12-19 11:08   ` Petr Lautrbach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).