Based-on: <20201020193555.1493936-1-js...@redhat.com> [PATCH v3 00/15] python: create installable package
Hi! This series looks big, but don't panic. Like many python refactoring series, most of the individual patches are very tiny, isolated changes. This series depends on the details of the installable package series, so don't sweat too hard reviewing the particulars just yet, or at all. I did want to showcase the process of moving scripts INTO the python library, though, so here it is. The purpose of this series is to move ./scripts/qmp/* to ./python/qemu/qmp/*.py. To do so, we need to ensure that these files pass the various linters and code quality standards we have instituted for the python library. Doing so allows us to check these tools with the same type checking utilities that we use to enforce integrity in the base library. This way, changes to the library will cause integration tests to fail, and we can ensure the continued stability of these scripts. Nicest of all, by installing this python package to your working environment, you will now have access to 'qom-set', 'qom-get', 'qmp-shell', etc no matter what your working directory is, and it will Just Work. Let's run down the list: - qom-set, qom-get, qom-tree, and qom-list are merged into a 'qom' tool. - qom-[set|get|tree|list] are still available under those names, too. - qemu-ga-client is lightly refurbished and is also now available. - qmp-shell is lightly polished and will be available. Patches 1-3: Introduce 'qom' tool, deprecate qom-[set|get|tree|list] Patches 4-16: port qom-fuse to qemu.qmp.qom tool Patches 17-27: port qemu-ga-client to qemu.qmp package Patches 28-72: port qmp-shell to qemu.qmp package Reviewer notes: - I just rewrote qom-xxx entirely, though it is based on the original scripts. Doing it brick by brick was too slow and awkward. - I added symlinks (not in git) to the old scripts in the new location to run the linters against the files that haven't been moved yet, and once they're almost done (except for import problems), I move them. - After moving scripts, I add a forwarder to the new location from the old location. The forwarders can be deleted eventually. - some scripts disappear for a commit or two before being re-established. This helps preserve git-blame history where it happens; it was the best I could do. John Snow (72): python/qmp: Add qom script rewrites python/qmp: add qom script entry points scripts/qmp: redirect qom-xxx scripts to python/qemu/qmp/ scripts/qom-fuse: apply isort rules scripts/qom-fuse: apply flake8 rules python: Add 'fh' to known-good variable names scripts/qom-fuse: Apply pylint rules scripts/qom-fuse: Add docstrings scripts/qom-fuse: Convert to QOMCommand scripts/qom-fuse: use QOMCommand.qom_list() scripts/qom-fuse: ensure QOMFuse.read always returns bytes scripts/qom-fuse: add static type hints scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.py scripts/qom-fuse: add redirection shim to python/qemu/qmp/qom-fuse.py python: add fuse command to 'qom' tools python: add optional fuse dependency scripts/qemu-ga-client: apply isort rules scripts/qemu-ga-client: apply (most) flake8 rules scripts/qemu-ga-client: Fix exception handling scripts/qemu-ga-client: replace deprecated optparse with argparse scripts/qemu-ga-client: add module docstring scripts/qemu-ga-client: apply (most) pylint rules python/qmp: Correct type of QMPReturnValue scripts/qmp/qemu-ga-client: add mypy type hints scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.py python/qemu-ga-client: add entry point scripts/qemu-ga-client: Add forwarder stub scripts/qmp-shell: apply isort rules scripts/qmp-shell: Apply flake8 rules scripts/qmp-shell: fix show_banner signature scripts/qmp-shell: fix exception handling scripts/qmp-shell: fix connect method signature scripts/qmp-shell: remove shadowed variable from _print() scripts/qmp-shell: use @classmethod where appropriate scripts/qmp-shell: Use python3-style super() scripts/qmp-shell: declare verbose in __init__ scripts/qmp-shell: use triple-double-quote docstring style scripts/qmp-shell: ignore visit_Name name scripts/qmp-shell: make QMPCompleter returns explicit scripts/qmp-shell: rename one and two-letter variables scripts/qmp-shell: fix shell history exception handling scripts/qmp-shell: explicitly chain exception context scripts/qmp-shell: remove if-raise-else patterns scripts/qmp-shell: use isinstance() instead of type() scripts/qmp-shell: use argparse python/qmp: Fix type of SocketAddrT python/qmp: add parse_address classmethod scripts/qmp-shell: Add pretty attribute to HMP shell scripts/qmp-shell: Make verbose a public attribute scripts/qmp-shell: move get_prompt() to prompt property scripts/qmp-shell: remove prompt argument from read_exec_command scripts/qmp-shell: move the REPL functionality into QMPShell scripts/qmp-shell: Fix "FuzzyJSON" parser scripts/qmp-shell: refactor QMPCompleter scripts/qmp-shell: initialize completer early python/qmp: add QMPObject type alias scripts/qmp-shell: add mypy types scripts/qmp-shell: Accept SocketAddrT instead of string scripts/qmp-shell: unprivatize 'pretty' property python/qmp: return generic type from context manager scripts/qmp-shell: Use context manager instead of atexit scripts/qmp-shell: use logging to show warnings scripts/qmp-shell: remove TODO scripts/qmp-shell: Fix empty-transaction invocation scripts/qmp-shell: Remove too-broad-exception scripts/qmp-shell: convert usage comment to docstring scripts/qmp-shell: remove double-underscores scripts/qmp-shell: make QMPShellError inherit QMPError scripts/qmp-shell: add docstrings scripts/qmp-shell: move to python/qemu/qmp/qmp_shell.py python: add qmp-shell entry point scripts/qmp-shell: add redirection shim python/Pipfile.lock | 13 +- python/qemu/qmp/__init__.py | 61 +++- python/qemu/qmp/qemu_ga_client.py | 323 ++++++++++++++++++ python/qemu/qmp/qmp_shell.py | 535 ++++++++++++++++++++++++++++++ python/qemu/qmp/qom.py | 217 ++++++++++++ python/qemu/qmp/qom_common.py | 153 +++++++++ python/qemu/qmp/qom_fuse.py | 207 ++++++++++++ python/setup.cfg | 30 +- scripts/qmp/qemu-ga-client | 297 +---------------- scripts/qmp/qmp-shell | 454 +------------------------ scripts/qmp/qom-fuse | 144 +------- scripts/qmp/qom-get | 66 +--- scripts/qmp/qom-list | 63 +--- scripts/qmp/qom-set | 63 +--- scripts/qmp/qom-tree | 74 +---- 15 files changed, 1546 insertions(+), 1154 deletions(-) create mode 100644 python/qemu/qmp/qemu_ga_client.py create mode 100644 python/qemu/qmp/qmp_shell.py create mode 100644 python/qemu/qmp/qom.py create mode 100644 python/qemu/qmp/qom_common.py create mode 100644 python/qemu/qmp/qom_fuse.py -- 2.26.2