[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 18/72] scripts/qemu-ga-client: apply (most) flake8 rules
From: |
John Snow |
Subject: |
[PATCH v2 18/72] scripts/qemu-ga-client: apply (most) flake8 rules |
Date: |
Tue, 3 Nov 2020 19:35:08 -0500 |
- Line length should be < 80
- You shouldn't perform unscoped imports except at the top of the module
Notably, the sys.path hack creates problems with the import rule. This
will be fixed later.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qmp/qemu-ga-client | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/scripts/qmp/qemu-ga-client b/scripts/qmp/qemu-ga-client
index ae71b30dfa43..a12e0e9b2a6e 100755
--- a/scripts/qmp/qemu-ga-client
+++ b/scripts/qmp/qemu-ga-client
@@ -12,7 +12,8 @@
# Start QEMU with:
#
# # qemu [...] -chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0 \
-# -device virtio-serial -device
virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
+# -device virtio-serial \
+# -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
#
# Run the script:
#
@@ -37,6 +38,7 @@
#
import base64
+import optparse
import os
import random
import sys
@@ -94,9 +96,11 @@ class QemuGuestAgentClient:
msgs = []
msgs.append('version: ' + info['version'])
msgs.append('supported_commands:')
- enabled = [c['name'] for c in info['supported_commands'] if
c['enabled']]
+ enabled = [c['name'] for c in info['supported_commands']
+ if c['enabled']]
msgs.append('\tenabled: ' + ', '.join(enabled))
- disabled = [c['name'] for c in info['supported_commands'] if not
c['enabled']]
+ disabled = [c['name'] for c in info['supported_commands']
+ if not c['enabled']]
msgs.append('\tdisabled: ' + ', '.join(disabled))
return '\n'.join(msgs)
@@ -119,11 +123,11 @@ class QemuGuestAgentClient:
if ipaddr['ip-address-type'] == 'ipv4':
addr = ipaddr['ip-address']
mask = self.__gen_ipv4_netmask(int(ipaddr['prefix']))
- msgs.append("\tinet %s netmask %s" % (addr, mask))
+ msgs.append(f"\tinet {addr} netmask {mask}")
elif ipaddr['ip-address-type'] == 'ipv6':
addr = ipaddr['ip-address']
prefix = ipaddr['prefix']
- msgs.append("\tinet6 %s prefixlen %s" % (addr,
prefix))
+ msgs.append(f"\tinet6 {addr} prefixlen {prefix}")
if nif['hardware-address'] != '00:00:00:00:00:00':
msgs.append("\tether " + nif['hardware-address'])
@@ -237,6 +241,8 @@ def _cmd_suspend(client, args):
def _cmd_shutdown(client, args):
client.shutdown()
+
+
_cmd_powerdown = _cmd_shutdown
@@ -280,17 +286,15 @@ def main(address, cmd, args):
if __name__ == '__main__':
- import optparse
- import os
- import sys
+ address = os.environ.get('QGA_CLIENT_ADDRESS')
- address = os.environ['QGA_CLIENT_ADDRESS'] if 'QGA_CLIENT_ADDRESS' in
os.environ else None
-
- usage = "%prog [--address=<unix_path>|<ipv4_address>] <command>
[args...]\n"
+ usage = ("%prog [--address=<unix_path>|<ipv4_address>]"
+ " <command> [args...]\n")
usage += '<command>: ' + ', '.join(commands)
parser = optparse.OptionParser(usage=usage)
parser.add_option('--address', action='store', type='string',
- default=address, help='Specify a ip:port pair or a unix
socket path')
+ default=address,
+ help='Specify a ip:port pair or a unix socket path')
options, args = parser.parse_args()
address = options.address
--
2.26.2
- [PATCH v2 08/72] scripts/qom-fuse: Add docstrings, (continued)
- [PATCH v2 08/72] scripts/qom-fuse: Add docstrings, John Snow, 2020/11/03
- [PATCH v2 06/72] python: Add 'fh' to known-good variable names, John Snow, 2020/11/03
- [PATCH v2 07/72] scripts/qom-fuse: Apply pylint rules, John Snow, 2020/11/03
- [PATCH v2 09/72] scripts/qom-fuse: Convert to QOMCommand, John Snow, 2020/11/03
- [PATCH v2 12/72] scripts/qom-fuse: add static type hints, John Snow, 2020/11/03
- [PATCH v2 11/72] scripts/qom-fuse: ensure QOMFuse.read always returns bytes, John Snow, 2020/11/03
- [PATCH v2 16/72] python: add optional fuse dependency, John Snow, 2020/11/03
- [PATCH v2 10/72] scripts/qom-fuse: use QOMCommand.qom_list(), John Snow, 2020/11/03
- [PATCH v2 13/72] scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.py, John Snow, 2020/11/03
- [PATCH v2 15/72] python: add fuse command to 'qom' tools, John Snow, 2020/11/03
- [PATCH v2 18/72] scripts/qemu-ga-client: apply (most) flake8 rules,
John Snow <=
- [PATCH v2 20/72] scripts/qemu-ga-client: replace deprecated optparse with argparse, John Snow, 2020/11/03
- [PATCH v2 19/72] scripts/qemu-ga-client: Fix exception handling, John Snow, 2020/11/03
- [PATCH v2 26/72] python/qemu-ga-client: add entry point, John Snow, 2020/11/03
- [PATCH v2 29/72] scripts/qmp-shell: Apply flake8 rules, John Snow, 2020/11/03
- [PATCH v2 23/72] python/qmp: Correct type of QMPReturnValue, John Snow, 2020/11/03
- [PATCH v2 28/72] scripts/qmp-shell: apply isort rules, John Snow, 2020/11/03
- [PATCH v2 21/72] scripts/qemu-ga-client: add module docstring, John Snow, 2020/11/03
- [PATCH v2 27/72] scripts/qemu-ga-client: Add forwarder stub, John Snow, 2020/11/03
- [PATCH v2 25/72] scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.py, John Snow, 2020/11/03
- [PATCH v2 17/72] scripts/qemu-ga-client: apply isort rules, John Snow, 2020/11/03