Skip to content
Snippets Groups Projects
Commit 5912e791 authored by Adrian Vladu's avatar Adrian Vladu Committed by Sasha Levin
Browse files

tools: hv: fixed Python pep8/flake8 warnings for lsvmbus


Fixed pep8/flake8 python style code for lsvmbus tool.

The TAB indentation was on purpose ignored (pep8 rule W191) to make
sure the code is complying with the Linux code guideline.
The following command doe not show any warnings now:
pep8 --ignore=W191 lsvmbus
flake8 --ignore=W191 lsvmbus

Signed-off-by: default avatarAdrian Vladu <avladu@cloudbasesolutions.com>

Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Alessandro Pilotti <apilotti@cloudbasesolutions.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5f9e832c
No related branches found
No related tags found
No related merge requests found
......@@ -4,10 +4,10 @@
import os
from optparse import OptionParser
help_msg = "print verbose messages. Try -vv, -vvv for more verbose messages"
parser = OptionParser()
parser.add_option("-v", "--verbose", dest="verbose",
help="print verbose messages. Try -vv, -vvv for \
more verbose messages", action="count")
parser.add_option(
"-v", "--verbose", dest="verbose", help=help_msg, action="count")
(options, args) = parser.parse_args()
......@@ -42,6 +42,7 @@ vmbus_dev_dict = {
'{3375baf4-9e15-4b30-b765-67acb10d607b}': '[Reserved system device]',
}
def get_vmbus_dev_attr(dev_name, attr):
try:
f = open('%s/%s/%s' % (vmbus_sys_path, dev_name, attr), 'r')
......@@ -52,6 +53,7 @@ def get_vmbus_dev_attr(dev_name, attr):
return lines
class VMBus_Dev:
pass
......@@ -66,12 +68,13 @@ for f in os.listdir(vmbus_sys_path):
chn_vp_mapping = get_vmbus_dev_attr(f, 'channel_vp_mapping')
chn_vp_mapping = [c.strip() for c in chn_vp_mapping]
chn_vp_mapping = sorted(chn_vp_mapping,
key = lambda c : int(c.split(':')[0]))
chn_vp_mapping = sorted(
chn_vp_mapping, key=lambda c: int(c.split(':')[0]))
chn_vp_mapping = ['\tRel_ID=%s, target_cpu=%s' %
(c.split(':')[0], c.split(':')[1])
for c in chn_vp_mapping]
chn_vp_mapping = [
'\tRel_ID=%s, target_cpu=%s' %
(c.split(':')[0], c.split(':')[1]) for c in chn_vp_mapping
]
d = VMBus_Dev()
d.sysfs_path = '%s/%s' % (vmbus_sys_path, f)
d.vmbus_id = vmbus_id
......@@ -95,9 +98,15 @@ for d in vmbus_dev_list:
if verbose == 0:
print(('VMBUS ID ' + format0) % (d.vmbus_id, d.dev_desc))
elif verbose == 1:
print (('VMBUS ID ' + format1) % \
(d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping))
print(
('VMBUS ID ' + format1) %
(d.vmbus_id, d.class_id, d.dev_desc, d.chn_vp_mapping)
)
else:
print (('VMBUS ID ' + format2) % \
(d.vmbus_id, d.class_id, d.dev_desc, \
d.device_id, d.sysfs_path, d.chn_vp_mapping))
print(
('VMBUS ID ' + format2) %
(
d.vmbus_id, d.class_id, d.dev_desc,
d.device_id, d.sysfs_path, d.chn_vp_mapping
)
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment