qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Eduardo Habkost <eduardo@habkost.net>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Hanna Reitz <hreitz@redhat.com>, Cleber Rosa <crosa@redhat.com>,
	John Snow <jsnow@redhat.com>
Subject: [RFC PATCH 4/9] scripts/qmp: update remaining forwarder stubs
Date: Thu, 16 Dec 2021 21:29:34 -0500	[thread overview]
Message-ID: <20211217022939.279559-5-jsnow@redhat.com> (raw)
In-Reply-To: <20211217022939.279559-1-jsnow@redhat.com>

The text for each forwarder is largely the same, though the qom-fuse
stub instructs users to install the optional fuse dependency for the
qemu package.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qmp/qemu-ga-client | 40 ++++++++++++++++++++++++++++++++-----
 scripts/qmp/qom-fuse       | 40 ++++++++++++++++++++++++++++++++-----
 scripts/qmp/qom-get        | 40 ++++++++++++++++++++++++++++++++-----
 scripts/qmp/qom-list       | 40 ++++++++++++++++++++++++++++++++-----
 scripts/qmp/qom-set        | 40 ++++++++++++++++++++++++++++++++-----
 scripts/qmp/qom-tree       | 41 +++++++++++++++++++++++++++++++++-----
 6 files changed, 211 insertions(+), 30 deletions(-)

diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client
index 56edd0234a..f9c4087a56 100755
--- a/scripts/qmp/qemu-ga-client
+++ b/scripts/qmp/qemu-ga-client
@@ -1,11 +1,41 @@
 #!/usr/bin/env python3
 
-import os
 import sys
 
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.utils import qemu_ga_client
+try:
+    from qemu.utils import qemu_ga_client
+    _HAVE_DEPS = True
+except ModuleNotFoundError:
+    _HAVE_DEPS = False
 
+bold = "\033[1m"
+end = "\033[0m"
+cmd = 'qemu-ga-client'
 
-if __name__ == '__main__':
-    sys.exit(qemu_ga_client.main())
+EMSG = f"""
+{bold}'{sys.argv[0]}' is just a forwarder, and is not necessary.{end}
+
+However, there are missing dependencies to run this script.
+
+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:
+ > cd ../../python/
+ > pip3 install --user .
+ > export PATH=$PATH:~/.local/bin/
+ > {cmd} --help
+
+Alternatively, after installing the qemu package, this forwarder
+will work again. However, it will eventually be removed. I apologize for
+the inconvenience!"""
+
+if not _HAVE_DEPS:
+    print(EMSG, file=sys.stderr)
+    sys.exit(1)
+
+sys.exit(qemu_ga_client.main())
diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse
index d453807b27..e9edf01550 100755
--- a/scripts/qmp/qom-fuse
+++ b/scripts/qmp/qom-fuse
@@ -1,11 +1,41 @@
 #!/usr/bin/env python3
 
-import os
 import sys
 
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.utils.qom_fuse import QOMFuse
+try:
+    from qemu.utils.qom_fuse import QOMFuse
+    _HAVE_DEPS = True
+except ModuleNotFoundError:
+    _HAVE_DEPS = False
 
+bold = "\033[1m"
+end = "\033[0m"
+cmd = 'qom-fuse'
 
-if __name__ == '__main__':
-    sys.exit(QOMFuse.entry_point())
+EMSG = f"""
+{bold}'{sys.argv[0]}' is just a forwarder, and is not necessary.{end}
+
+However, there are missing dependencies to run this script.
+
+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:
+ > cd ../../python/
+ > pip3 install --user .[fuse]
+ > export PATH=$PATH:~/.local/bin/
+ > {cmd} --help
+
+Alternatively, after installing the qemu[fuse] package, this forwarder
+will work again. However, it will eventually be removed. I apologize for
+the inconvenience!"""
+
+if not _HAVE_DEPS:
+    print(EMSG, file=sys.stderr)
+    sys.exit(1)
+
+sys.exit(QOMFuse.entry_point())
diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get
index 04ebe052e8..9fa3e1c270 100755
--- a/scripts/qmp/qom-get
+++ b/scripts/qmp/qom-get
@@ -1,11 +1,41 @@
 #!/usr/bin/env python3
 
-import os
 import sys
 
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.utils.qom import QOMGet
+try:
+    from qemu.utils.qom import QOMGet
+    _HAVE_DEPS = True
+except ModuleNotFoundError:
+    _HAVE_DEPS = False
 
+bold = "\033[1m"
+end = "\033[0m"
+cmd = 'qom-get'
 
-if __name__ == '__main__':
-    sys.exit(QOMGet.entry_point())
+EMSG = f"""
+{bold}'{sys.argv[0]}' is just a forwarder, and is not necessary.{end}
+
+However, there are missing dependencies to run this script.
+
+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:
+ > cd ../../python/
+ > pip3 install --user .
+ > export PATH=$PATH:~/.local/bin/
+ > {cmd} --help
+
+Alternatively, after installing the qemu package, this forwarder
+will work again. However, it will eventually be removed. I apologize for
+the inconvenience!"""
+
+if not _HAVE_DEPS:
+    print(EMSG, file=sys.stderr)
+    sys.exit(1)
+
+sys.exit(QOMGet.entry_point())
diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list
index 853b85a8d3..6c6e4074e9 100755
--- a/scripts/qmp/qom-list
+++ b/scripts/qmp/qom-list
@@ -1,11 +1,41 @@
 #!/usr/bin/env python3
 
