qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [Qemu-devel] [Patch v2] Provided python3 support for qmp.py 2/2]
       [not found] <1490174864-7454-1-git-send-email-nanjekyejoannah@gmail.com>
@ 2017-03-24 18:04 ` Stefan Hajnoczi
  0 siblings, 0 replies; only message in thread
From: Stefan Hajnoczi @ 2017-03-24 18:04 UTC (permalink / raw)
  To: Joannah Nanjekye; +Cc: qemu-devel, jsnow

[-- Attachment #1: Type: text/plain, Size: 4615 bytes --]

On Wed, Mar 22, 2017 at 12:27:44PM +0300, Joannah Nanjekye wrote:
> From: nanjekyejoannah <nanjekyejoannah@gmail.com>

Thanks for the patch!

> 
> Signed-off-by: nanjekyejoannah <nanjekyejoannah@gmail.com>
> 
> 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 <armbru@redhat.com>.  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):

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-24 18:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1490174864-7454-1-git-send-email-nanjekyejoannah@gmail.com>
2017-03-24 18:04 ` [Qemu-devel] [Patch v2] Provided python3 support for qmp.py 2/2] Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).