diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2018-06-08 09:29:43 -0300 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2018-06-08 14:39:24 -0300 |
commit | f03868bd5653265e97b253102d77d83ea85efdea (patch) | |
tree | f524a2198bb8492e8502326a112d465892d255b0 /tests/image-fuzzer | |
parent | 0d2fa03dae4fbe185a082f361342b1e30aed4582 (diff) |
python: futurize -f libfuturize.fixes.fix_print_with_import
Change all Python code to use print as a function.
This is necessary for Python 3 compatibility.
Done using:
$ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
sort -u | grep -v README.sh4)
$ futurize -w -f libfuturize.fixes.fix_print_with_import $py
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20180608122952.2009-2-ehabkost@redhat.com>
[ehabkost: fixup tests/docker/docker.py]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'tests/image-fuzzer')
-rwxr-xr-x | tests/image-fuzzer/runner.py | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/tests/image-fuzzer/runner.py b/tests/image-fuzzer/runner.py index 96a1c11b2f..8de656933e 100755 --- a/tests/image-fuzzer/runner.py +++ b/tests/image-fuzzer/runner.py @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +from __future__ import print_function import sys import os import signal @@ -36,9 +37,8 @@ except ImportError: try: import simplejson as json except ImportError: - print >>sys.stderr, \ - "Warning: Module for JSON processing is not found.\n" \ - "'--config' and '--command' options are not supported." + print("Warning: Module for JSON processing is not found.\n" \ + "'--config' and '--command' options are not supported.", file=sys.stderr) # Backing file sizes in MB MAX_BACKING_FILE_SIZE = 10 @@ -158,9 +158,8 @@ class TestEnv(object): try: os.makedirs(self.current_dir) except OSError as e: - print >>sys.stderr, \ - "Error: The working directory '%s' cannot be used. Reason: %s"\ - % (self.work_dir, e[1]) + print("Error: The working directory '%s' cannot be used. Reason: %s"\ + % (self.work_dir, e[1]), file=sys.stderr) raise TestException self.log = open(os.path.join(self.current_dir, "test.log"), "w") self.parent_log = open(run_log, "a") @@ -277,7 +276,7 @@ class TestEnv(object): if __name__ == '__main__': def usage(): - print """ + print(""" Usage: runner.py [OPTION...] TEST_DIR IMG_GENERATOR Set up test environment in TEST_DIR and run a test in it. A module for @@ -326,7 +325,7 @@ if __name__ == '__main__': If '--config' argument is specified, fields not listed in the configuration array will not be fuzzed. - """ + """) def run_test(test_id, seed, work_dir, run_log, cleanup, log_all, command, fuzz_config): @@ -357,8 +356,7 @@ if __name__ == '__main__': ['command=', 'help', 'seed=', 'config=', 'keep_passed', 'verbose', 'duration=']) except getopt.error as e: - print >>sys.stderr, \ - "Error: %s\n\nTry 'runner.py --help' for more information" % e + print("Error: %s\n\nTry 'runner.py --help' for more information" % e, file=sys.stderr) sys.exit(1) command = None @@ -375,9 +373,8 @@ if __name__ == '__main__': try: command = json.loads(arg) except (TypeError, ValueError, NameError) as e: - print >>sys.stderr, \ - "Error: JSON array of test commands cannot be loaded.\n" \ - "Reason: %s" % e + print("Error: JSON array of test commands cannot be loaded.\n" \ + "Reason: %s" % e, file=sys.stderr) sys.exit(1) elif opt in ('-k', '--keep_passed'): cleanup = False @@ -391,15 +388,13 @@ if __name__ == '__main__': try: config = json.loads(arg) except (TypeError, ValueError, NameError) as e: - print >>sys.stderr, \ - "Error: JSON array with the fuzzer configuration cannot" \ - " be loaded\nReason: %s" % e + print("Error: JSON array with the fuzzer configuration cannot" \ + " be loaded\nReason: %s" % e, file=sys.stderr) sys.exit(1) if not len(args) == 2: - print >>sys.stderr, \ - "Expected two parameters\nTry 'runner.py --help'" \ - " for more information." + print("Expected two parameters\nTry 'runner.py --help'" \ + " for more information.", file=sys.stderr) sys.exit(1) work_dir = os.path.realpath(args[0]) @@ -415,9 +410,8 @@ if __name__ == '__main__': try: image_generator = __import__(generator_name) except ImportError as e: - print >>sys.stderr, \ - "Error: The image generator '%s' cannot be imported.\n" \ - "Reason: %s" % (generator_name, e) + print("Error: The image generator '%s' cannot be imported.\n" \ + "Reason: %s" % (generator_name, e), file=sys.stderr) sys.exit(1) # Enable core dumps |