-import os
 import sys
 
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.utils.qom import QOMList
+try:
+    from qemu.utils.qom import QOMList
+    _HAVE_DEPS = True
+except ModuleNotFoundError:
+    _HAVE_DEPS = False
 
+bold = "\033[1m"
+end = "\033[0m"
+cmd = 'qom-list'
 
-if __name__ == '__main__':
-    sys.exit(QOMList.entry_point())
+EMSG = f"""
+{bold}'{sys.argv[0]}' is just a forwarder, and is not necessary.{end}
+
+However, there are missing dependencies to run this script.
+
+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:
+ > cd ../../python/
+ > pip3 install --user .
+ > export PATH=$PATH:~/.local/bin/
+ > {cmd} --help
+
+Alternatively, after installing the qemu package, this forwarder
+will work again. However, it will eventually be removed. I apologize for
+the inconvenience!"""
+
+if not _HAVE_DEPS:
+    print(EMSG, file=sys.stderr)
+    sys.exit(1)
+
+sys.exit(QOMList.entry_point())
diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
index 06820feec4..bcdee0e2d5 100755
--- a/scripts/qmp/qom-set
+++ b/scripts/qmp/qom-set
@@ -1,11 +1,41 @@
 #!/usr/bin/env python3
 
-import os
 import sys
 
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.utils.qom import QOMSet
+try:
+    from qemu.utils.qom import QOMSet
+    _HAVE_DEPS = True
+except ModuleNotFoundError:
+    _HAVE_DEPS = False
 
+bold = "\033[1m"
+end = "\033[0m"
+cmd = 'qom-set'
 
-if __name__ == '__main__':
-    sys.exit(QOMSet.entry_point())
+EMSG = f"""
+{bold}'{sys.argv[0]}' is just a forwarder, and is not necessary.{end}
+
+However, there are missing dependencies to run this script.
+
+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:
+ > cd ../../python/
+ > pip3 install --user .
+ > export PATH=$PATH:~/.local/bin/
+ > {cmd} --help
+
+Alternatively, after installing the qemu package, this forwarder
+will work again. However, it will eventually be removed. I apologize for
+the inconvenience!"""
+
+if not _HAVE_DEPS:
+    print(EMSG, file=sys.stderr)
+    sys.exit(1)
+
+sys.exit(QOMSet.entry_point())
diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree
index 760e172277..c9c1247f18 100755
--- a/scripts/qmp/qom-tree
+++ b/scripts/qmp/qom-tree
@@ -1,11 +1,42 @@
 #!/usr/bin/env python3
 
-import os
 import sys
 
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.utils.qom import QOMTree
+try:
+    from qemu.utils.qom import QOMTree
+    _HAVE_DEPS = True
+except ModuleNotFoundError:
+    _HAVE_DEPS = False
 
+bold = "\033[1m"
+end = "\033[0m"
+cmd = 'qom-tree'
 
-if __name__ == '__main__':
-    sys.exit(QOMTree.entry_point())
+EMSG = f"""
+{bold}'{sys.argv[0]}' is just a forwarder, and is not necessary.{end}
+
+However, there are missing dependencies to run this script.
+
+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:
+ > cd ../../python/
+ > pip3 install --user .
+ > export PATH=$PATH:~/.local/bin/
+ > {cmd} --help
+
+Alternatively, after installing the qemu package, this forwarder
+will work again. However, it will eventually be removed. I apologize for
+the inconvenience!"""
+
+if not _HAVE_DEPS:
+    print(EMSG, file=sys.stderr)
+    sys.exit(1)
+
+sys.exit(QOMTree.entry_point())
+k
-- 
2.31.1



  parent reply	other threads:[~2021-12-17  2:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17  2:29 [RFC PATCH 0/9] Python: Switch to externally hosted qemu.qmp dependency John Snow
2021-12-17  2:29 ` [RFC PATCH 1/9] Python: Update mypy dependency to >= 0.780 John Snow
2021-12-17  2:29 ` [RFC PATCH 2/9] Python: update isort dependency John Snow
2021-12-17  2:29 ` [RFC PATCH 3/9] scripts/qmp: Update 'qmp-shell' forwarder stub John Snow
2021-12-17  2:29 ` John Snow [this message]
2021-12-17  2:29 ` [RFC PATCH 5/9] scripts/qmp: delete qmp.py script stub John Snow
2021-12-17  2:29 ` [RFC PATCH 6/9] scripts: remove sys.path hacks for qemu/qemu.qmp John Snow
2021-12-17  2:29 ` [RFC PATCH 7/9] iotests/testenv: initialize an iotests venv John Snow
2021-12-17  2:29 ` [RFC PATCH 8/9] Python: delete qemu.qmp John Snow
2021-12-17  2:29 ` [RFC PATCH 9/9] (WIP) Python: update Pipfile John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211217022939.279559-5-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).