[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 49/72] scripts/qmp-shell: Make verbose a public attribute
From: |
John Snow |
Subject: |
[PULL 49/72] scripts/qmp-shell: Make verbose a public attribute |
Date: |
Fri, 18 Jun 2021 19:04:32 -0400 |
No real reason to hide this behind an underscore; make it part of the
initializer and make it a regular RW attribute.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-20-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qmp/qmp-shell | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index de5fa189f0..cfcefb95f9 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -113,7 +113,7 @@ class FuzzyJSON(ast.NodeTransformer):
# TODO: QMPShell's interface is a bit ugly (eg. _fill_completion() and
# _execute_cmd()). Let's design a better one.
class QMPShell(qmp.QEMUMonitorProtocol):
- def __init__(self, address, pretty=False):
+ def __init__(self, address, pretty=False, verbose=False):
super().__init__(self.parse_address(address))
self._greeting = None
self._completer = None
@@ -122,7 +122,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
self._actions = list()
self._histfile = os.path.join(os.path.expanduser('~'),
'.qmp-shell_history')
- self._verbose = False
+ self.verbose = verbose
def _fill_completion(self):
cmds = self.cmd('query-commands')
@@ -271,7 +271,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
# For transaction mode, we may have just cached the action:
if qmpcmd is None:
return True
- if self._verbose:
+ if self.verbose:
self._print(qmpcmd)
resp = self.cmd_obj(qmpcmd)
if resp is None:
@@ -317,13 +317,10 @@ class QMPShell(qmp.QEMUMonitorProtocol):
return self._execute_cmd(cmdline)
- def set_verbosity(self, verbose):
- self._verbose = verbose
-
class HMPShell(QMPShell):
- def __init__(self, address, pretty=False):
- super().__init__(address, pretty)
+ def __init__(self, address, pretty=False, verbose=False):
+ super().__init__(address, pretty, verbose)
self.__cpu_index = 0
def __cmd_completion(self):
@@ -423,7 +420,7 @@ def main():
shell_class = HMPShell if args.hmp else QMPShell
try:
- qemu = shell_class(args.qmp_server, args.pretty)
+ qemu = shell_class(args.qmp_server, args.pretty, args.verbose)
except qmp.QMPBadPortError:
parser.error(f"Bad port number: {args.qmp_server}")
return # pycharm doesn't know error() is noreturn
@@ -438,7 +435,6 @@ def main():
die(f"Couldn't connect to {args.qmp_server}: {err!s}")
qemu.show_banner()
- qemu.set_verbosity(args.verbose)
while qemu.read_exec_command(qemu.get_prompt()):
pass
qemu.close()
--
2.31.1
- [PULL 19/72] python/qmp: add fuse command to 'qom' tools, (continued)
- [PULL 19/72] python/qmp: add fuse command to 'qom' tools, John Snow, 2021/06/18
- [PULL 37/72] scripts/qmp-shell: use @classmethod where appropriate, John Snow, 2021/06/18
- [PULL 10/72] scripts/qom-fuse: Apply pylint rules, John Snow, 2021/06/18
- [PULL 21/72] scripts/qemu-ga-client: apply (most) flake8 rules, John Snow, 2021/06/18
- [PULL 29/72] python/qemu-ga-client: add entry point, John Snow, 2021/06/18
- [PULL 33/72] scripts/qmp-shell: fix show_banner signature, John Snow, 2021/06/18
- [PULL 48/72] scripts/qmp-shell: Add pretty attribute to HMP shell, John Snow, 2021/06/18
- [PULL 44/72] scripts/qmp-shell: fix shell history exception handling, John Snow, 2021/06/18
- [PULL 46/72] scripts/qmp-shell: use isinstance() instead of type(), John Snow, 2021/06/18
- [PULL 43/72] scripts/qmp-shell: rename one and two-letter variables, John Snow, 2021/06/18
- [PULL 49/72] scripts/qmp-shell: Make verbose a public attribute,
John Snow <=
- [PULL 31/72] scripts/qmp-shell: apply isort rules, John Snow, 2021/06/18
- [PULL 39/72] scripts/qmp-shell: declare verbose in __init__, John Snow, 2021/06/18
- [PULL 40/72] scripts/qmp-shell: use triple-double-quote docstring style, John Snow, 2021/06/18
- [PULL 41/72] scripts/qmp-shell: ignore visit_Name name, John Snow, 2021/06/18
- [PULL 42/72] scripts/qmp-shell: make QMPCompleter returns explicit, John Snow, 2021/06/18
- [PULL 50/72] scripts/qmp-shell: move get_prompt() to prompt property, John Snow, 2021/06/18
- [PULL 23/72] scripts/qemu-ga-client: replace deprecated optparse with argparse, John Snow, 2021/06/18
- [PULL 25/72] scripts/qemu-ga-client: apply (most) pylint rules, John Snow, 2021/06/18
- [PULL 24/72] scripts/qemu-ga-client: add module docstring, John Snow, 2021/06/18
- [PULL 34/72] scripts/qmp-shell: fix exception handling, John Snow, 2021/06/18