[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v2 11/11] QMP/qmp.py: set locale for exceptions
From: |
Tomoki Sekiyama |
Subject: |
[Qemu-devel] [RFC PATCH v2 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly |
Date: |
Fri, 12 Apr 2013 16:02:15 -0400 |
User-agent: |
StGit/0.16 |
qemu-ga in Windows might return error message with multibyte characters
when the guest OS language is set to other than English. To display such
messages correctly, this decodes the message based on locale settings.
Signed-off-by: Tomoki Sekiyama <address@hidden>
---
QMP/qmp.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/QMP/qmp.py b/QMP/qmp.py
index c551df1..ee21819 100644
--- a/QMP/qmp.py
+++ b/QMP/qmp.py
@@ -11,6 +11,7 @@
import json
import errno
import socket
+import locale
class QMPError(Exception):
pass
@@ -133,7 +134,8 @@ class QEMUMonitorProtocol:
def command(self, cmd, **kwds):
ret = self.cmd(cmd, kwds)
if ret.has_key('error'):
- raise Exception(ret['error']['desc'])
+ enc = locale.getpreferredencoding()
+ raise Exception(ret['error']['desc'].encode(enc))
return ret['return']
def pull_event(self, wait=False):
- [Qemu-devel] [RFC PATCH v2 01/11] configure: Support configuring c++ compiler, (continued)
- [Qemu-devel] [RFC PATCH v2 01/11] configure: Support configuring c++ compiler, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 02/11] Fix errors and warnings while compiling with c++ compilier, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 03/11] Add a script to extract VSS SDK headers on POSIX system, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 04/11] qemu-ga: Add an configure option to specify path to Windows VSS SDK, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 06/11] qemu-ga: Add Windows VSS requester to quisce applications and filesystems, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 07/11] qemu-ga: call Windows VSS requester in fsfreeze command handler, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 05/11] qemu-ga: Add Windows VSS provider to quiesce applications on fsfreeze, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 08/11] qemu-ga: install Windows VSS provider on `qemu-ga -s install', Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 09/11] qemu-ga: Add VSS provider .tlb file in the repository, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 10/11] QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze command, Tomoki Sekiyama, 2013/04/12
- [Qemu-devel] [RFC PATCH v2 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly,
Tomoki Sekiyama <=
- Re: [Qemu-devel] [RFC PATCH v2 00/11] qemu-ga: fsfreeze on Windows using VSS, Libaiqing, 2013/04/23