diff options
author | Uri Lublin <uril@redhat.com> | 2020-01-01 11:51:23 +0200 |
---|---|---|
committer | Uri Lublin <uril@redhat.com> | 2020-02-20 14:10:09 +0200 |
commit | 7318565eccb8e722e2c6248619ee35a07c26628e (patch) | |
tree | a677c8bbc826c1ab188ca2781034a1f0a18737d0 /tests | |
parent | d109bd35779f5139bc763961f7a788cde59122b1 (diff) |
migrate.py: python3: raw_input and more
There is no raw_input() in python3 -- define it as input()
Use decode() when writing subprocess output to the log, to make
sure the argument for write is a string (in python3
stdout.read() returns bytes).
There is no has_key in python3 -- use "in" instead
Signed-off-by: Uri Lublin <uril@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/migrate.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/migrate.py b/tests/migrate.py index aa20c565..8ecb59fd 100755 --- a/tests/migrate.py +++ b/tests/migrate.py @@ -47,6 +47,10 @@ import datetime import atexit import argparse +# python3 does not have raw_input +if sys.version_info[0] == 3: + raw_input = input + def get_args(): parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('--qmp1', dest='qmp1', default='/tmp/migrate_test.1.qmp') @@ -125,7 +129,7 @@ def wait_active(q, active): # ValueError time.sleep(0.1) continue - if ret and ret.has_key("return"): + if ret and "return" in ret.keys(): if ret["return"]["running"] == active: break for e in q.get_events(): @@ -213,7 +217,8 @@ class Migrator(object): new_spice_port = dead.spice_port new_qmp_filename = dead.qmp_filename self.log.write("# STDOUT dead %s\n" % dead.pid) - self.log.write(dead.stdout.read()) + outstr = dead.stdout.read().decode(encoding='utf-8', errors='ignore') + self.log.write(outstr) del dead self.active = self.target self.target = start_qemu(spice_port=new_spice_port, |