Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] adding pylint check and addressing any pylint issue across the repo #823

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Pylint

on:

on:
push:
branches:
- 'master'
branches: [ "master" ]
pull_request:
branches:
- 'master'
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -25,4 +24,4 @@ jobs:
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
pylint -d C0301,C0325,C0114,C0103,C0209,W0718,W1202,R0912 $(git ls-files '*.py')
7 changes: 3 additions & 4 deletions OpTestConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from common.OpTestWeb import OpTestWeb
from common.OpTestUtil import OpTestUtil
from common.OpTestCronus import OpTestCronus
from common.Exceptions import HostLocker, AES, ParameterCheck, OpExit
from common.Exceptions import ParameterCheck, OpExit
from common.OpTestConstants import OpTestConstants as BMC_CONST
import atexit
import argparse
Expand Down Expand Up @@ -49,7 +49,6 @@
import importlib
import os
import stat
import addons

optAddons = dict() # Store all addons found. We'll loop through it a couple time below
# Look at the top level of the addons for any directories and load their Setup modules
Expand Down Expand Up @@ -514,7 +513,7 @@ def parse_config_file(self, filename, optional=False):
config.read(filename)

if config.has_section('op-test'):
d = dict(config.items('op-test'))
dict(config.items('op-test'))
else:
msg = "{} is missing an an [op-test] section header".format(
filename)
Expand Down Expand Up @@ -671,7 +670,7 @@ def do_testing_setup(self):
# log for triage of how dated the repo is
OpTestLogger.optest_logger_glob.optest_logger.debug(
"op-test-framework git level = {}".format(git_output))
except Exception as e:
except Exception:
OpTestLogger.optest_logger_glob.optest_logger.debug(
"Unable to get git describe")

Expand Down
2 changes: 0 additions & 2 deletions OpTestLogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
# This implements all the python logger setup for op-test

import os
import sys
from datetime import datetime
import logging
from logging.handlers import RotatingFileHandler

Expand Down
2 changes: 1 addition & 1 deletion common/OPexpect.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def expect(self, pattern, timeout=-1, searchwindowsize=-1):
log = log + self.before + self.after
l = super(spawn, self).expect("ISTEP", timeout=20)
log = log + self.before + self.after
except pexpect.TIMEOUT as t:
except pexpect.TIMEOUT:
pass
raise PlatformError(state, log)

Expand Down
6 changes: 0 additions & 6 deletions common/OpTestASM.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@
'''

import time
import subprocess
import os
import pexpect
import sys
import subprocess

from .OpTestConstants import OpTestConstants as BMC_CONST
from .OpTestError import OpTestError

import http.cookiejar
Expand Down
11 changes: 4 additions & 7 deletions common/OpTestBMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@
import subprocess
from . import OPexpect

from .OpTestIPMI import OpTestIPMI
from .OpTestSSH import OpTestSSH
from .OpTestUtil import OpTestUtil
from .OpTestConstants import OpTestConstants as BMC_CONST
from .OpTestError import OpTestError
from .OpTestWeb import OpTestWeb
from .Exceptions import CommandFailed, SSHSessionDisconnected

import logging
import OpTestLogger
log = OpTestLogger.optest_logger_glob.get_logger(__name__)

Expand Down Expand Up @@ -120,9 +117,9 @@ def reboot(self):
retries = 0
try:
self.ssh.run_command('reboot')
except SSHSessionDisconnected as e:
except SSHSessionDisconnected:
pass
except CommandFailed as e:
except CommandFailed:
pass
self.ssh.close()
log.info('Sent reboot command now waiting for reboot to complete...')
Expand Down Expand Up @@ -157,9 +154,9 @@ def reboot_nowait(self):
'''
try:
self.ssh.run_command('reboot')
except SSHSessionDisconnected as e:
except SSHSessionDisconnected:
pass
except CommandFailed as e:
except CommandFailed:
pass
self.ssh.close()
log.info('Sent reboot command...')
Expand Down
5 changes: 1 addition & 4 deletions common/OpTestCronus.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
# IBM_PROLOG_END_TAG

import os
import datetime
import time
import subprocess
import traceback
import socket

from .Exceptions import ParameterCheck, UnexpectedCase
from .Exceptions import UnexpectedCase
from .OpTestSystem import OpSystemState

import logging
import OpTestLogger
log = OpTestLogger.optest_logger_glob.get_logger(__name__)

Expand Down
1 change: 0 additions & 1 deletion common/OpTestEBMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import time
import requests
import json
import sys

from .OpTestSSH import OpTestSSH
Expand Down
7 changes: 1 addition & 6 deletions common/OpTestFSP.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
'''

import time
import subprocess
import os
import pexpect
import sys
import subprocess

from .OpTestTConnection import TConnection
from .OpTestASM import OpTestASM
Expand Down Expand Up @@ -279,7 +274,7 @@ def wait_for_standby(self, timeout=10):
# the "standby" state and went straigh to "ipling" again. I have
# no idea why...
if self.is_sys_powered_on():
print("Hit runtime while waiting in wait_for_standby(), odd!");
print("Hit runtime while waiting in wait_for_standby(), odd!")
self.power_off_sys()

print(self.progress_line())
Expand Down
2 changes: 1 addition & 1 deletion common/OpTestHMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def get_ioslots_assigned_to_lpar(self, lpar_profile = None):
f" --filter 'lpar_names={self.lpar_name},"
f"profile_names={lpar_profile}' -F io_slots")
log.info(f"assigned_io_slots:{assigned_io_slots}")
return [] if assigned_io_slots is "none" \
return [] if assigned_io_slots == "none" \
else assigned_io_slots[0].replace('"',"").split(",")

def get_lpar_name_for_ioslot(self, ioslot):
Expand Down
14 changes: 2 additions & 12 deletions common/OpTestHost.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,16 @@

import sys
import os
import string
import time
import random
import subprocess
import re
import telnetlib
import socket
import select
import pty
import pexpect
import subprocess

import OpTestConfiguration
from .OpTestConstants import OpTestConstants as BMC_CONST
from .OpTestError import OpTestError
from .OpTestSSH import OpTestSSH
from . import OpTestQemu
from .Exceptions import CommandFailed, NoKernelConfig, KernelModuleNotLoaded, KernelConfigNotSet, ParameterCheck
from .Exceptions import CommandFailed, NoKernelConfig, KernelModuleNotLoaded, KernelConfigNotSet

import logging
import OpTestLogger
log = OpTestLogger.optest_logger_glob.get_logger(__name__)

Expand Down Expand Up @@ -799,7 +789,7 @@ def host_get_cores(self, console=0):

# Supported on OpenPower and P9 FSP system
def host_prd_supported(self, bmc_type, console=0):
if not "FSP" in bmc_type:
if "FSP" not in bmc_type:
return True

proc_gen = self.host_get_proc_gen(console=console)
Expand Down
18 changes: 8 additions & 10 deletions common/OpTestIPMI.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@
from .OpTestUtil import OpTestUtil
from . import OpTestSystem
from .Exceptions import CommandFailed
from .Exceptions import BMCDisconnected
from . import OPexpect

from .SerialConsole import SerialConsole

import logging
import OpTestLogger
log = OpTestLogger.optest_logger_glob.get_logger(__name__)

Expand Down Expand Up @@ -256,7 +254,7 @@ def close(self):
except pexpect.ExceptionPexpect:
self.state = IPMIConsoleState.DISCONNECTED
raise OpTestError("IPMI: failed to close ipmi console")
except Exception as e:
except Exception:
self.state = IPMIConsoleState.DISCONNECTED
pass

Expand All @@ -277,7 +275,7 @@ def connect(self, logger=None):
logfile=self.logfile,
failure_callback=set_system_to_UNKNOWN_BAD,
failure_callback_data=self.system)
except Exception as e:
except Exception:
self.state = IPMIConsoleState.DISCONNECTED
raise CommandFailed(
'OPexpect.spawn', "OPexpect.spawn encountered a problem, command was '{}'".format(cmd), -1)
Expand Down Expand Up @@ -463,15 +461,15 @@ def ipmi_power_reset(self):
'''
r = self.ipmitool.run('chassis power reset')
self.console.close()
if not BMC_CONST.CHASSIS_POWER_RESET in r:
if BMC_CONST.CHASSIS_POWER_RESET not in r:
raise Exception("IPMI 'chassis power reset' failed: %s " % r)

def ipmi_power_diag(self):
'''
This function sends the chassis power diag ipmitool command.
'''
r = self.ipmitool.run('chassis power diag')
if not "Chassis Power Control: Diag" in r:
if "Chassis Power Control: Diag" not in r:
raise Exception("IPMI 'chassis power diag' failed: %s " % r)

