Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated

gen-out-type = $(subst .,-,$(suffix $@))

qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
qapi-py = $(SRC_PATH)/scripts/qapi.py

qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
Expand Down
5 changes: 2 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1186,9 +1186,8 @@ fi

# Note that if the Python conditional here evaluates True we will exit
# with status 1 which is a shell 'false' value.
if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
error_exit "Cannot use '$python', Python 2.6 or later is required." \
"Note that Python 3 or later is not yet supported." \
if ! $python -c 'import sys; sys.exit(sys.version_info < (3,))'; then
error_exit "Cannot use '$python', Python 3 or later is required." \
"Use --python=/path/to/python to specify a supported Python."
fi

Expand Down
2 changes: 1 addition & 1 deletion pebble.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import os
import argparse
Expand Down
2 changes: 1 addition & 1 deletion scripts/acpi_extract.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (C) 2011 Red Hat, Inc., Michael S. Tsirkin <mst@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion scripts/acpi_extract_preprocess.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# Copyright (C) 2011 Red Hat, Inc., Michael S. Tsirkin <mst@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion scripts/analyse-9p-simpletrace.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Pretty print 9p simpletrace log
# Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/analyze-migration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Migration Stream Analyzer
#
Expand Down
128 changes: 0 additions & 128 deletions scripts/ordereddict.py

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/png_to_cstruct.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

"""
Convert a PNG image into a C struct
Expand Down
35 changes: 17 additions & 18 deletions scripts/qapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the COPYING file in the top-level directory.

import re
from ordereddict import OrderedDict
from collections import OrderedDict
import errno
import getopt
import os
Expand Down Expand Up @@ -152,7 +152,7 @@ def __init__(self, fp, previously_included=[], incl_info=None):
continue
try:
fobj = open(incl_abs_fname, 'r')
except IOError, e:
except IOError as e:
raise QAPIExprError(expr_info,
'%s: %s' % (e.strerror, include))
exprs_include = QAPISchemaParser(fobj, previously_included,
Expand Down Expand Up @@ -1148,8 +1148,8 @@ def __init__(self, fname):
self._predefining = False
self._def_exprs()
self.check()
except (QAPISchemaError, QAPIExprError), err:
print >>sys.stderr, err
except (QAPISchemaError, QAPIExprError) as err:
print(err, file=sys.stderr)
exit(1)

def _def_entity(self, ent):
Expand Down Expand Up @@ -1235,7 +1235,7 @@ def _make_member(self, name, typ, info):

def _make_members(self, data, info):
return [self._make_member(key, value, info)
for (key, value) in data.iteritems()]
for (key, value) in data.items()]

def _def_struct_type(self, expr, info):
name = expr['struct']
Expand Down Expand Up @@ -1269,10 +1269,10 @@ def _def_union_type(self, expr, info):
tag_member = None
if tag_name:
variants = [self._make_variant(key, value)
for (key, value) in data.iteritems()]
for (key, value) in data.items()]
else:
variants = [self._make_simple_variant(key, value, info)
for (key, value) in data.iteritems()]
for (key, value) in data.items()]
tag_member = self._make_implicit_tag(name, info, variants)
self._def_entity(
QAPISchemaObjectType(name, info, base,
Expand All @@ -1285,7 +1285,7 @@ def _def_alternate_type(self, expr, info):
name = expr['alternate']
data = expr['data']
variants = [self._make_variant(key, value)
for (key, value) in data.iteritems()]
for (key, value) in data.items()]
tag_member = self._make_implicit_tag(name, info, variants)
self._def_entity(
QAPISchemaAlternateType(name, info,
Expand Down Expand Up @@ -1392,7 +1392,7 @@ def c_enum_const(type_name, const_name, prefix=None):
type_name = prefix
return camel_to_upper(type_name + '_' + const_name)

c_name_trans = string.maketrans('.-', '__')
c_name_trans = str.maketrans('.-', '__')


# Map @name to a valid C identifier.
Expand Down Expand Up @@ -1639,8 +1639,8 @@ def parse_command_line(extra_options="", extra_long_options=[]):
"chp:o:" + extra_options,
["source", "header", "prefix=",
"output-dir="] + extra_long_options)
except getopt.GetoptError, err:
print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err))
except getopt.GetoptError as err:
print("%s: %s" % (sys.argv[0], str(err)), file=sys.stderr)
sys.exit(1)

output_dir = ""
Expand All @@ -1654,9 +1654,8 @@ def parse_command_line(extra_options="", extra_long_options=[]):
if o in ("-p", "--prefix"):
match = re.match('([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
if match.end() != len(a):
print >>sys.stderr, \
"%s: 'funny character '%s' in argument of --prefix" \
% (sys.argv[0], a[match.end()])
print("%s: 'funny character '%s' in argument of --prefix" \
% (sys.argv[0], a[match.end()]), file=sys.stderr)
sys.exit(1)
prefix = a
elif o in ("-o", "--output-dir"):
Expand All @@ -1673,7 +1672,7 @@ def parse_command_line(extra_options="", extra_long_options=[]):
do_h = True

if len(args) != 1:
print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0]
print("%s: need exactly one argument" % sys.argv[0], file=sys.stderr)
sys.exit(1)
fname = args[0]

Expand All @@ -1693,16 +1692,16 @@ def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
if output_dir:
try:
os.makedirs(output_dir)
except os.error, e:
except os.error as e:
if e.errno != errno.EEXIST:
raise

def maybe_open(really, name, opt):
if really:
return open(name, opt)
else:
import StringIO
return StringIO.StringIO()
import io
return io.StringIO()

fdef = maybe_open(do_c, c_file, 'w')
fdecl = maybe_open(do_h, h_file, 'w')
Expand Down
2 changes: 1 addition & 1 deletion scripts/qemu-gdb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# GDB debugging support
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/qemugdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# GDB debugging support
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/qemugdb/aio.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# GDB debugging support: aio/iohandler debug
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/qemugdb/coroutine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# GDB debugging support
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/qemugdb/mtree.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# GDB debugging support
#
Expand Down
4 changes: 2 additions & 2 deletions scripts/qmp/qmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __get_events(self, wait=False):
self.__sock.setblocking(0)
try:
self.__json_read()
except socket.error, err:
except socket.error as err:
if err[0] == errno.EAGAIN:
# No data available
pass
Expand Down Expand Up @@ -150,7 +150,7 @@ def cmd_obj(self, qmp_cmd):
"""
try:
self.__sock.sendall(json.dumps(qmp_cmd))
except socket.error, err:
except socket.error as err:
if err[0] == errno.EPIPE:
return
raise socket.error(err)
Expand Down
2 changes: 1 addition & 1 deletion scripts/simpletrace.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Pretty-printer for simple trace backend binary trace files
#
Expand Down
6 changes: 3 additions & 3 deletions scripts/tracetool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Expand Down Expand Up @@ -71,7 +71,7 @@ def main(args):

try:
opts, args = getopt.getopt(args[1:], "", long_opts)
except getopt.GetoptError, err:
except getopt.GetoptError as err:
error_opt(str(err))

check_backends = False
Expand Down Expand Up @@ -132,7 +132,7 @@ def main(args):
try:
tracetool.generate(sys.stdin, arg_format, arg_backends,
binary=binary, probe_prefix=probe_prefix)
except tracetool.TracetoolError, e:
except tracetool.TracetoolError as e:
error_opt(str(e))

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion scripts/tracetool/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Expand Down
2 changes: 1 addition & 1 deletion scripts/tracetool/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Expand Down
Loading