提交 cf6c6345 编写于 作者: M Markus Armbruster

scripts/qmp: Use Python 2.6 "except E as ..." syntax

PEP 8 calls for it, because it's forward compatible with Python 3.
Supported since Python 2.6, which we require (commit fec21036).
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Acked-by: NStefan Hajnoczi <stefanha@redhat.com>
Message-Id: <1450425164-24969-3-git-send-email-armbru@redhat.com>
上级 291928a8
...@@ -259,7 +259,7 @@ def main(address, cmd, args): ...@@ -259,7 +259,7 @@ def main(address, cmd, args):
try: try:
client = QemuGuestAgentClient(address) client = QemuGuestAgentClient(address)
except QemuGuestAgent.error, e: except QemuGuestAgent.error as e:
import errno import errno
print(e) print(e)
......
...@@ -91,8 +91,8 @@ def main(args): ...@@ -91,8 +91,8 @@ def main(args):
try: try:
os.environ['QMP_PATH'] = path os.environ['QMP_PATH'] = path
os.execvp(fullcmd, [fullcmd] + args) os.execvp(fullcmd, [fullcmd] + args)
except OSError, (errno, msg): except OSError as exc:
if errno == 2: if exc.errno == 2:
print 'Command "%s" not found.' % (fullcmd) print 'Command "%s" not found.' % (fullcmd)
return 1 return 1
raise raise
......
...@@ -240,7 +240,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): ...@@ -240,7 +240,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
def _execute_cmd(self, cmdline): def _execute_cmd(self, cmdline):
try: try:
qmpcmd = self.__build_cmd(cmdline) qmpcmd = self.__build_cmd(cmdline)
except Exception, e: except Exception as e:
print 'Error while parsing command line: %s' % e print 'Error while parsing command line: %s' % e
print 'command format: <command-name> ', print 'command format: <command-name> ',
print '[arg-name1=arg1] ... [arg-nameN=argN]' print '[arg-name1=arg1] ... [arg-nameN=argN]'
......
...@@ -92,7 +92,7 @@ class QEMUMonitorProtocol: ...@@ -92,7 +92,7 @@ class QEMUMonitorProtocol:
self.__sock.setblocking(0) self.__sock.setblocking(0)
try: try:
self.__json_read() self.__json_read()
except socket.error, err: except socket.error as err:
if err[0] == errno.EAGAIN: if err[0] == errno.EAGAIN:
# No data available # No data available
pass pass
...@@ -150,7 +150,7 @@ class QEMUMonitorProtocol: ...@@ -150,7 +150,7 @@ class QEMUMonitorProtocol:
""" """
try: try:
self.__sock.sendall(json.dumps(qmp_cmd)) self.__sock.sendall(json.dumps(qmp_cmd))
except socket.error, err: except socket.error as err:
if err[0] == errno.EPIPE: if err[0] == errno.EPIPE:
return return
raise socket.error(err) raise socket.error(err)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册