test suite reviews and discussions
 help / color / mirror / Atom feed
From: lihong <lihongx.ma@intel.com>
To: dts@dpdk.org, weix.xie@intel.com
Cc: lihong <lihongx.ma@intel.com>
Subject: [dts] [PATCH V1 1/2] QMP: optimization file qemu-ga-client and qmp.py
Date: Thu,  4 Jun 2020 09:38:19 +0800	[thread overview]
Message-ID: <1591234700-19815-2-git-send-email-lihongx.ma@intel.com> (raw)
In-Reply-To: <1591234700-19815-1-git-send-email-lihongx.ma@intel.com>

1. modify code to support python3
2. return None string if file not exist when use cat command

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 dep/QMP/qemu-ga-client | 10 ++++++----
 dep/QMP/qmp.py         |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/dep/QMP/qemu-ga-client b/dep/QMP/qemu-ga-client
index 46676c3..caf44b1 100755
--- a/dep/QMP/qemu-ga-client
+++ b/dep/QMP/qemu-ga-client
@@ -68,7 +68,7 @@ class QemuGuestAgentClient:
 
     def __file_read_all(self, handle):
         eof = False
-        data = ''
+        data = b''
         while not eof:
             ret = self.qga.file_read(handle=handle, count=1024)
             _data = base64.b64decode(ret['buf-b64'])
@@ -77,7 +77,10 @@ class QemuGuestAgentClient:
         return data
 
     def read(self, path):
-        handle = self.qga.file_open(path=path)
+        try:
+            handle = self.qga.file_open(path=path)
+        except:
+            return ''
         try:
             data = self.__file_read_all(handle)
         finally:
@@ -162,7 +165,6 @@ class QemuGuestAgentClient:
         except self.qga.timeout:
             return
 
-
 def _cmd_cat(client, args):
     if len(args) != 1:
         print('Invalid argument')
@@ -259,7 +261,7 @@ def main(address, cmd, args):
 
     try:
         client = QemuGuestAgentClient(address)
-    except QemuGuestAgent.error, e:
+    except QemuGuestAgent.error as e:
         import errno
 
         print(e)
diff --git a/dep/QMP/qmp.py b/dep/QMP/qmp.py
index 9e6f4cf..430887d 100755
--- a/dep/QMP/qmp.py
+++ b/dep/QMP/qmp.py
@@ -108,7 +108,7 @@ class QEMUMonitorProtocol:
                 been closed
         """
         try:
-            self.__sock.sendall(json.dumps(qmp_cmd))
+            self.__sock.sendall(str.encode(json.dumps(qmp_cmd)))
         except socket.error as err:
             if err[0] == errno.EPIPE:
                 return
@@ -135,7 +135,7 @@ class QEMUMonitorProtocol:
         if not ret:
             return
         else:
-            if 'error' in ret:
+            if 'error' in ret.keys():
                 raise Exception(ret['error']['desc'])
             return ret['return']
 
-- 
2.7.4


  reply	other threads:[~2020-06-04  9:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04  1:38 [dts] [PATCH V1 0/2] fix issue of ssh vm lihong
2020-06-04  1:38 ` lihong [this message]
2020-06-05  7:48   ` [dts] [PATCH V1 1/2] QMP: optimization file qemu-ga-client and qmp.py Xie, WeiX
2020-06-04  1:38 ` [dts] [PATCH V1 2/2] framework/qemu_kvm: check the ssh service status before get vm ip lihong
2020-06-04  9:26   ` Xie, WeiX
2020-06-11 12:17 ` [dts] [PATCH V1 0/2] fix issue of ssh vm Tu, Lijuan

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=1591234700-19815-2-git-send-email-lihongx.ma@intel.com \
    --to=lihongx.ma@intel.com \
    --cc=dts@dpdk.org \
    --cc=weix.xie@intel.com \
    /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).