[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 3/9] scripts/qmp: Update 'qmp-shell' forwarder stub
From: |
John Snow |
Subject: |
[RFC PATCH 3/9] scripts/qmp: Update 'qmp-shell' forwarder stub |
Date: |
Thu, 16 Dec 2021 21:29:33 -0500 |
The text here is slightly different than the text in other forwarder
stubs in this directory, because the only dependency needed here is
outside of the QEMU source tree entirely.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qmp/qmp-shell | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index 4a20f97db7..1d30425547 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -1,11 +1,40 @@
#!/usr/bin/env python3
-import os
import sys
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.qmp import qmp_shell
+try:
+ from qemu.qmp import qmp_shell
+ _HAVE_QMP = True
+except ModuleNotFoundError:
+ _HAVE_QMP = False
+bold = "\033[1m"
+end = "\033[0m"
+cmd = 'qmp-shell'
-if __name__ == '__main__':
- qmp_shell.main()
+EMSG = f"""
+{bold}'{sys.argv[0]}' is just a forwarder, and is not necessary.{end}
+
+However, the 'qemu.qmp' package is not installed.
+
+To use the '{cmd}' command directly from the installed package,
+install the python package and then add (for a --user install)
+~/.local/bin/ to $PATH if it isn't already. Then, you should have access
+to the '{cmd}' command.
+
+For more information, please see ../../python/README.rst.
+
+maybe:
+ > pip3 install --user qemu.qmp
+ > export PATH=$PATH:~/.local/bin/
+ > {cmd} --help
+
+Alternatively, after installing the qemu.qmp package, this forwarder
+will work again. However, it will eventually be removed. I apologize for
+the inconvenience!"""
+
+if not _HAVE_QMP:
+ print(EMSG, file=sys.stderr)
+ sys.exit(1)
+
+qmp_shell.main()
--
2.31.1
- [RFC PATCH 0/9] Python: Switch to externally hosted qemu.qmp dependency, John Snow, 2021/12/16
- [RFC PATCH 1/9] Python: Update mypy dependency to >= 0.780, John Snow, 2021/12/16
- [RFC PATCH 5/9] scripts/qmp: delete qmp.py script stub, John Snow, 2021/12/16
- [RFC PATCH 2/9] Python: update isort dependency, John Snow, 2021/12/16
- [RFC PATCH 4/9] scripts/qmp: update remaining forwarder stubs, John Snow, 2021/12/16
- [RFC PATCH 3/9] scripts/qmp: Update 'qmp-shell' forwarder stub,
John Snow <=
- [RFC PATCH 6/9] scripts: remove sys.path hacks for qemu/qemu.qmp, John Snow, 2021/12/16
- [RFC PATCH 7/9] iotests/testenv: initialize an iotests venv, John Snow, 2021/12/16
- [RFC PATCH 9/9] (WIP) Python: update Pipfile, John Snow, 2021/12/16
- [RFC PATCH 8/9] Python: delete qemu.qmp, John Snow, 2021/12/16