##
Expand All @@ -495,7 +493,7 @@ def ipl_wait_for_working_state(self, timeout=10):
timeout = time.time() + 60*timeout
cmd = 'sdr elist |grep \'Host Status\''
output = self.ipmitool.run(cmd)
if not "Host Status" in output:
if "Host Status" not in output:
return BMC_CONST.FW_PARAMETER
while True:
output = self.ipmitool.run(cmd)
Expand Down Expand Up @@ -532,7 +530,7 @@ def ipmi_ipl_wait_for_working_state_v1(self, timeout=10):
timeout = time.time() + 60*timeout
cmd = 'sdr elist |grep \'Host Status\''
output = self.ipmitool.run(cmd)
if not "Host Status" in output:
if "Host Status" not in output:
return BMC_CONST.FW_PARAMETER

while True:
Expand Down Expand Up @@ -592,7 +590,7 @@ def ipmi_wait_for_os_boot_complete(self, i_timeout=10):
l_timeout = time.time() + 60*i_timeout
l_cmd = 'sdr elist |grep \'OS Boot\''
output = self.ipmitool.run(l_cmd)
if not "OS Boot" in output:
if "OS Boot" not in output:
return BMC_CONST.FW_PARAMETER
while True:
l_output = self.ipmitool.run(l_cmd)
Expand Down Expand Up @@ -621,7 +619,7 @@ def ipmi_wait_for_os_boot_complete_v1(self, i_timeout=10):
l_timeout = time.time() + 60*i_timeout
l_cmd = 'sdr elist |grep \'OS Boot\''
l_output = self.ipmitool.run(l_cmd)
if not "OS Boot" in l_output:
if "OS Boot" not in l_output:
return BMC_CONST.FW_PARAMETER

while True:
Expand Down
10 changes: 4 additions & 6 deletions common/OpTestInstallUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import threading
import socketserver
import http.server
import http.server
import cgi
import subprocess
import time
Expand All @@ -36,7 +35,6 @@

from common.OpTestSystem import OpSystemState

import logging
import OpTestLogger
log = OpTestLogger.optest_logger_glob.get_logger(__name__)

Expand Down Expand Up @@ -90,7 +88,7 @@ def wait_for_network(self):
return True
except CommandFailed as cf:
log.debug("wait_for_network CommandFailed={}".format(cf))
if cf.exitcode is 1:
if cf.exitcode == 1:
time.sleep(5)
retry = retry - 1
pass
Expand Down Expand Up @@ -118,7 +116,7 @@ def ping_network(self):
if retry == 1:
log.debug("ping_network raise cf={}".format(cf))
raise cf
if cf.exitcode is 1:
if cf.exitcode == 1:
time.sleep(5)
retry = retry - 1
log.debug(
Expand Down Expand Up @@ -148,7 +146,7 @@ def assign_ip_petitboot(self):
raise noconfig_exception
cmd = (
"ip addr|grep -B1 -i %s |grep BROADCAST|awk -F ':' '{print $2}'" % (self.conf.args.host_mac))
log.debug("ip addr cmd={}".format(cmd, type(cmd)))
log.debug("ip addr cmd={}".format(cmd, ))
iface = self.cv_SYSTEM.console.run_command(cmd, retry=5)
log.debug("iface={} type={} len={}".format(
iface, type(iface), len(iface)))
Expand Down Expand Up @@ -217,7 +215,7 @@ def get_server_ip(self):
break
except CommandFailed as cf:
log.debug("get_server_ip CommandFailed cf={}".format(cf))
if cf.exitcode is 1:
if cf.exitcode == 1:
time.sleep(1)
retry = retry - 1
pass
Expand Down
6 changes: 2 additions & 4 deletions common/OpTestMambo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
import sys
import time
import pexpect
import subprocess
import os

from common.Exceptions import CommandFailed, ParameterCheck
from . import OPexpect
from .OpTestUtil import OpTestUtil

import logging
import OpTestLogger
log = OpTestLogger.optest_logger_glob.get_logger(__name__)

Expand Down Expand Up @@ -123,10 +121,10 @@ def close(self):
else:
signalstatus = os.WTERMSIG(self.pty.status)
self.state = ConsoleState.DISCONNECTED
except pexpect.ExceptionPexpect as e:
except pexpect.ExceptionPexpect:
self.state = ConsoleState.DISCONNECTED
raise "Mambo Console: failed to close console"
except Exception as e:
except Exception:
self.state = ConsoleState.DISCONNECTED
pass
log.debug("Mambo close -> TERMINATE")
Expand Down
Loading
Loading