Skip to content

Commit

Permalink
scripts/qmp: Use Python 2.6 "except E as ..." syntax
Browse files Browse the repository at this point in the history
PEP 8 calls for it, because it's forward compatible with Python 3.
Supported since Python 2.6, which we require (commit fec2103).

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <1450425164-24969-3-git-send-email-armbru@redhat.com>
  • Loading branch information
Markus Armbruster committed Feb 8, 2016
1 parent 291928a commit cf6c634
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/qmp/qemu-ga-client
Expand Up @@ -259,7 +259,7 @@ def main(address, cmd, args):

try:
client = QemuGuestAgentClient(address)
except QemuGuestAgent.error, e:
except QemuGuestAgent.error as e:
import errno

print(e)
Expand Down
4 changes: 2 additions & 2 deletions scripts/qmp/qmp
Expand Up @@ -91,8 +91,8 @@ def main(args):
try:
os.environ['QMP_PATH'] = path
os.execvp(fullcmd, [fullcmd] + args)
except OSError, (errno, msg):
if errno == 2:
except OSError as exc:
if exc.errno == 2:
print 'Command "%s" not found.' % (fullcmd)
return 1
raise
Expand Down
2 changes: 1 addition & 1 deletion scripts/qmp/qmp-shell
Expand Up @@ -240,7 +240,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
def _execute_cmd(self, cmdline):
try:
qmpcmd = self.__build_cmd(cmdline)
except Exception, e:
except Exception as e:
print 'Error while parsing command line: %s' % e
print 'command format: <command-name> ',
print '[arg-name1=arg1] ... [arg-nameN=argN]'
Expand Down
4 changes: 2 additions & 2 deletions scripts/qmp/qmp.py
Expand Up @@ -92,7 +92,7 @@ def __get_events(self, wait=False):
self.__sock.setblocking(0)
try:
self.__json_read()
except socket.error, err:
except socket.error as err:
if err[0] == errno.EAGAIN:
# No data available
pass
Expand Down Expand Up @@ -150,7 +150,7 @@ def cmd_obj(self, qmp_cmd):
"""
try:
self.__sock.sendall(json.dumps(qmp_cmd))
except socket.error, err:
except socket.error as err:
if err[0] == errno.EPIPE:
return
raise socket.error(err)
Expand Down

0 comments on commit cf6c634

Please sign in to comment.