mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
python: futurize -f libfuturize.fixes.fix_print_with_import
Change all Python code to use print as a function. This is necessary for Python 3 compatibility. Done using: $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \ sort -u | grep -v README.sh4) $ futurize -w -f libfuturize.fixes.fix_print_with_import $py Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Acked-by: Fam Zheng <famz@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20180608122952.2009-2-ehabkost@redhat.com> [ehabkost: fixup tests/docker/docker.py] Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
0d2fa03dae
commit
f03868bd56
32 changed files with 281 additions and 256 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue