aboutsummaryrefslogtreecommitdiff
path: root/scripts/qmp/qmp-shell
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/qmp/qmp-shell')
-rwxr-xr-xscripts/qmp/qmp-shell35
1 files changed, 18 insertions, 17 deletions
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index be449de621..b1cc7e2271 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -65,6 +65,7 @@
# which will echo back the properly formatted JSON-compliant QMP that is being
# sent to QEMU, which is useful for debugging and documentation generation.
+from __future__ import print_function
import qmp
import json
import ast
@@ -153,14 +154,14 @@ class QMPShell(qmp.QEMUMonitorProtocol):
# File not found. No problem.
pass
else:
- print "Failed to read history '%s'; %s" % (self._histfile, e)
+ print("Failed to read history '%s'; %s" % (self._histfile, e))
atexit.register(self.__save_history)
def __save_history(self):
try:
readline.write_history_file(self._histfile)
except Exception as e:
- print "Failed to save history file '%s'; %s" % (self._histfile, e)
+ print("Failed to save history file '%s'; %s" % (self._histfile, e))
def __parse_value(self, val):
try:
@@ -258,15 +259,15 @@ class QMPShell(qmp.QEMUMonitorProtocol):
if self._pretty:
indent = 4
jsobj = json.dumps(qmp, indent=indent)
- print str(jsobj)
+ print(str(jsobj))
def _execute_cmd(self, cmdline):
try:
qmpcmd = self.__build_cmd(cmdline)
except Exception as e:
- print 'Error while parsing command line: %s' % e
- print 'command format: <command-name> ',
- print '[arg-name1=arg1] ... [arg-nameN=argN]'
+ print('Error while parsing command line: %s' % e)
+ print('command format: <command-name> ', end=' ')
+ print('[arg-name1=arg1] ... [arg-nameN=argN]')
return True
# For transaction mode, we may have just cached the action:
if qmpcmd is None:
@@ -275,7 +276,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
self._print(qmpcmd)
resp = self.cmd_obj(qmpcmd)
if resp is None:
- print 'Disconnected'
+ print('Disconnected')
return False
self._print(resp)
return True
@@ -285,12 +286,12 @@ class QMPShell(qmp.QEMUMonitorProtocol):
self.__completer_setup()
def show_banner(self, msg='Welcome to the QMP low-level shell!'):
- print msg
+ print(msg)
if not self._greeting:
- print 'Connected'
+ print('Connected')
return
version = self._greeting['QMP']['version']['qemu']
- print 'Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro'])
+ print('Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro']))
def get_prompt(self):
if self._transmode:
@@ -306,11 +307,11 @@ class QMPShell(qmp.QEMUMonitorProtocol):
try:
cmdline = raw_input(prompt)
except EOFError:
- print
+ print()
return False
if cmdline == '':
for ev in self.get_events():
- print ev
+ print(ev)
self.clear_events()
return True
else:
@@ -366,24 +367,24 @@ class HMPShell(QMPShell):
try:
idx = int(cmdline.split()[1])
if not 'return' in self.__cmd_passthrough('info version', idx):
- print 'bad CPU index'
+ print('bad CPU index')
return True
self.__cpu_index = idx
except ValueError:
- print 'cpu command takes an integer argument'
+ print('cpu command takes an integer argument')
return True
resp = self.__cmd_passthrough(cmdline, self.__cpu_index)
if resp is None:
- print 'Disconnected'
+ print('Disconnected')
return False
assert 'return' in resp or 'error' in resp
if 'return' in resp:
# Success
if len(resp['return']) > 0:
- print resp['return'],
+ print(resp['return'], end=' ')
else:
# Error
- print '%s: %s' % (resp['error']['class'], resp['error']['desc'])
+ print('%s: %s' % (resp['error']['class'], resp['error']['desc']))
return True
def show_banner(self):