pycodestyle: fix issues
When calling pycodestyle directly on a file (vs the project as a
whole) it seems to be a bit more opinionated. Fix up these issues
so we can change how we call pycodestyle organization-wide.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If561fb1ec3036b5fd5a600969fb5d81274464db2
diff --git a/bin/generate_inventory b/bin/generate_inventory
index 880777c..3654682 100755
--- a/bin/generate_inventory
+++ b/bin/generate_inventory
@@ -91,16 +91,16 @@
# Check if there is mismatch in data vs expect list
if len(inventory_dict) != len(inventory_items):
print_error("The generated list doesn't match Inventory List.\n")
- print (data)
+ print(data)
print_var(inventory_items)
sys.exit()
# Write dictionary data to inventory file
-print ("\nGenerated Inventory item json format\n")
-print (data)
+print("\nGenerated Inventory item json format\n")
+print(data)
out = open(fru_inventory_file_path, 'w')
out.write('inventory_dict = ')
out.write(data)
out.close()
-print ("\nGenerated Inventory File: %s " % fru_inventory_file_path)
+print("\nGenerated Inventory File: %s " % fru_inventory_file_path)
diff --git a/bin/obmc_ser_num b/bin/obmc_ser_num
index 96fa7e0..ba620c8 100755
--- a/bin/obmc_ser_num
+++ b/bin/obmc_ser_num
@@ -22,9 +22,9 @@
parser = argparse.ArgumentParser(
usage='%(prog)s [OPTIONS]',
- description="%(prog)s will get the system serial number from an OBMC" +
- " machine and print it to stdout as follows:\n\n" +
- "mch_ser_num:<ser num>",
+ description="%(prog)s will get the system serial number from an OBMC"
+ + " machine and print it to stdout as follows:\n\n"
+ + "mch_ser_num:<ser num>",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prefix_chars='-+')
@@ -130,8 +130,8 @@
try:
mch_ser_num = json['data']['SerialNumber']
except KeyError:
- print_error_report("Failed to find 'SerialNumber' key in the" +
- " following data:\n" + sprint_var(json))
+ print_error_report("Failed to find 'SerialNumber' key in the"
+ + " following data:\n" + sprint_var(json))
return False
print_var(mch_ser_num, 0, 0, 0)
diff --git a/bin/plug_ins/Auto_reboot/cp_master b/bin/plug_ins/Auto_reboot/cp_master
index 843d73e..7e1b274 100755
--- a/bin/plug_ins/Auto_reboot/cp_master
+++ b/bin/plug_ins/Auto_reboot/cp_master
@@ -22,8 +22,7 @@
parser = argparse.ArgumentParser(
usage='%(prog)s [OPTIONS]',
- description="%(prog)s will set the auto_boot policy according to the"
- + " user's wishes.",
+ description="%(prog)s will set the auto_boot policy according to the user's wishes.",
formatter_class=argparse.RawTextHelpFormatter,
prefix_chars='-+')
@@ -35,6 +34,7 @@
AUTO_REBOOT_DISABLE = "1"
+
def validate_parms():
r"""
diff --git a/bin/plug_ins/Soft_errors/cp_post_boot b/bin/plug_ins/Soft_errors/cp_post_boot
index 8a562da..9f9d515 100755
--- a/bin/plug_ins/Soft_errors/cp_post_boot
+++ b/bin/plug_ins/Soft_errors/cp_post_boot
@@ -17,9 +17,9 @@
parser = argparse.ArgumentParser(
usage='%(prog)s [OPTIONS]',
description="%(prog)s will calculate the value of num_err_logs and"
- + " save it as a plug-in value for the benefit of the FFDC plug-in."
- + " The FFDC plug-in can use that data to decide whether to collect"
- + " FFDC data.",
+ + " save it as a plug-in value for the benefit of the FFDC plug-in."
+ + " The FFDC plug-in can use that data to decide whether to collect"
+ + " FFDC data.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prefix_chars='-+')
@@ -75,8 +75,9 @@
if not REDFISH_SUPPORT_TRANS_STATE:
try:
from robot.libraries.BuiltIn import BuiltIn
- REDFISH_SUPPORT_TRANS_STATE = int(BuiltIn().get_variable_value("${REDFISH_SUPPORT_TRANS_STATE}", default=0))
- except:
+ REDFISH_SUPPORT_TRANS_STATE = \
+ int(BuiltIn().get_variable_value("${REDFISH_SUPPORT_TRANS_STATE}", default=0))
+ except Exception:
pass
keyword_redfish_strings = \
@@ -96,7 +97,7 @@
"${json_string}= Evaluate json.dumps($error_logs, indent=4) modules=json",
"Append To File " + high_sev_elogs_file_path + " ${json_string}"
]
-
+
if REDFISH_SUPPORT_TRANS_STATE:
keyword_string = ' ; '.join(keyword_redfish_strings)
else:
@@ -116,7 +117,8 @@
num_error_logs = int(result['num_error_logs'])
save_plug_in_value(num_error_logs)
if num_error_logs > 0:
- qprint_timen("Adding the name of our high severity error logs FFDC file to the appropriate file list.")
+ qprint_timen("Adding the name of our high severity error logs FFDC file "
+ + "to the appropriate file list.")
shell_cmd("echo " + high_sev_elogs_file_path + " > " + AUTOBOOT_FFDC_LIST_FILE_PATH)
else:
os.remove(high_sev_elogs_file_path)
diff --git a/bin/plug_ins/Stop/cp_stop_check b/bin/plug_ins/Stop/cp_stop_check
index ba46eb7..8eb8e05 100755
--- a/bin/plug_ins/Stop/cp_stop_check
+++ b/bin/plug_ins/Stop/cp_stop_check
@@ -4,6 +4,7 @@
Check for stop conditions. Return code of 2 if stop conditions are found.
"""
+import argparse
import sys
import subprocess
import os
@@ -30,18 +31,18 @@
# Create parser object to process command line parameters and args.
parser = argparse.ArgumentParser(
usage='%(prog)s [OPTIONS]',
- description="If the \"Stop\" plug-in is selected by the user, %(prog)s" +
- " is called by OBMC Boot Test after each boot test. If %(prog)s returns" +
- " " + str(stop_test_rc) + ", then OBMC Boot Test will stop. The user" +
- " may set environment variable STOP_COMMAND to contain any valid bash" +
- " command or program. %(prog)s will run this stop command. If the stop" +
- " command returns non-zero, then %(prog)s will return " +
- str(stop_test_rc) + ". %(prog)s recognizes some special values for" +
- " STOP_COMMAND: 1) \"FAIL\" means that OBMC Boot Test should stop" +
- " whenever a boot test fails. 2) \"ALL\" means that OBMC Boot Test" +
- " should stop after any boot test. If environment variable" +
- " STOP_REST_FAIL is set, OBMC Boot Test will stop if REST commands are" +
- " no longer working.",
+ description="If the \"Stop\" plug-in is selected by the user, %(prog)s"
+ + " is called by OBMC Boot Test after each boot test. If %(prog)s returns"
+ + " " + str(stop_test_rc) + ", then OBMC Boot Test will stop. The user"
+ + " may set environment variable STOP_COMMAND to contain any valid bash"
+ + " command or program. %(prog)s will run this stop command. If the stop"
+ + " command returns non-zero, then %(prog)s will return "
+ + str(stop_test_rc) + ". %(prog)s recognizes some special values for"
+ + " STOP_COMMAND: 1) \"FAIL\" means that OBMC Boot Test should stop"
+ + " whenever a boot test fails. 2) \"ALL\" means that OBMC Boot Test"
+ + " should stop after any boot test. If environment variable"
+ + " STOP_REST_FAIL is set, OBMC Boot Test will stop if REST commands are"
+ + " no longer working.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prefix_chars='-+')
@@ -147,11 +148,11 @@
return
pel_txt_file_path = os.environ.get("AUTOBOOT_FFDC_DIR_PATH", "") + \
- os.environ.get("AUTOBOOT_FFDC_PREFIX", "") + "PEL_logs_list.json"
+ os.environ.get("AUTOBOOT_FFDC_PREFIX", "") + "PEL_logs_list.json"
if not os.path.isfile(pel_txt_file_path):
- qprint_timen("The following file was not present so no further" +
- " action will be taken.")
+ qprint_timen("The following file was not present so no further"
+ + " action will be taken.")
qprint_var(pel_txt_file_path)
return
@@ -170,22 +171,23 @@
pel_stop_list = file_to_list(pel_stop_file_path, newlines=0, comments=0)
if len(pel_stop_list) == 0:
- print_timen("There are no records to process in " +
- pel_stop_file_path + ".")
+ print_timen("There are no records to process in "
+ + pel_stop_file_path + ".")
return
pel_all_list = file_to_list(pel_txt_file_path, newlines=0, comments=0)
if len(pel_all_list) == 0:
- print_timen("There are no records to process in " +
- pel_txt_file_path + ".")
+ print_timen("There are no records to process in "
+ + pel_txt_file_path + ".")
return
for stop_pel in pel_stop_list:
for pel_all in pel_all_list:
pel_match = re.search(".*SRC.*" + stop_pel + ".*", pel_all)
if pel_match:
- print_timen("The caller wishes to stop test execution based on the presence of certain PEL entries.")
+ print_timen("The caller wishes to stop test execution based on "
+ + "the presence of certain PEL entries.")
stop_check()
diff --git a/bin/print_ffdc_functions b/bin/print_ffdc_functions
index 7d56584..dd46bc6 100755
--- a/bin/print_ffdc_functions
+++ b/bin/print_ffdc_functions
@@ -21,19 +21,19 @@
set_exit_on_error(True)
parser = argparse.ArgumentParser(
- usage='%(prog)s [OPTIONS]',
- description="%(prog)s will print a colon-delimited list of all valid OBMC FFDC functions.\n\nExample:" +
- "\n\n\nDump Log:FFDC Generic Report:Get Request FFDC:SEL Log:BMC Specific Files:Sys Inventory Files" +
- ":Core Files:OS FFDC:Dump Files",
+ usage="%(prog)s [OPTIONS]",
+ description="%(prog)s will print a colon-delimited list of all valid OBMC FFDC functions.\n\nExample:"
+ + "\n\n\nDump Log:FFDC Generic Report:Get Request FFDC:SEL Log:BMC Specific Files:Sys Inventory Files"
+ + ":Core Files:OS FFDC:Dump Files",
formatter_class=argparse.RawDescriptionHelpFormatter,
- prefix_chars='-+')
+ prefix_chars="-+",
+)
# Populate stock_list with options we want.
stock_list = [("test_mode", 0), ("quiet", 1), ("debug", 0)]
-def exit_function(signal_number=0,
- frame=None):
+def exit_function(signal_number=0, frame=None):
r"""
Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
"""
@@ -44,8 +44,7 @@
qprint_pgm_footer()
-def signal_handler(signal_number,
- frame):
+def signal_handler(signal_number, frame):
r"""
Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
with return code 143 and without calling our exit_function.
@@ -77,9 +76,9 @@
qprint_pgm_header()
my_openbmc_ffdc_list = openbmc_ffdc_list()
- ffdc_function_list = my_openbmc_ffdc_list.get_ffdc_method_desc('BMC LOGS')
+ ffdc_function_list = my_openbmc_ffdc_list.get_ffdc_method_desc("BMC LOGS")
# Convert from list to colon-delimited string.
- ffdc_function_list = ':'.join(ffdc_function_list)
+ ffdc_function_list = ":".join(ffdc_function_list)
print(ffdc_function_list)