mirror of https://github.com/xemu-project/xemu.git
scripts/qmp-shell: use logging to show warnings
A perfect candidate is non-fatal shell history messages. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-33-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
This commit is contained in:
parent
d1d14e5989
commit
be19c6a712
|
@ -67,6 +67,7 @@
|
||||||
import argparse
|
import argparse
|
||||||
import ast
|
import ast
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import readline
|
import readline
|
||||||
|
@ -85,6 +86,9 @@ from qemu import qmp
|
||||||
from qemu.qmp import QMPMessage
|
from qemu.qmp import QMPMessage
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class QMPCompleter:
|
class QMPCompleter:
|
||||||
# NB: Python 3.9+ will probably allow us to subclass list[str] directly,
|
# NB: Python 3.9+ will probably allow us to subclass list[str] directly,
|
||||||
# but pylint as of today does not know that List[str] is simply 'list'.
|
# but pylint as of today does not know that List[str] is simply 'list'.
|
||||||
|
@ -167,13 +171,15 @@ class QMPShell(qmp.QEMUMonitorProtocol):
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
print(f"Failed to read history '{self._histfile}': {err!s}")
|
msg = f"Failed to read history '{self._histfile}': {err!s}"
|
||||||
|
LOG.warning(msg)
|
||||||
|
|
||||||
def _save_history(self) -> None:
|
def _save_history(self) -> None:
|
||||||
try:
|
try:
|
||||||
readline.write_history_file(self._histfile)
|
readline.write_history_file(self._histfile)
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
print(f"Failed to save history file '{self._histfile}': {err!s}")
|
msg = f"Failed to save history file '{self._histfile}': {err!s}"
|
||||||
|
LOG.warning(msg)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __parse_value(cls, val: str) -> object:
|
def __parse_value(cls, val: str) -> object:
|
||||||
|
|
Loading…
Reference in New Issue