From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Anthony PERARD <anthony.perard@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH for-next v2 v2 2/5] libxl: make python scripts work with python 2.6 and up
Date: Wed, 6 Mar 2019 17:52:07 +0000 [thread overview]
Message-ID: <20190306175210.28145-3-wei.liu2@citrix.com> (raw)
In-Reply-To: <20190306175210.28145-1-wei.liu2@citrix.com>
Go through the transformations suggested by 2to3 and pick the
necessary ones.
Use sys.stderr.write to avoid importing from __future__.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
tools/libxl/gentest.py | 2 +-
tools/libxl/gentypes.py | 10 +++++-----
tools/libxl/idl.py | 13 ++++++-------
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/tools/libxl/gentest.py b/tools/libxl/gentest.py
index 989959fc68..81e13b437c 100644
--- a/tools/libxl/gentest.py
+++ b/tools/libxl/gentest.py
@@ -86,7 +86,7 @@ def gen_rand_init(ty, v, indent = " ", parent = None):
if __name__ == '__main__':
if len(sys.argv) < 3:
- print >>sys.stderr, "Usage: gentest.py <idl> <implementation>"
+ sys.stderr.write("Usage: gentest.py <idl> <implementation>\n")
sys.exit(1)
random.seed(os.getenv('LIBXL_TESTIDL_SEED'))
diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
index 88e5c5f30e..656c157c01 100644
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -576,14 +576,14 @@ def libxl_C_enum_from_string(ty, str, e, indent = " "):
if __name__ == '__main__':
if len(sys.argv) != 6:
- print >>sys.stderr, "Usage: gentypes.py <idl> <header> <header-private> <header-json> <implementation>"
+ sys.stderr.write("Usage: gentypes.py <idl> <header> <header-private> <header-json> <implementation>\n")
sys.exit(1)
(_, idlname, header, header_private, header_json, impl) = sys.argv
(builtins,types) = idl.parse(idlname)
- print "outputting libxl type definitions to %s" % header
+ print("outputting libxl type definitions to %s" % header)
f = open(header, "w")
@@ -633,7 +633,7 @@ if __name__ == '__main__':
f.write("""#endif /* %s */\n""" % (header_define))
f.close()
- print "outputting libxl JSON definitions to %s" % header_json
+ print("outputting libxl JSON definitions to %s" % header_json)
f = open(header_json, "w")
@@ -657,7 +657,7 @@ if __name__ == '__main__':
f.write("""#endif /* %s */\n""" % header_json_define)
f.close()
- print "outputting libxl type internal definitions to %s" % header_private
+ print("outputting libxl type internal definitions to %s" % header_private)
f = open(header_private, "w")
@@ -683,7 +683,7 @@ if __name__ == '__main__':
f.write("""#endif /* %s */\n""" % header_json_define)
f.close()
- print "outputting libxl type implementations to %s" % impl
+ print("outputting libxl type implementations to %s" % impl)
f = open(impl, "w")
f.write("""
diff --git a/tools/libxl/idl.py b/tools/libxl/idl.py
index 2a7f3c44fe..b5bfc66b50 100644
--- a/tools/libxl/idl.py
+++ b/tools/libxl/idl.py
@@ -11,7 +11,7 @@ DIR_BOTH = 3
_default_namespace = ""
def namespace(s):
if type(s) != str:
- raise TypeError, "Require a string for the default namespace."
+ raise TypeError("Require a string for the default namespace.")
global _default_namespace
_default_namespace = s
@@ -346,7 +346,7 @@ class OrderedDict(dict):
return [(x,self[x]) for x in self.__ordered]
def parse(f):
- print >>sys.stderr, "Parsing %s" % f
+ sys.stderr.write("Parsing %s\n" % f)
globs = {}
locs = OrderedDict()
@@ -362,11 +362,10 @@ def parse(f):
globs[n] = t
try:
- execfile(f, globs, locs)
- except SyntaxError,e:
- raise SyntaxError, \
- "Errors were found at line %d while processing %s:\n\t%s"\
- %(e.lineno,f,e.text)
+ exec(compile(open(f).read(), f, 'exec'), globs, locs)
+ except SyntaxError as e:
+ raise SyntaxError("Errors were found at line %d while processing %s:\n\t%s"\
+ %(e.lineno,f,e.text))
types = [t for t in locs.ordered_values() if isinstance(t,Type)]
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-03-06 17:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 17:52 [PATCH for-next v2 v2 0/5] tools: Python 3 compatibility Wei Liu
2019-03-06 17:52 ` [PATCH for-next v2 v2 1/5] build/m4: make python_devel.m4 work with both python 2 and 3 Wei Liu
2019-03-07 11:14 ` Anthony PERARD
2019-03-06 17:52 ` Wei Liu [this message]
2019-03-06 18:20 ` [PATCH for-next v2 v2 2/5] libxl: make python scripts work with python 2.6 and up Andrew Cooper
2019-03-06 20:58 ` Hans van Kranenburg
2019-03-07 10:37 ` Wei Liu
2019-03-07 11:30 ` Wei Liu
2019-03-06 17:52 ` [PATCH for-next v2 v2 3/5] pygrub: convert python scripts to work with " Wei Liu
2019-03-06 18:23 ` Andrew Cooper
2019-03-06 17:52 ` [PATCH for-next v2 v2 4/5] pygrub: make it build with python 3 Wei Liu
2019-03-06 18:46 ` Andrew Cooper
2019-03-06 17:52 ` [PATCH for-next v2 v2 5/5] Update python requirement Wei Liu
2019-03-07 11:21 ` Anthony PERARD
2019-03-07 11:24 ` Wei Liu
2019-03-06 18:17 ` [PATCH for-next v2 v2 0/5] tools: Python 3 compatibility Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190306175210.28145-3-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.