qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Joannah Nanjekye <nanjekyejoannah@gmail.com>
Cc: qemu-devel@nongnu.org, jsnow@redhat.com
Subject: Re: [Qemu-devel] [Patch v2] Provided python3 support for qmp.py 2/2]
Date: Fri, 24 Mar 2017 18:04:45 +0000	[thread overview]
Message-ID: <20170324180445.GA6789@stefanha-x1.localdomain> (raw)
In-Reply-To: <1490174864-7454-1-git-send-email-nanjekyejoannah@gmail.com>

[-- 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 --]

           reply	other threads:[~2017-03-24 18:04 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1490174864-7454-1-git-send-email-nanjekyejoannah@gmail.com>]

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=20170324180445.GA6789@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=nanjekyejoannah@gmail.com \
    --cc=qemu-devel@nongnu.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 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).