Richard W.M. Jones
2023-Jan-30 22:34 UTC
[Libguestfs] [libnbd PATCH v2 3/3] nbdsh: Improve --help and initial banner contents.
On Fri, Nov 04, 2022 at 04:18:31PM -0500, Eric Blake wrote:> Document all options in --help output. If -n is not in use, then > enhance the banner to print the current state of h, and further tailor > the advice given on useful next steps to take to mention opt_go when > using --opt-mode.I had to partially revert this patch (reverting most of it) because it unfortunately breaks the implicit handle creation :-( https://gitlab.com/nbdkit/libnbd/-/commit/5a02c7d2cc6a201f9e5531c0c20c2f3c22b805a2 I'm not actually sure how to do this correctly in Python. I made several attempts, but I don't think Python is very good about having a variable which is only defined on some paths -- maybe it's not possible at all. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Nir Soffer
2023-Jan-31 11:33 UTC
[Libguestfs] [libnbd PATCH v2 3/3] nbdsh: Improve --help and initial banner contents.
On Tue, Jan 31, 2023 at 12:34 AM Richard W.M. Jones <rjones at redhat.com> wrote:> > On Fri, Nov 04, 2022 at 04:18:31PM -0500, Eric Blake wrote: > > Document all options in --help output. If -n is not in use, then > > enhance the banner to print the current state of h, and further tailor > > the advice given on useful next steps to take to mention opt_go when > > using --opt-mode. > > I had to partially revert this patch (reverting most of it) because it > unfortunately breaks the implicit handle creation :-( > > https://gitlab.com/nbdkit/libnbd/-/commit/5a02c7d2cc6a201f9e5531c0c20c2f3c22b805a2 > > I'm not actually sure how to do this correctly in Python. I made > several attempts, but I don't think Python is very good about having a > variable which is only defined on some paths -- maybe it's not > possible at all.Can you share the error when it breaks? I'm not sure what is the issue, but usually if you have a global variable created only in some flows, adding: thing = None At the start of the module makes sure that the name exists later, regardless of the flow taken. Code can take the right action based on: if thing is None: ... Nir
Seemingly Similar Threads
- [libnbd PATCH v2 3/3] nbdsh: Improve --help and initial banner contents.
- [libnbd PATCH v2 3/3] nbdsh: Improve --help and initial banner contents.
- [libnbd PATCH v2 3/3] nbdsh: Improve --help and initial banner contents.
- [libnbd PATCH v2 0/3] Improve nbdsh -u handling
- [PATCH nbdkit] tests: Convert some tests to use nbdsh instead of qemu-io.