[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Patch v2] Provided python3 support for qmp.py 2/2]
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [Patch v2] Provided python3 support for qmp.py 2/2] |
Date: |
Fri, 24 Mar 2017 18:04:45 +0000 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Wed, Mar 22, 2017 at 12:27:44PM +0300, Joannah Nanjekye wrote:
> From: nanjekyejoannah <address@hidden>
Thanks for the patch!
>
> Signed-off-by: nanjekyejoannah <address@hidden>
>
> The patch provides python 3 support for one of the scripts in scripts/qmp
> that is to say qmp.py. This is not a port to python 3 but rather the patch
> ensures that the script runs fine for both python 2 and 3.
>
> Minimum Python Versions supported:
>
> Python 2 : python 2.6 +
> Python 3 : python 3.3 +
>
> The two new imports future and builtins introduced refer to the future
> pip-installable package on PyPI.
Signed-off-by goes here (after the commit description).
>
> ---
> diff --git a/scripts/qmp/qmp.py b/scripts/qmp/qmp.py
> index 6dcb870..57ac86b 100644
> --- a/scripts/qmp/qmp.py
> +++ b/scripts/qmp/qmp.py
> @@ -8,8 +8,6 @@
> # This work is licensed under the terms of the GNU GPL, version 2. See
> # the COPYING file in the top-level directory.
> from __future__ import absolute_import, print_function, unicode_literals
> -from future.utils import raise_from
> -from builtins import str
This looks like a patch on top of your previous patch.
Please send a v3 patch that applies directly to qemu.git/master. You
may need to use "git rebase -i master" to squash intermediate commits
you've made together into a single patch. Logically these changes are
part of the same code change so there's no need for multiple patches.
The v3 patch email should be:
[PATCH v3] scripts/qmp: python3 support for qmp.py
Please also CC Markus Armbruster <address@hidden>. He is the
maintainer of this file (you can check for maintainers using
scripts/get_maintainer.pl -f scripts/qmp.py).
> import json
> import errno
> import socket
> @@ -58,13 +56,13 @@ class QEMUMonitorProtocol:
>
> def __negotiate_capabilities(self):
> greeting = self.__json_read()
> - if greeting is None or not greeting.has_key('QMP'):
> - raise_from(QMPConnectError())
> + if greeting is None or not 'QMP' in list(greeting):
> + raise QMPConnectError()
> # Greeting seems ok, negotiate capabilities
> resp = self.cmd('qmp_capabilities')
> if "return" in resp:
> return greeting
> - raise_from(QMPCapabilitiesError())
> + raise QMPCapabilitiesError()
>
> def __json_read(self, only_event=False):
> while True:
> @@ -74,7 +72,7 @@ class QEMUMonitorProtocol:
> resp = json.loads(data)
> if 'event' in resp:
> if self._debug:
> - print(u"QMP:<<< %s" % str(resp), file=sys.stderr)
> + print(u"QMP:<<< %s" % resp, file=sys.stderr)
> self.__events.append(resp)
> if not only_event:
> continue
> @@ -113,11 +111,11 @@ class QEMUMonitorProtocol:
> try:
> ret = self.__json_read(only_event=True)
> except socket.timeout:
> - raise_from(QMPTimeoutError("Timeout waiting for event"))
> + raise QMPTimeoutError("Timeout waiting for event")
> except:
> - raise_from(QMPConnectError("Error while reading from
> socket"))
> + raise(QMPConnectError("Error while reading from socket"))
> if ret is None:
> - raise_from(QMPConnectError("Error while reading from
> socket"))
> + raise QMPConnectError("Error while reading from socket")
> self.__sock.settimeout(None)
>
> def connect(self, negotiate=True):
> @@ -157,16 +155,16 @@ class QEMUMonitorProtocol:
> been closed
> """
> if self._debug:
> - print(u"QMP:>>> %s" % str(qmp_cmd), file=sys.stderr)
> + print(u"QMP:>>> %s" % qmp_cmd, file=sys.stderr)
> try:
> - self.__sock.sendall(json.dumps(qmp_cmd))
> + self.__sock.sendall((json.dumps(qmp_cmd)).encode('latin-1'))
> except socket.error as err:
> if err[0] == errno.EPIPE:
> return
> - raise_from(socket.error(), err)
> + raise (socket.error(), err)
> resp = self.__json_read()
> if self._debug:
> - print(u"QMP:<<< %s" % str(resp), file=sys.stderr)
> + print(u"QMP:<<< %s" % resp, file=sys.stderr)
> return resp
>
> def cmd(self, name, args=None, id=None):
signature.asc
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [Patch v2] Provided python3 support for qmp.py 2/2],
Stefan Hajnoczi <=