pep8: re-enable E302 (2 blank lines between functions)

This isn't a significant effort to fix, so let's just enable it to move
closer to the official Python PEP 8 guidelines.

Fix up the existing instances where we didn't already have two lines
between functions, and re-enable the pep8 warning.

Change-Id: I9cf5e7e32b9c6dfedbd1b0f9bc92951cbb2c8a0d
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/399949
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Daniel Verkamp 2018-02-14 14:34:55 -07:00
parent 20fbd09a78
commit dc6f9571c1
11 changed files with 38 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import os
import glob
import re
def generateCoverageReport(output_dir, repo_dir):
with open(os.path.join(output_dir, 'coverage.log'), 'w+') as log_file:
coveragePath = os.path.join(output_dir, '**', 'cov_total.info')

View File

@ -103,7 +103,6 @@ rm -f scripts/posix.log
if hash pep8; then
echo -n "Checking Python style..."
PEP8_ARGS+=" --ignore=E302" # ignore 'E302 expected 2 blank lines, found 1'
PEP8_ARGS+=" --max-line-length=140"
error=0

View File

@ -34,11 +34,13 @@ filename=%(device)s
"""
def interrupt_handler(signum, frame):
fio.terminate()
print "FIO terminated"
sys.exit(0)
def main():
global fio
@ -77,10 +79,12 @@ def main():
sys.stdout.flush()
sys.exit(rc)
def get_target_devices():
output = check_output('iscsiadm -m session -P 3', shell=True)
return re.findall("Attached scsi disk (sd[a-z]+)", output)
def create_fio_config(size, q_depth, devices, test, run_time, verify):
if not verify:
verifyfio = ""
@ -92,6 +96,7 @@ def create_fio_config(size, q_depth, devices, test, run_time, verify):
fiofile += fio_job_template % {"jobnumber": i, "device": dev}
return fiofile
def set_device_parameter(devices, filename_template, value):
for dev in devices:
filename = filename_template % dev
@ -99,6 +104,7 @@ def set_device_parameter(devices, filename_template, value):
f.write(value)
f.close()
def configure_devices(devices):
set_device_parameter(devices, "/sys/block/%s/queue/nomerges", "2")
set_device_parameter(devices, "/sys/block/%s/queue/nr_requests", "128")
@ -116,5 +122,6 @@ def configure_devices(devices):
print "Requested queue_depth {} but only {} is supported.".format(str(requested_qd), str(qd))
set_device_parameter(devices, "/sys/block/%s/queue/scheduler", "noop")
if __name__ == "__main__":
main()

View File

@ -36,6 +36,7 @@ run_time = ['60']
# set iter_num = ['1', '2', '3'] to repeat each test 3 times
iter_num = ['1']
def run_fio(io_size_bytes, qd, rw_mix, cpu_mask, run_num, workload, run_time_sec):
print "Running Test: IO Size=", io_size_bytes, " QD=", qd, " Mix=", rw_mix, "CPU Mask=", cpu_mask
string = "s_" + str(io_size_bytes) + "_q_" + str(qd) + "_m_" + str(rw_mix) + "_c_" + str(cpu_mask) + "_run_" + str(run_num)
@ -51,6 +52,7 @@ def run_fio(io_size_bytes, qd, rw_mix, cpu_mask, run_num, workload, run_time_sec
print "Finished Test: IO Size=", io_size_bytes, " QD=", qd, " Mix=", rw_mix, " CPU Mask=", cpu_mask
return
def parse_results(io_size_bytes, qd, rw_mix, cpu_mask, run_num, workload, run_time_sec):
results_array = []
@ -107,20 +109,24 @@ def parse_results(io_size_bytes, qd, rw_mix, cpu_mask, run_num, workload, run_ti
results_array = []
return
def get_nvme_devices_count():
output = check_output('lspci | grep -i Non | wc -l', shell=True)
return int(output)
def get_nvme_devices_bdf():
output = check_output('lspci | grep -i Non | awk \'{print $1}\'', shell=True)
output = output.split()
return output
def add_filename_to_conf(conf_file_name, bdf):
filestring = "filename=trtype=PCIe traddr=0000." + bdf.replace(":", ".") + " ns=1"
with open(conf_file_name, "a") as conf_file:
conf_file.write(filestring + "\n")
if len(sys.argv) != 4:
print "usage: python ", sys.argv[0], " path_to_fio_conf path_to_ioengine num_ssds"
sys.exit()

View File

@ -5,6 +5,7 @@ def kill_instance(args):
params = {'sig_name': args.sig_name}
args.client.call('kill_instance', params)
def context_switch_monitor(args):
params = {}
if args.enable:

View File

@ -91,6 +91,7 @@ def bdev_inject_error(args):
args.client.call('bdev_inject_error', params)
def apply_firmware(args):
params = {
'filename': args.filename,

View File

@ -1,5 +1,6 @@
from client import print_dict, print_array, int_arg
def set_vhost_controller_coalescing(args):
params = {
'ctrlr': args.ctrlr,
@ -8,6 +9,7 @@ def set_vhost_controller_coalescing(args):
}
args.client.call('set_vhost_controller_coalescing', params)
def construct_vhost_scsi_controller(args):
params = {'ctrlr': args.ctrlr}

View File

@ -32,6 +32,7 @@ known_failed_cases = ['tc_ffp_15_2', 'tc_ffp_29_2', 'tc_ffp_29_3',
'tc_err_3_4', 'tc_err_5_1', 'tc_login_3_1',
'tc_login_11_2', 'tc_login_11_4', 'tc_login_2_2']
def run_case(case, result_list, log_dir_path):
try:
case_log = subprocess.check_output("{}/{}".format(CALSOFT_BIN_PATH, case), stderr=subprocess.STDOUT, shell=True)
@ -43,6 +44,7 @@ def run_case(case, result_list, log_dir_path):
with open(log_dir_path + case + '.txt', 'w') as f:
f.write(case_log)
def main():
if not os.path.exists(CALSOFT_BIN_PATH):
print "The Calsoft test suite is not available on this machine."
@ -106,5 +108,6 @@ def main():
failed = 1
exit(failed)
if __name__ == '__main__':
main()

View File

@ -78,6 +78,7 @@ def verify_trace_flag_rpc_methods(rpc_py, rpc_param):
print "verify_trace_flag_rpc_methods passed"
def verify_iscsi_connection_rpc_methods(rpc_py):
rpc = spdk_rpc(rpc_py)
output = rpc.get_iscsi_connections()
@ -121,6 +122,7 @@ def verify_iscsi_connection_rpc_methods(rpc_py):
print "verify_iscsi_connection_rpc_methods passed"
def verify_scsi_devices_rpc_methods(rpc_py):
rpc = spdk_rpc(rpc_py)
output = rpc.get_scsi_devices()
@ -357,6 +359,7 @@ def verify_target_nodes_rpc_methods(rpc_py, rpc_param):
print "verify_target_nodes_rpc_methods passed."
def verify_get_interfaces(rpc_py):
rpc = spdk_rpc(rpc_py)
nics = json.loads(rpc.get_interfaces())
@ -366,6 +369,7 @@ def verify_get_interfaces(rpc_py):
verify(nics_names == ifcfg_nics, 1, "get_interfaces returned {}".format(nics))
print "verify_get_interfaces passed."
def help_get_interface_ip_list(rpc_py, nic_name):
rpc = spdk_rpc(rpc_py)
nics = json.loads(rpc.get_interfaces())
@ -374,6 +378,7 @@ def help_get_interface_ip_list(rpc_py, nic_name):
"Nic name: {} is not found in {}".format(nic_name, [x["name"] for x in nics]))
return nic[0]["ip_addr"]
def verify_add_delete_ip_address(rpc_py):
rpc = spdk_rpc(rpc_py)
nics = json.loads(rpc.get_interfaces())
@ -408,6 +413,7 @@ def verify_add_delete_ip_address(rpc_py):
(faked_ip, x["name"]))
print "verify_add_delete_ip_address passed."
def verify_add_nvme_bdev_rpc_methods(rpc_py):
rpc = spdk_rpc(rpc_py)
test_pass = 0
@ -429,6 +435,7 @@ def verify_add_nvme_bdev_rpc_methods(rpc_py):
verify(test_pass == 1, 1, "add nvme device passed second time")
print "verify_add_nvme_bdev_rpc_methods passed."
if __name__ == "__main__":
rpc_py = sys.argv[1]

View File

@ -16,6 +16,7 @@ from uuid import uuid4
MEGABYTE = 1024 * 1024
def test_counter():
'''
:return: the number of tests
@ -68,10 +69,12 @@ def header(num):
print("Test Name: {name}".format(name=test_name[num]))
print("========================================================")
def footer(num):
print("Test Case {num}: END\n".format(num=num))
print("========================================================")
class TestCases(object):
def __init__(self, rpc_py, total_size, block_size, cluster_size, base_dir_path, app_path):

View File

@ -34,11 +34,13 @@ filename=%(device)s
"""
def interrupt_handler(signum, frame):
fio.terminate()
print "FIO terminated"
sys.exit(0)
def main():
global fio
@ -78,10 +80,12 @@ def main():
sys.stdout.flush()
sys.exit(rc)
def get_target_devices():
output = check_output('lsblk -l -o NAME', shell=True)
return re.findall("(nvme[0-9]+n[0-9]+)\n", output)
def create_fio_config(size, q_depth, devices, test, run_time, verify):
if not verify:
verifyfio = ""
@ -93,6 +97,7 @@ def create_fio_config(size, q_depth, devices, test, run_time, verify):
fiofile += fio_job_template % {"jobnumber": i, "device": dev}
return fiofile
def set_device_parameter(devices, filename_template, value):
for dev in devices:
filename = filename_template % dev
@ -100,6 +105,7 @@ def set_device_parameter(devices, filename_template, value):
f.write(value)
f.close()
def configure_devices(devices):
set_device_parameter(devices, "/sys/block/%s/queue/nomerges", "2")
set_device_parameter(devices, "/sys/block/%s/queue/nr_requests", "128")
@ -117,5 +123,6 @@ def configure_devices(devices):
print "Requested queue_depth {} but only {} is supported.".format(str(requested_qd), str(qd))
set_device_parameter(devices, "/sys/block/%s/queue/scheduler", "noop")
if __name__ == "__main__":
main()