cleanup whitespace mess

This commit is contained in:
o 2016-04-04 15:57:29 +02:00
parent b04d1ce005
commit 01bc257265

View File

@ -35,10 +35,8 @@ def main():
action="store_true", default=False, action="store_true", default=False,
help="n m : One line summary of top n vms with more than m cpu_time %") help="n m : One line summary of top n vms with more than m cpu_time %")
(options, args) = parser.parse_args () (options, args) = parser.parse_args ()
qvm_collection = QubesVmCollection() qvm_collection = QubesVmCollection()
qvm_collection.lock_db_for_reading() qvm_collection.lock_db_for_reading()
qvm_collection.load() qvm_collection.load()
@ -47,9 +45,7 @@ def main():
fields_to_display = ["name", "cpu", "mem"] fields_to_display = ["name", "cpu", "mem"]
cpu_usages = None cpu_usages = None
qhost = QubesHost() qhost = QubesHost()
(measure_time, cpu_usages) = qhost.measure_cpu_usage(qvm_collection) (measure_time, cpu_usages) = qhost.measure_cpu_usage(qvm_collection)
vms_list = [vm for vm in qvm_collection.values() if vm.is_running()] vms_list = [vm for vm in qvm_collection.values() if vm.is_running()]
@ -62,25 +58,25 @@ def main():
any_shown = False any_shown = False
ndisp = 3 ndisp = 3
cputh = 0 cputh = 0
if len(args) > 0: if len(args) > 0:
ndisp = int(args[0]) ndisp = int(args[0])
if len(args) > 1: if len(args) > 1:
cputh = int(args[1]) cputh = int(args[1])
for vm in vms_to_display[:ndisp]: for vm in vms_to_display[:ndisp]:
cpu = cpu_usages[vm.get_xid()]['cpu_usage'] cpu = cpu_usages[vm.get_xid()]['cpu_usage']
if cpu > cputh: if cpu > cputh:
any_shown = True any_shown = True
sys.stdout.write("%d %s, " % (cpu, vm.name)) sys.stdout.write("%d %s, " % (cpu, vm.name))
if any_shown: if any_shown:
sys.stdout.write(" ... | ") sys.stdout.write(" ... | ")
totalMem = 0 totalMem = 0
dom0mem = 0 dom0mem = 0
for vm in vms_to_display: for vm in vms_to_display:
if not vm.name == "dom0": if not vm.name == "dom0":
totalMem += vm.get_mem() totalMem += vm.get_mem()
else: else:
dom0mem = vm.get_mem() dom0mem = vm.get_mem()
totalMem /= 1024.0 * 1024.0 totalMem /= 1024.0 * 1024.0