From 1c4a4fb84bf470709541067665dbc232e2c12dd3 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 30 Mar 2020 10:08:06 +0200 Subject: flake8 cleanups --- libvirt-cputime | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libvirt-cputime') diff --git a/libvirt-cputime b/libvirt-cputime index d9f9e1b..e49d20e 100644 --- a/libvirt-cputime +++ b/libvirt-cputime @@ -17,9 +17,11 @@ from __future__ import print_function import re, sys, os import libvirt + def canon(name): return re.sub(r"[^a-zA-Z0-9_]", "_", name) + def print_config(uri, stack): """print the plugin config, determine the domains""" @@ -37,7 +39,7 @@ total_pc.info cputime used by all virtual machines total_pc.warning 90 total_pc.critical 95""") - draw = [ "LINE1", "AREA"][stack] + draw = ["LINE1", "AREA"][stack] conn = libvirt.openReadOnly(uri) ids = conn.listDomainsID() for id in ids: @@ -57,6 +59,7 @@ total_pc.critical 95""") if draw == "AREA": draw = "STACK" + def fetch_values(uri): conn = libvirt.openReadOnly(uri) ids = conn.listDomainsID() @@ -81,10 +84,10 @@ def fetch_values(uri): def main(sys): uri = os.getenv("uri", "qemu:///system") - stack = [ False, True ][os.getenv("stack") == "1"] + stack = [False, True][os.getenv("stack") == "1"] if len(sys) > 1: - if sys[1] in [ 'autoconf', 'detect' ]: + if sys[1] in ['autoconf', 'detect']: if libvirt.openReadOnly(uri): print("yes") return 0 @@ -97,6 +100,7 @@ def main(sys): fetch_values(uri) return 0 + if __name__ == "__main__": sys.exit(main(sys.argv)) -- cgit v1.2.3