def main(argv):
argv0 = argv[0]
- # Make stdout and stderr UTF-8, even if they are redirected to a file.
- sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
- sys.stderr = codecs.getwriter("utf-8")(sys.stderr)
+ # When this is used with Python 3, the program produces no output.
+ if sys.version_info[0] == 2:
+ # Make stdout and stderr UTF-8, even if they are redirected to a file.
+ sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
+ sys.stderr = codecs.getwriter("utf-8")(sys.stderr)
try:
options, args = getopt.gnu_getopt(argv[1:], '', ['multiple'])
atom = data.Atom.from_json(base, atom_json)
print(ovs.json.to_string(atom.to_json()))
except error.Error as e:
- print(e.args[0].encode("utf8"))
+ print(e.args[0])
def do_parse_data(type_string, *data_strings):
AT_CHECK([PYAPPCTL -t test-unixctl.py version], [0], [expout])
AT_CHECK([APPCTL -t test-unixctl.py echo robot ninja], [0], [stdout])
-AT_CHECK([cat stdout], [0], [dnl
-[[u'robot', u'ninja']]
+AT_CHECK([cat stdout | sed -e "s/u'/'/g"], [0], [dnl
+[['robot', 'ninja']]
])
mv stdout expout
AT_CHECK([PYAPPCTL -t test-unixctl.py echo robot ninja], [0], [expout])
AT_CHECK([APPCTL -t test-unixctl.py echo_error robot ninja], [2], [], [stderr])
-AT_CHECK([cat stderr], [0], [dnl
-[[u'robot', u'ninja']]
+AT_CHECK([cat stderr | sed -e "s/u'/'/g"], [0], [dnl
+[['robot', 'ninja']]
ovs-appctl: test-unixctl.py: server returned an error
])
sed 's/ovs-appctl/appctl.py/' stderr > experr