summaryrefslogtreecommitdiffstats
path: root/libmount/python/test_mount_tab.py
diff options
context:
space:
mode:
Diffstat (limited to 'libmount/python/test_mount_tab.py')
-rwxr-xr-xlibmount/python/test_mount_tab.py45
1 files changed, 22 insertions, 23 deletions
diff --git a/libmount/python/test_mount_tab.py b/libmount/python/test_mount_tab.py
index 33ceb5285..9d7d4edca 100755
--- a/libmount/python/test_mount_tab.py
+++ b/libmount/python/test_mount_tab.py
@@ -1,4 +1,3 @@
-#!/bin/python2
import os
import sys
import stat
@@ -7,11 +6,11 @@ import functools as ft
import libmount as mnt
def usage(tss):
- print "\nUsage:\n\t{:s} <test> [testoptions]\nTests:\n".format(sys.argv[0])
+ print("\nUsage:\n\t{:s} <test> [testoptions]\nTests:\n".format(sys.argv[0]))
for i in tss:
- print "\t{15:-s}".format(i[0])
+ print("\t{15:-s}".format(i[0]))
if i[2] != "":
- print " {:s}\n".format(i[2])
+ print(" {:s}\n".format(i[2]))
print("\n")
return 1
@@ -28,7 +27,7 @@ def mnt_run_test(tss, argv):
if i[0] == argv[1]:
rc = i[1](i, argv[1:])
if rc:
- print "FAILED [rc={:d}]".format(rc)
+ print("FAILED [rc={:d}]".format(rc))
break
if ((rc < 0) and (i == ())):
@@ -36,7 +35,7 @@ def mnt_run_test(tss, argv):
return not not rc #because !!rc is too mainstream for python
def parser_errcb(tb, fname, line):
- print "{:s}:{:d}: parse error".format(fname, line)
+ print("{:s}:{:d}: parse error".format(fname, line))
return 1
def create_table(f, comments):
@@ -50,7 +49,7 @@ def create_table(f, comments):
try:
tb.parse_file(f)
except Exception:
- print "{:s}: parsing failed".format(f)
+ print("{:s}: parsing failed".format(f))
return None
return tb
@@ -61,14 +60,14 @@ def test_copy_fs(ts, argv):
if not fs:
return rc
- print "ORIGINAL:"
- fs.print_debug(sys.stdout)
+ print("ORIGINAL:")
+ fs.print_debug()
fs = fs.copy_fs(None)
if not fs:
return rc
- print "COPY:"
- fs.print_debug(sys.stdout)
+ print("COPY:")
+ fs.print_debug()
return 0
def test_parse(ts, argv):
@@ -79,17 +78,17 @@ def test_parse(ts, argv):
tb = create_table(argv[1], parse_comments)
if tb.intro_comment:
- print "Initial comment:\n\"{:s}\"".format(tb.intro_comment)
+ print("Initial comment:\n\"{:s}\"".format(tb.intro_comment))
#while ((fs = tb.next_fs()) != None):
for fs in iter(ft.partial(tb.next_fs), None):
- fs.print_debug(sys.stdout)
+ fs.print_debug()
if tb.trailing_comment:
- print "Trailing comment:\n\"{:s}\"".format(tb.trailing_comment)
+ print("Trailing comment:\n\"{:s}\"".format(tb.trailing_comment))
return 0
def test_find(ts, argv, dr):
if len(argv) != 4:
- print "try --help"
+ print("try --help")
return -errno.EINVAL
f, find, what = argv[1:]
@@ -101,9 +100,9 @@ def test_find(ts, argv, dr):
fs = tb.find_target(what, dr)
if not fs:
- print "{:s}: not found {:s} '{:s}'".format(f, find, what)
+ print("{:s}: not found {:s} '{:s}'".format(f, find, what))
else:
- fs.print_debug(sys.stdout)
+ fs.print_debug()
return 0
def test_find_fw(ts, argv):
@@ -118,14 +117,14 @@ def test_find_pair(ts, argv):
fs = tb.find_pair(argv[2], argv[3], mnt.MNT_ITER_FORWARD)
if not fs:
return rc
- fs.print_debug(sys.stdout)
+ fs.print_debug()
return 0
def test_is_mounted(ts, argv):
rc = -1
tb = mnt.Tab(path="/proc/self/mountinfo")
if not tb:
- print "failed to parse mountinto"
+ print("failed to parse mountinto")
return rc
fstab = create_table(argv[1], False)
@@ -134,9 +133,9 @@ def test_is_mounted(ts, argv):
fs = ()
for fs in ft.iter(tb.next_fs(), -1):
if tb.is_fs_mounted(fs):
- print "{:s} already mounted on {:s}".format(fs.source, fs.target)
+ print("{:s} already mounted on {:s}".format(fs.source, fs.target))
else:
- print "{:s} not mounted on {:s}".format(fs.source, fs.target)
+ print("{:s} not mounted on {:s}".format(fs.source, fs.target))
return 0
def test_find_mountpoint(ts, argv):
@@ -147,12 +146,12 @@ def test_find_mountpoint(ts, argv):
fs = tb.find_mountpoint(argv[1], mnt.MNT_ITER_BACKWARD)
if not fs:
return rc
- fs.print_debug(sys.stdout)
+ fs.print_debug()
return 0
tss = (
- ( "--parse", test_parse, "<file> [--comments] parse and print tab" ),
+ ( "--parse", test_parse, "<file> [--comments] parse and print(tab" ),
( "--find-forward", test_find_fw, "<file> <source|target> <string>" ),
( "--find-backward", test_find_bw, "<file> <source|target> <string>" ),
( "--find-pair", test_find_pair, "<file> <source> <target>" ),