[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 52/72] scripts/qmp-shell: move the REPL functionality into QMPShel
From: |
John Snow |
Subject: |
[PULL 52/72] scripts/qmp-shell: move the REPL functionality into QMPShell |
Date: |
Fri, 18 Jun 2021 19:04:35 -0400 |
Instead of doing this in main, move it into the class itself. (This
makes it easier to put into the qemu.qmp package later by removing as
much as we can from the main() function.)
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20210607200649.1840382-23-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qmp/qmp-shell | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index 31269859c4..aa148517a8 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -318,6 +318,12 @@ class QMPShell(qmp.QEMUMonitorProtocol):
return self._execute_cmd(cmdline)
+ def repl(self):
+ self.show_banner()
+ while self.read_exec_command():
+ yield
+ self.close()
+
class HMPShell(QMPShell):
def __init__(self, address, pretty=False, verbose=False):
@@ -435,10 +441,8 @@ def main():
except OSError as err:
die(f"Couldn't connect to {args.qmp_server}: {err!s}")
- qemu.show_banner()
- while qemu.read_exec_command():
+ for _ in qemu.repl():
pass
- qemu.close()
if __name__ == '__main__':
--
2.31.1
- [PULL 41/72] scripts/qmp-shell: ignore visit_Name name, (continued)
- [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
- [PULL 51/72] scripts/qmp-shell: remove prompt argument from read_exec_command, John Snow, 2021/06/18
- [PULL 53/72] scripts/qmp-shell: Fix "FuzzyJSON" parser, John Snow, 2021/06/18
- [PULL 54/72] scripts/qmp-shell: refactor QMPCompleter, John Snow, 2021/06/18
- [PULL 52/72] scripts/qmp-shell: move the REPL functionality into QMPShell,
John Snow <=
- [PULL 47/72] scripts/qmp-shell: use argparse, John Snow, 2021/06/18
- [PULL 45/72] scripts/qmp-shell: remove if-raise-else patterns, John Snow, 2021/06/18
- [PULL 55/72] scripts/qmp-shell: initialize completer early, John Snow, 2021/06/18
- [PULL 56/72] python/qmp: add QMPObject type alias, John Snow, 2021/06/18
- [PULL 57/72] scripts/qmp-shell: add mypy types, John Snow, 2021/06/18
- [PULL 59/72] scripts/qmp-shell: unprivatize 'pretty' property, John Snow, 2021/06/18
- [PULL 60/72] python/qmp: return generic type from context manager, John Snow, 2021/06/18
- [PULL 64/72] scripts/qmp-shell: Fix empty-transaction invocation, John Snow, 2021/06/18
- [PULL 63/72] scripts/qmp-shell: remove TODO, John Snow, 2021/06/18
- [PULL 61/72] scripts/qmp-shell: Use context manager instead of atexit, John Snow, 2021/06/18