qemu-block
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]