From 931a7a83c427ce87789826b807719aa51c318d9c Mon Sep 17 00:00:00 2001 From: Praveen K Pandey Date: Sun, 23 Jun 2024 21:35:40 +0530 Subject: [PATCH] Fix pylint issue in repo Fix pylint issue in repo Signed-off-by: Praveen K Pandey --- .github/workflows/pylint.yml | 2 +- analysis.py | 27 ++++++++++++++-------- avocado-setup.py | 5 +++- lib/pci.py | 45 ++++++++++++++++++++++++++++-------- pci_info.py | 1 + 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index b19b249..29f27fa 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -21,4 +21,4 @@ jobs: - name: Analysing the code with pylint run: | pip install Inspektor==0.5.3 - inspekt checkall --disable-style E501,E265,W601,W605,E402,E722,E741 --no-license-check + inspekt checkall --disable-style E501,E265,W601,W605,E402,E722,E741,E115,E0606 --no-license-check diff --git a/analysis.py b/analysis.py index 6e2c455..3304a51 100644 --- a/analysis.py +++ b/analysis.py @@ -71,7 +71,8 @@ def test_analysis(data): # Loop through the 'tests' list in the JSON data and add rows for i, test in enumerate(data['tests']): - dataframe.loc[i + 8] = [test['name'], test['status'], test['fail_reason']] + dataframe.loc[i + 8] = [test['name'], + test['status'], test['fail_reason']] # Save the DataFrame to a Excel file dataframe.to_excel('Analysis.xlsx', index=False) @@ -111,7 +112,8 @@ def comparison_analysis(excel, data): found = 0 for j in range(len(test_names)): if test['name'] == test_names[j]: - new_dataframe.loc[j + 8] = [test['status'], test['fail_reason']] + new_dataframe.loc[j + 8] = [test['status'], + test['fail_reason']] found = 1 break if found == 0: @@ -119,7 +121,8 @@ def comparison_analysis(excel, data): for i in range(len(old_dataframe.columns)-1): new.append("") old_dataframe.loc[len(old_dataframe.index)] = new - new_dataframe.loc[len(old_dataframe.index)-1] = [test['status'], test['fail_reason']] + new_dataframe.loc[len(old_dataframe.index) - + 1] = [test['status'], test['fail_reason']] final_res = pd.concat([old_dataframe, new_dataframe], axis=1) final_res.to_excel(excel, index=False) @@ -179,7 +182,8 @@ def deco(excel): for cell in row: cell.font = Font(size=15) cell.border = Border(left=Side(border_style='thin', color='000000'), - right=Side(border_style='thin', color='000000'), + right=Side(border_style='thin', + color='000000'), top=Side(border_style='thin', color='000000'), bottom=Side(border_style='thin', color='000000')) cell.alignment = Alignment(wrap_text=True, vertical='center') @@ -187,18 +191,23 @@ def deco(excel): # Apply header formatting for cell in worksheet[1]: cell.font = Font(size=18, bold=True) # White text color - cell.fill = PatternFill(start_color='ADD8E6', end_color='ADD8E6', fill_type='solid') # Blue background color + # Blue background color + cell.fill = PatternFill(start_color='ADD8E6', + end_color='ADD8E6', fill_type='solid') # Conditional formatting for the "Result" column if present try: for idx, value in enumerate(dataframe['Result'], start=2): cell = worksheet.cell(row=idx, column=6) if value == 'DIFF': - cell.fill = PatternFill(start_color='FF0000', end_color='FF0000', fill_type='solid') # Red + cell.fill = PatternFill( + start_color='FF0000', end_color='FF0000', fill_type='solid') # Red elif value == 'SOLVED': - cell.fill = PatternFill(start_color='39E75F', end_color='39E75F', fill_type='solid') # Green + cell.fill = PatternFill( + start_color='39E75F', end_color='39E75F', fill_type='solid') # Green elif value == 'REGRESSION': - cell.fill = PatternFill(start_color='FFA500', end_color='FFA500', fill_type='solid') # Orange + cell.fill = PatternFill( + start_color='FFA500', end_color='FFA500', fill_type='solid') # Orange except Exception as e: pass @@ -248,4 +257,4 @@ def usage(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/avocado-setup.py b/avocado-setup.py index 1ba1a8c..e0ab3d6 100644 --- a/avocado-setup.py +++ b/avocado-setup.py @@ -51,6 +51,9 @@ logger = logger_init(filepath=BASE_PATH).getlogger() prescript_dir = CONFIGFILE.get('script-dir', 'prescriptdir') postscript_dir = CONFIGFILE.get('script-dir', 'postscriptdir') +args=None +outputdir='' +pipManager=None class TestSuite(): @@ -673,7 +676,7 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm): bootstraped = True if args.run_tests: - with open("%s/host/dynamic_test_suite" % TEST_CONF_PATH+".cfg","w+") as fp: + with open("%s/host/dynamic_test_suite" % TEST_CONF_PATH+".cfg", "w+") as fp: fp.write('\n'.join(args.run_tests.split(","))) args.run_suite = str(args.run_suite)+","+"host_dynamic_test_suite" diff --git a/lib/pci.py b/lib/pci.py index ade0fe5..5af5d90 100644 --- a/lib/pci.py +++ b/lib/pci.py @@ -42,7 +42,8 @@ def get_domains(): return list(set(domains)) return [] -def is_nvmf(): + +def is_nvmf(): """ Verify if nvmf is configured @@ -55,6 +56,7 @@ def is_nvmf(): else: return False + def list_fc_host_names(pci_domain): """ For a specific PCI domain find the nvmf disks behind FC PCI domain @@ -88,6 +90,7 @@ def list_fc_host_names(pci_domain): logger.debug("Error while traversing PCI domain %s", pci_domain) return [] + def list_nvmf_fc_node_names(host_names): """ For every FC hostnames find the node_name @@ -116,6 +119,7 @@ def list_nvmf_fc_node_names(host_names): return node_names + def list_nvmf_nvme_names(node_names): """ In the nvme list-subsystem output find the nvme host specific to FC node names @@ -126,7 +130,6 @@ def list_nvmf_nvme_names(node_names): """ nvme_names = [] lines = runcmd('nvme list-subsys')[1].splitlines() - for line in lines: for word in node_names: if re.search(word, line): @@ -135,6 +138,7 @@ def list_nvmf_nvme_names(node_names): return nvme_names + def list_nvmf_disks(nvme_names): """ Traverse through nvme list command to find the corresponding nvmf disks @@ -154,6 +158,7 @@ def list_nvmf_disks(nvme_names): nvmf_disks.append(parts[0]) return nvmf_disks + def get_pci_addresses(): """ Gets list of PCI addresses in the system. @@ -167,6 +172,7 @@ def get_pci_addresses(): addresses.append(line.split()[0]) return addresses + def get_num_interfaces_in_pci(dom_pci_address): """ Gets number of interfaces of a given partial PCI address starting with @@ -186,6 +192,7 @@ def get_num_interfaces_in_pci(dom_pci_address): count += 1 return count + def get_disks_in_pci_address(pci_address): """ Gets disks in a PCI address. @@ -202,6 +209,7 @@ def get_disks_in_pci_address(pci_address): disk_list.append(os.path.abspath(os.path.join(disks_path, link))) return disk_list + def get_disks_in_interface(interface): """ Gets disks in a PCI interface. @@ -218,6 +226,7 @@ def get_disks_in_interface(interface): disk_list.append('/dev/%s' % dev) return disk_list + def get_multipath_wwids(disks_list): """ Get mpath wwid for given scsi disks @@ -240,6 +249,7 @@ def get_multipath_wwids(disks_list): existing_wwids.append(line.split('/')[1]) return [mpath for mpath in list(set(wwid_list)) if mpath in existing_wwids] + def get_multipath_disks(wwids_list): """ Get mpath disk names for given wwids @@ -254,6 +264,7 @@ def get_multipath_disks(wwids_list): mpath_list.append("/dev/mapper/%s" % disk) return mpath_list + def get_root_disks(): """ Gets the PCI address of the root disk. @@ -267,6 +278,7 @@ def get_root_disks(): root_disk.append('/dev/%s' % line.split()[0]) return root_disk + def get_nics_in_pci_address(pci_address): """ Gets network interface(nic) in a PCI address. @@ -277,6 +289,7 @@ def get_nics_in_pci_address(pci_address): """ return get_interfaces_in_pci_address(pci_address, "net") + def get_interfaces_in_pci_address(pci_address, pci_class): """ Gets interface in a PCI address. @@ -297,6 +310,7 @@ def get_interfaces_in_pci_address(pci_address, pci_class): if pci_address in os.readlink(os.path.join(pci_class_path, interface))] + def get_pci_class_name(pci_address): """ Gets PCI class name for given PCI bus address @@ -316,6 +330,7 @@ def get_pci_class_name(pci_address): return "" return pci_class_dic.get(pci_class_id) + def get_pci_type(pci_address): """ Gets PCI type for given PCI bus address @@ -335,6 +350,7 @@ def get_pci_type(pci_address): return "" return pci_class_dic.get(pci_class_id) + def get_firmware(pci_address): """ Gets firmware of a pci_address @@ -506,6 +522,7 @@ def get_pci_name(pci_address): return " ".join(pci_name) return "" + def get_driver(adapter_type, pci_address): """ Gets the kernel driver in use of given PCI address. (first match only) @@ -532,6 +549,7 @@ def get_driver(adapter_type, pci_address): return line.rsplit(None, 1)[-1] return "" + def ioa_details(): """ Gets the IPR IOA details and returns @@ -555,7 +573,8 @@ def ioa_details(): r_serial = line.split()[-1] if line.startswith('Current Dual Adapter State'): status = line.split()[-1] - ioas.append({'ioa': ioa, 'pci': pci, 'serial': serial, 'r_serial': r_serial, 'status': status}) + ioas.append({'ioa': ioa, 'pci': pci, 'serial': serial, + 'r_serial': r_serial, 'status': status}) return ioas @@ -572,6 +591,7 @@ def get_primary_ioa(pci_address): return ioa_detail['ioa'] return '' + def get_multipath_nvmf_wwids(): """ Gets the wwids of the nvmf multipath disks @@ -592,6 +612,7 @@ def get_multipath_nvmf_wwids(): return wwid_list + def get_secondary_ioa(primary_ioa): """ Gets the Secondary IPR IOA in the given Primary IPR IOA @@ -648,7 +669,8 @@ def pci_info(pci_addrs, pci_type='', pci_blocklist='', type_blocklist=''): pci_dic['class'] = get_pci_class_name(pci_dic['functions'][0]) pci_dic['interfaces'] = [] for fun in pci_dic['functions']: - pci_dic['interfaces'].extend(get_interfaces_in_pci_address(fun, pci_dic['class'])) + pci_dic['interfaces'].extend( + get_interfaces_in_pci_address(fun, pci_dic['class'])) pci_dic['disks'] = [] pci_dic['mpath_wwids'] = [] pci_dic['mpath_disks'] = [] @@ -656,7 +678,8 @@ def pci_info(pci_addrs, pci_type='', pci_blocklist='', type_blocklist=''): pci_dic['adapter_type'] = 'nvmf' if is_rhel8(): pci_dic['mpath_wwids'] = get_multipath_nvmf_wwids() - pci_dic['mpath_disks'] = get_multipath_disks(pci_dic['mpath_wwids']) + pci_dic['mpath_disks'] = get_multipath_disks( + pci_dic['mpath_wwids']) pci_dic['disks'] = pci_dic['mpath_disks'] else: pci_val = ':'.join(pci_addr.split(':')[:2]) @@ -667,12 +690,14 @@ def pci_info(pci_addrs, pci_type='', pci_blocklist='', type_blocklist=''): pci_dic['disks'] = list(set(pci_dic['disks'])) if pci_dic['class'] == 'scsi_host' and not pci_dic['adapter_type'] == 'nvmf': pci_dic['mpath_wwids'] = get_multipath_wwids(pci_dic['disks']) - pci_dic['mpath_disks'] = get_multipath_disks(pci_dic['mpath_wwids']) + pci_dic['mpath_disks'] = get_multipath_disks( + pci_dic['mpath_wwids']) pci_dic['disks'] = pci_dic['mpath_disks'] pci_dic['pci_root'] = pci_addr pci_dic['adapter_description'] = get_pci_name(pci_dic['functions'][0]) pci_dic['adapter_id'] = get_pci_id(pci_dic['functions'][0]) - pci_dic['driver'] = get_driver(pci_dic['adapter_type'], pci_dic['functions'][0]) + pci_dic['driver'] = get_driver( + pci_dic['adapter_type'], pci_dic['functions'][0]) pci_dic['slot'] = get_slot_from_sysfs(pci_dic['functions'][0]) if pci_dic['adapter_type'] in type_blocklist: continue @@ -682,11 +707,13 @@ def pci_info(pci_addrs, pci_type='', pci_blocklist='', type_blocklist=''): pci_dic['infiniband_interfaces'] = [] if pci_dic['adapter_type'] == 'infiniband': for fun in pci_dic['functions']: - pci_dic['infiniband_interfaces'].extend(get_interfaces_in_pci_address(fun, 'infiniband')) + pci_dic['infiniband_interfaces'].extend( + get_interfaces_in_pci_address(fun, 'infiniband')) if pci_dic['adapter_type'] == 'raid': for fun in pci_dic['functions']: pci_dic['primary_ioa'] = get_primary_ioa(fun) - pci_dic['secondary_ioa'] = get_secondary_ioa(pci_dic['primary_ioa']) + pci_dic['secondary_ioa'] = get_secondary_ioa( + pci_dic['primary_ioa']) pci_dic['is_root_disk'] = False for disk in pci_dic['disks']: for root_disk in root_disks: diff --git a/pci_info.py b/pci_info.py index 2b4381a..fa01035 100755 --- a/pci_info.py +++ b/pci_info.py @@ -34,6 +34,7 @@ input_path = "io_input.txt" INPUTFILE = configparser.ConfigParser() INPUTFILE.optionxform = str +args=None logger = logger_init(filepath=BASE_PATH).getlogger()