Formatted python files to follow PEP 8 python code standards.

  - Changed the python files in the openbmc-test-automation
    directory to conform to python code style standards with
    the exception of E402 and E501.
  - Resolves openbmc/openbmc-test-automation#1308

Change-Id: I109995c2d248f5a6bb2c0e3c76a6144c8f3aac2e
Signed-off-by: Joy Onyerikwu <onyekachukwu.joy.onyerikwu@ibm.com>
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/code_update_utils.py b/lib/code_update_utils.py
index e041c05..0fa0114 100644
--- a/lib/code_update_utils.py
+++ b/lib/code_update_utils.py
@@ -26,8 +26,8 @@
     Check that there are no active images with the same purpose and priority.
 
     Description of argument(s):
-    image_purpose  The purpose that images must have to be checked for
-                   priority duplicates.
+    image_purpose                   The purpose that images must have to be
+                                    checked for priority duplicates.
     """
 
     taken_priorities = {}
@@ -41,7 +41,8 @@
         image_priority = image["Priority"]
         if image_priority in taken_priorities:
             BuiltIn().fail("Found active images with the same priority.\n"
-                           + gp.sprint_vars(image, taken_priorities[image_priority]))
+                           + gp.sprint_vars(image,
+                                            taken_priorities[image_priority]))
         taken_priorities[image_priority] = image
 
 
@@ -90,8 +91,9 @@
     change from the state provided by the calling function.
 
     Description of argument(s):
-    version_id     The version ID whose state change we are waiting for.
-    initial_state  The activation state we want to wait for.
+    version_id                      The version ID whose state change we are
+                                    waiting for.
+    initial_state                   The activation state we want to wait for.
     """
 
     keyword.run_key_u("Open Connection And Log In")
@@ -100,9 +102,9 @@
     read_fail_threshold = 1
     while (retry < 30):
         # TODO: Use retry option in run_key when available.
-        status, software_state = keyword.run_key("Read Properties  " +
-                                                 var.SOFTWARE_VERSION_URI +
-                                                 str(version_id),
+        status, software_state = keyword.run_key("Read Properties  "
+                                                 + var.SOFTWARE_VERSION_URI
+                                                 + str(version_id),
                                                  ignore=1)
         if status == 'FAIL':
             num_read_errors += 1
@@ -128,15 +130,15 @@
     Get the path to the latest uploaded file.
 
     Description of argument(s):
-    dir_path    Path to the dir from which the name of the last
-                updated file or folder will be returned to the
-                calling function.
+    dir_path                        Path to the dir from which the name of the
+                                    last updated file or folder will be
+                                    returned to the calling function.
     """
 
     stdout, stderr, rc = \
-        bsu.bmc_execute_command("cd " + dir_path +
-                                "; stat -c '%Y %n' * |" +
-                                " sort -k1,1nr | head -n 1")
+        bsu.bmc_execute_command("cd " + dir_path
+                                + "; stat -c '%Y %n' * |"
+                                + " sort -k1,1nr | head -n 1")
     return stdout.split(" ")[-1]
 
 
@@ -145,8 +147,8 @@
     Read the image version from the MANIFEST inside the tarball.
 
     Description of argument(s):
-    tar_file_path    The path to a tar file that holds the image
-                     version inside the MANIFEST.
+    tar_file_path                   The path to a tar file that holds the image
+                                    version inside the MANIFEST.
     """
 
     tar = tarfile.open(tar_file_path)
@@ -167,12 +169,13 @@
     Read the file for a version object.
 
     Description of argument(s):
-    file_path    The path to a file that holds the image version.
+    file_path                       The path to a file that holds the image
+                                    version.
     """
 
     stdout, stderr, rc = \
-        bsu.bmc_execute_command("cat "  + file_path +
-                                " | grep \"version=\"", ignore_err=1)
+        bsu.bmc_execute_command("cat " + file_path
+                                + " | grep \"version=\"", ignore_err=1)
     return (stdout.split("\n")[0]).split("=")[-1]
 
 
@@ -181,12 +184,13 @@
     Read the file for a purpose object.
 
     Description of argument(s):
-    file_path    The path to a file that holds the image purpose.
+    file_path                       The path to a file that holds the image
+                                    purpose.
     """
 
     stdout, stderr, rc = \
-        bsu.bmc_execute_command("cat " + file_path +
-                                " | grep \"purpose=\"", ignore_err=1)
+        bsu.bmc_execute_command("cat " + file_path
+                                + " | grep \"purpose=\"", ignore_err=1)
     return stdout.split("=")[-1]
 
 
@@ -198,13 +202,12 @@
     exists and is either READY or INVALID.
 
     Description of argument(s):
-    image_version    The version of the image that should match one
-                     of the images in the upload dir.
+    image_version                   The version of the image that should match
+                                    one of the images in the upload dir.
     """
 
     stdout, stderr, rc = \
-        bsu.bmc_execute_command("ls -d " + var.IMAGE_UPLOAD_DIR_PATH +
-                                "*/")
+        bsu.bmc_execute_command("ls -d " + var.IMAGE_UPLOAD_DIR_PATH + "*/")
 
     image_list = stdout.split("\n")
     retry = 0
@@ -225,10 +228,10 @@
     fails, try again until we reach the timeout.
 
     Description of argument(s):
-    image_version  The version from the image's manifest file
-                   (e.g. "v2.2-253-g00050f1").
-    timeout        How long, in minutes, to keep trying to find the
-                   image on the BMC. Default is 3 minutes.
+    image_version                   The version from the image's manifest file
+                                    (e.g. "v2.2-253-g00050f1").
+    timeout                         How long, in minutes, to keep trying to
+                                    find the image on the BMC. Default is 3 minutes.
     """
 
     image_path = get_image_path(image_version)
@@ -236,8 +239,8 @@
 
     keyword.run_key_u("Open Connection And Log In")
     image_purpose = get_image_purpose(image_path + "MANIFEST")
-    if (image_purpose == var.VERSION_PURPOSE_BMC or
-            image_purpose == var.VERSION_PURPOSE_HOST):
+    if (image_purpose == var.VERSION_PURPOSE_BMC
+            or image_purpose == var.VERSION_PURPOSE_HOST):
         uri = var.SOFTWARE_VERSION_URI + image_version_id
         ret_values = ""
         for itr in range(timeout * 2):
@@ -266,17 +269,18 @@
     unpacking the image.
 
     Description of argument(s):
-    image_version  The version of the image to look for on the BMC.
-    timeout        How long, in minutes, to try to find an image on the BMC.
-                   Default is 3 minutes.
+    image_version                   The version of the image to look for on
+                                    the BMC.
+    timeout                         How long, in minutes, to try to find an
+                                    image on the BMC. Default is 3 minutes.
     """
 
     for i in range(timeout * 2):
         stdout, stderr, rc = \
-        bsu.bmc_execute_command('ls ' + var.IMAGE_UPLOAD_DIR_PATH +
-                                '*/MANIFEST 2>/dev/null ' +
-                                '| xargs grep -rl "version=' +
-                                image_version + '"')
+            bsu.bmc_execute_command('ls ' + var.IMAGE_UPLOAD_DIR_PATH
+                                    + '*/MANIFEST 2>/dev/null '
+                                    + '| xargs grep -rl "version='
+                                    + image_version + '"')
         image_dir = os.path.dirname(stdout.split('\n')[0])
         if '' != image_dir:
             bsu.bmc_execute_command('rm -rf ' + image_dir)
diff --git a/lib/dump_utils.py b/lib/dump_utils.py
index dd15162..94b6b36 100755
--- a/lib/dump_utils.py
+++ b/lib/dump_utils.py
@@ -33,10 +33,14 @@
     Example output:
 
     dump_dict:
-      [1]: /var/lib/phosphor-debug-collector/dumps/1/obmcdump_1_1508255216.tar.xz
-      [2]: /var/lib/phosphor-debug-collector/dumps/2/obmcdump_2_1508255245.tar.xz
-      [3]: /var/lib/phosphor-debug-collector/dumps/3/obmcdump_3_1508255267.tar.xz
-      [4]: /var/lib/phosphor-debug-collector/dumps/4/obmcdump_4_1508255283.tar.xz
+      [1]:
+      /var/lib/phosphor-debug-collector/dumps/1/obmcdump_1_1508255216.tar.xz
+      [2]:
+      /var/lib/phosphor-debug-collector/dumps/2/obmcdump_2_1508255245.tar.xz
+      [3]:
+      /var/lib/phosphor-debug-collector/dumps/3/obmcdump_3_1508255267.tar.xz
+      [4]:
+      /var/lib/phosphor-debug-collector/dumps/4/obmcdump_4_1508255283.tar.xz
 
     Description of argument(s):
     quiet                           If quiet is set to 1, this function will
@@ -123,8 +127,8 @@
     for dump_id, source_file_path in dump_dict.iteritems():
         targ_file_path = targ_dir_path + targ_file_prefix \
             + os.path.basename(source_file_path)
-        status, ret_values = grk.run_key("scp.Get File  " + source_file_path +
-                                         "  " + targ_file_path, quiet=quiet)
+        status, ret_values = grk.run_key("scp.Get File  " + source_file_path
+                                         + "  " + targ_file_path, quiet=quiet)
         dump_file_list.append(targ_file_path)
 
     return dump_file_list
diff --git a/lib/firmware_utils.py b/lib/firmware_utils.py
index 9885790..4e0dbb5 100755
--- a/lib/firmware_utils.py
+++ b/lib/firmware_utils.py
@@ -14,8 +14,8 @@
     dictionary.
 
     Description of argument(s):
-    device  The device to be passed to the hdparm and lsblk commands (e.g.
-            "/dev/sdb").
+    device                          The device to be passed to the hdparm and
+                                    lsblk commands (e.g. "/dev/sdb").
 
     Example result:
 
@@ -23,7 +23,8 @@
       [model_number]:                        MTFDDAK1T9TCB 00LY461 00LY570IBM
       [serial_number]:                       179C413F
       [firmware_revision]:                   MJ06
-      [transport]:                           Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
+      [transport]:                           Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5,
+                                             SATA Rev 2.6, SATA Rev 3.0
       [used]:                                unknown (minor revision code 0x006d)
       [supported]:                           enhanced erase
       [likely_used]:                         10
diff --git a/lib/gen_arg.py b/lib/gen_arg.py
index badc099..313a486 100755
--- a/lib/gen_arg.py
+++ b/lib/gen_arg.py
@@ -57,7 +57,7 @@
                             " the desired stock parameter:\n" +\
                             gp.sprint_var(stock_list)
             return gv.process_error_message(error_message)
-        if type(stock_list[ix]) is tuple:
+        if isinstance(stock_list[ix], tuple):
             arg_name = stock_list[ix][0]
             default = stock_list[ix][1]
         else:
@@ -78,10 +78,10 @@
                 default=default,
                 type=int,
                 choices=[1, 0],
-                help='If this parameter is set to "1", %(prog)s' +
-                     ' will print only essential information, i.e. it will' +
-                     ' not echo parameters, echo commands, print the total' +
-                     ' run time, etc.' + default_string)
+                help='If this parameter is set to "1", %(prog)s'
+                     + ' will print only essential information, i.e. it will'
+                     + ' not echo parameters, echo commands, print the total'
+                     + ' run time, etc.' + default_string)
         elif arg_name == "test_mode":
             if default is None:
                 default = 0
@@ -90,10 +90,10 @@
                 default=default,
                 type=int,
                 choices=[1, 0],
-                help='This means that %(prog)s should go through all the' +
-                     ' motions but not actually do anything substantial.' +
-                     '  This is mainly to be used by the developer of' +
-                     ' %(prog)s.' + default_string)
+                help='This means that %(prog)s should go through all the'
+                     + ' motions but not actually do anything substantial.'
+                     + '  This is mainly to be used by the developer of'
+                     + ' %(prog)s.' + default_string)
         elif arg_name == "debug":
             if default is None:
                 default = 0
@@ -102,9 +102,9 @@
                 default=default,
                 type=int,
                 choices=[1, 0],
-                help='If this parameter is set to "1", %(prog)s will print' +
-                     ' additional debug information.  This is mainly to be' +
-                     ' used by the developer of %(prog)s.' + default_string)
+                help='If this parameter is set to "1", %(prog)s will print'
+                     + ' additional debug information.  This is mainly to be'
+                     + ' used by the developer of %(prog)s.' + default_string)
         elif arg_name == "loglevel":
             if default is None:
                 default = "info"
@@ -114,9 +114,9 @@
                 type=str,
                 choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL',
                          'debug', 'info', 'warning', 'error', 'critical'],
-                help='If this parameter is set to "1", %(prog)s will print' +
-                     ' additional debug information.  This is mainly to be' +
-                     ' used by the developer of %(prog)s.' + default_string)
+                help='If this parameter is set to "1", %(prog)s will print'
+                     + ' additional debug information.  This is mainly to be'
+                     + ' used by the developer of %(prog)s.' + default_string)
 
     arg_obj = parser.parse_args()
 
@@ -125,7 +125,7 @@
     __builtin__.debug = 0
     __builtin__.loglevel = 'WARNING'
     for ix in range(0, len(stock_list)):
-        if type(stock_list[ix]) is tuple:
+        if isinstance(stock_list[ix], tuple):
             arg_name = stock_list[ix][0]
             default = stock_list[ix][1]
         else:
diff --git a/lib/gen_call_robot.py b/lib/gen_call_robot.py
index 56fc19a..41ad582 100755
--- a/lib/gen_call_robot.py
+++ b/lib/gen_call_robot.py
@@ -23,7 +23,6 @@
 
 
 def init_robot_out_parms(extra_prefix=""):
-
     r"""
     Initialize robot output parms such as outputdir, output, etc.
 
@@ -64,7 +63,6 @@
 
 
 def init_robot_test_base_dir_path():
-
     r"""
     Initialize and validate the environment variable, ROBOT_TEST_BASE_DIR_PATH
     and set corresponding global variable ROBOT_TEST_RUNNING_FROM_SB.
@@ -116,9 +114,9 @@
                 gp.dprint_vars(ROBOT_TEST_RUNNING_FROM_SB)
                 ROBOT_TEST_BASE_DIR_PATH = developer_home_dir_path + suffix
                 if not os.path.isdir(ROBOT_TEST_BASE_DIR_PATH):
-                    gp.dprint_timen("NOTE: Sandbox directory" +
-                                    " ${ROBOT_TEST_BASE_DIR_PATH} does not" +
-                                    " exist.")
+                    gp.dprint_timen("NOTE: Sandbox directory"
+                                    + " ${ROBOT_TEST_BASE_DIR_PATH} does not"
+                                    + " exist.")
                     # Fall back to the apollo dir path.
                     ROBOT_TEST_BASE_DIR_PATH = apollo_dir_path + suffix
             else:
@@ -145,7 +143,6 @@
 
 
 def init_robot_file_path(robot_file_path):
-
     r"""
     Determine full path name for the file path passed in robot_file_path and
     return it.
@@ -206,7 +203,6 @@
 
 
 def get_robot_parm_names():
-
     r"""
     Return a list containing all of the long parm names (e.g. --outputdir)
     supported by the robot program.  Double dashes are not included in the
@@ -214,15 +210,14 @@
     """
 
     cmd_buf = "robot -h | egrep " +\
-        "'^([ ]\-[a-zA-Z0-9])?[ ]+--[a-zA-Z0-9]+[ ]+' | sed -re" +\
-        " s'/.*\-\-//g' -e s'/ .*//g' | sort -u"
+        "'^([ ]\\-[a-zA-Z0-9])?[ ]+--[a-zA-Z0-9]+[ ]+' | sed -re" +\
+        " s'/.*\\-\\-//g' -e s'/ .*//g' | sort -u"
     shell_rc, out_buf = gc.shell_cmd(cmd_buf, quiet=1, print_output=0)
 
     return out_buf.split("\n")
 
 
 def create_robot_cmd_string(robot_file_path, *parms):
-
     r"""
     Create a robot command string and return it.  On failure, return an empty
     string.
@@ -281,7 +276,6 @@
 def robot_cmd_fnc(robot_cmd_buf,
                   robot_jail=os.environ.get('ROBOT_JAIL', ''),
                   gzip=1):
-
     r"""
     Run the robot command string.
 
@@ -384,12 +378,12 @@
     # Retrieve the parms from the robot command buffer.
     robot_cmd_buf_dict = gc.parse_command_string(robot_cmd_buf)
     # Get prefix from the log parm.
-    prefix = re.sub('log\.html$', '', robot_cmd_buf_dict['log'])
+    prefix = re.sub('log\\.html$', '', robot_cmd_buf_dict['log'])
     gp.qprintn()
-    rc, outbuf = gc.cmd_fnc("cd " + robot_cmd_buf_dict['outputdir'] +
-                            " ; gzip " + robot_cmd_buf_dict['output'] +
-                            " " + robot_cmd_buf_dict['log'] +
-                            " " + robot_cmd_buf_dict['report'])
+    rc, outbuf = gc.cmd_fnc("cd " + robot_cmd_buf_dict['outputdir']
+                            + " ; gzip " + robot_cmd_buf_dict['output']
+                            + " " + robot_cmd_buf_dict['log']
+                            + " " + robot_cmd_buf_dict['report'])
 
     outputdir = gm.add_trailing_slash(robot_cmd_buf_dict['outputdir'])
     Output = outputdir + robot_cmd_buf_dict['output'] + ".gz"
diff --git a/lib/gen_cmd.py b/lib/gen_cmd.py
index 0919fe1..bdd8258 100644
--- a/lib/gen_cmd.py
+++ b/lib/gen_cmd.py
@@ -246,7 +246,7 @@
             key = 'positional'
             value = command_string_list[ix]
         if key in command_string_dict:
-            if type(command_string_dict[key]) is str:
+            if isinstance(command_string_dict[key], str):
                 command_string_dict[key] = [command_string_dict[key]]
             command_string_dict[key].append(value)
         else:
@@ -443,9 +443,9 @@
                 func_stdout += gp.sprint_error_report(err_msg)
         func_history_stdout += func_stdout
         if attempt_num < max_attempts:
-            func_history_stdout += gp.sprint_issuing("time.sleep(" +
-                                                     str(retry_sleep_time) +
-                                                     ")")
+            func_history_stdout += gp.sprint_issuing("time.sleep("
+                                                     + str(retry_sleep_time)
+                                                     + ")")
             time.sleep(retry_sleep_time)
 
     if shell_rc not in allowed_shell_rcs:
diff --git a/lib/gen_misc.py b/lib/gen_misc.py
index 281c406..75487c1 100755
--- a/lib/gen_misc.py
+++ b/lib/gen_misc.py
@@ -107,9 +107,9 @@
     try:
         module = sys.modules[mod_name]
     except KeyError:
-        gp.print_error_report("Programmer error - The mod_name passed to" +
-                              " this function is invalid:\n" +
-                              gp.sprint_var(mod_name))
+        gp.print_error_report("Programmer error - The mod_name passed to"
+                              + " this function is invalid:\n"
+                              + gp.sprint_var(mod_name))
         raise ValueError('Programmer error.')
 
     if default is None:
@@ -161,9 +161,9 @@
     try:
         module = sys.modules[mod_name]
     except KeyError:
-        gp.print_error_report("Programmer error - The mod_name passed to" +
-                              " this function is invalid:\n" +
-                              gp.sprint_var(mod_name))
+        gp.print_error_report("Programmer error - The mod_name passed to"
+                              + " this function is invalid:\n"
+                              + gp.sprint_var(mod_name))
         raise ValueError('Programmer error.')
 
     if var_name is None:
@@ -360,7 +360,6 @@
 
 def to_signed(number,
               bit_width=gp.bit_length(long(sys.maxsize)) + 1):
-
     r"""
     Convert number to a signed number and return the result.
 
diff --git a/lib/gen_plug_in.py b/lib/gen_plug_in.py
index 461ae57..1bd70a1 100755
--- a/lib/gen_plug_in.py
+++ b/lib/gen_plug_in.py
@@ -68,8 +68,8 @@
 
     global plug_in_base_path_list
     for plug_in_base_dir_path in plug_in_base_path_list:
-        candidate_plug_in_dir_path = os.path.normpath(plug_in_base_dir_path +
-                                                      plug_in_name) + \
+        candidate_plug_in_dir_path = os.path.normpath(plug_in_base_dir_path
+                                                      + plug_in_name) + \
             os.sep
         if os.path.isdir(candidate_plug_in_dir_path):
             return candidate_plug_in_dir_path
@@ -98,8 +98,8 @@
         candidate_plug_in_dir_path = os.path.normpath(plug_in_dir_path) +\
             os.sep
         if not os.path.isdir(candidate_plug_in_dir_path):
-            gp.print_error_report("Plug-in directory path \"" +
-                                  plug_in_dir_path + "\" does not exist.\n")
+            gp.print_error_report("Plug-in directory path \""
+                                  + plug_in_dir_path + "\" does not exist.\n")
             exit(1)
     else:
         # The plug_in_dir_path is actually a simple name (e.g.
@@ -107,22 +107,22 @@
         candidate_plug_in_dir_path = find_plug_in_package(plug_in_dir_path)
         if candidate_plug_in_dir_path == "":
             global PATH_LIST
-            gp.print_error_report("Plug-in directory path \"" +
-                                  plug_in_dir_path + "\" could not be found" +
-                                  " in any of the following directories:\n" +
-                                  gp.sprint_var(PATH_LIST))
+            gp.print_error_report("Plug-in directory path \""
+                                  + plug_in_dir_path + "\" could not be found"
+                                  + " in any of the following directories:\n"
+                                  + gp.sprint_var(PATH_LIST))
             exit(1)
     # Make sure that this plug-in supports us...
     supports_file_path = candidate_plug_in_dir_path + "supports_" + mch_class
     if not os.path.exists(supports_file_path):
-        gp.print_error_report("The following file path could not be" +
-                              " found:\n" +
-                              gp.sprint_varx("supports_file_path",
-                                             supports_file_path) +
-                              "\nThis file is necessary to indicate that" +
-                              " the given plug-in supports the class of" +
-                              " machine we are testing, namely \"" +
-                              mch_class + "\".\n")
+        gp.print_error_report("The following file path could not be"
+                              + " found:\n"
+                              + gp.sprint_varx("supports_file_path",
+                                               supports_file_path)
+                              + "\nThis file is necessary to indicate that"
+                              + " the given plug-in supports the class of"
+                              + " machine we are testing, namely \""
+                              + mch_class + "\".\n")
         exit(1)
 
     return candidate_plug_in_dir_path
@@ -153,8 +153,8 @@
 
     for plug_in_base_path in plug_in_base_path_list:
         # Get a list of all plug-in paths that support our mch_class.
-        mch_class_candidate_list = glob.glob(plug_in_base_path +
-                                             "*/supports_" + mch_class)
+        mch_class_candidate_list = glob.glob(plug_in_base_path
+                                             + "*/supports_" + mch_class)
         for candidate_path in mch_class_candidate_list:
             integrated_plug_in_dir_path = os.path.dirname(candidate_path) +\
                 os.sep
diff --git a/lib/gen_plug_in_utils.py b/lib/gen_plug_in_utils.py
index 39a8a97..34b227f 100755
--- a/lib/gen_plug_in_utils.py
+++ b/lib/gen_plug_in_utils.py
@@ -283,8 +283,8 @@
 
     # Calculate default value for plug_in_dir_paths.
     if plug_in_dir_paths is None:
-        plug_in_dir_paths = os.environ.get(PLUG_VAR_PREFIX +
-                                           "_PLUG_IN_DIR_PATHS", "")
+        plug_in_dir_paths = os.environ.get(PLUG_VAR_PREFIX
+                                           + "_PLUG_IN_DIR_PATHS", "")
 
     error_message = ""
 
@@ -336,8 +336,8 @@
     """
 
     BASE_TOOL_DIR_PATH = \
-        gm.add_trailing_slash(os.environ.get(PLUG_VAR_PREFIX +
-                                             "BASE_TOOL_DIR_PATH",
+        gm.add_trailing_slash(os.environ.get(PLUG_VAR_PREFIX
+                                             + "BASE_TOOL_DIR_PATH",
                                              "/fspmount/"))
     NICKNAME = os.environ.get("AUTOBOOT_OPENBMC_NICKNAME", "")
     if NICKNAME == "":
@@ -421,13 +421,13 @@
     plug_in_save_dir_path = create_plug_in_save_dir()
     save_file_path = plug_in_save_dir_path + lvalue
     if os.path.isfile(save_file_path):
-        gp.qprint_timen("Restoring " + lvalue + " value from " +
-                        save_file_path + ".")
+        gp.qprint_timen("Restoring " + lvalue + " value from "
+                        + save_file_path + ".")
         return gm.file_to_list(save_file_path, newlines=0, comments=0,
                                trim=1)[0]
     else:
-        gp.qprint_timen("Save file " + save_file_path +
-                        " does not exist so returning default value.")
+        gp.qprint_timen("Save file " + save_file_path
+                        + " does not exist so returning default value.")
         return default
 
 
diff --git a/lib/gen_print.py b/lib/gen_print.py
index 0de4489..ed254fc 100755
--- a/lib/gen_print.py
+++ b/lib/gen_print.py
@@ -27,7 +27,7 @@
     # are in a robot environment.  The following try block should confirm that.
     try:
         var_value = BuiltIn().get_variable_value("${SUITE_NAME}", "")
-    except:
+    except BaseException:
         robot_env = 0
 except ImportError:
     robot_env = 0
@@ -203,10 +203,10 @@
         os.environ.get('GET_ARG_NAME_SHOW_SOURCE', 0))
 
     if stack_frame_ix < 1:
-        print_error("Programmer error - Variable \"stack_frame_ix\" has an" +
-                    " invalid value of \"" + str(stack_frame_ix) + "\".  The" +
-                    " value must be an integer that is greater than or equal" +
-                    " to 1.\n")
+        print_error("Programmer error - Variable \"stack_frame_ix\" has an"
+                    + " invalid value of \"" + str(stack_frame_ix) + "\".  The"
+                    + " value must be an integer that is greater than or equal"
+                    + " to 1.\n")
         return
 
     if local_debug:
@@ -225,12 +225,12 @@
             frame, filename, cur_line_no, function_name, lines, index = \
                 inspect.stack()[stack_frame_ix]
         except IndexError:
-            print_error("Programmer error - The caller has asked for" +
-                        " information about the stack frame at index \"" +
-                        str(stack_frame_ix) + "\".  However, the stack" +
-                        " only contains " + str(len(inspect.stack())) +
-                        " entries.  Therefore the stack frame index is out" +
-                        " of range.\n")
+            print_error("Programmer error - The caller has asked for"
+                        + " information about the stack frame at index \""
+                        + str(stack_frame_ix) + "\".  However, the stack"
+                        + " only contains " + str(len(inspect.stack()))
+                        + " entries.  Therefore the stack frame index is out"
+                        + " of range.\n")
             return
         if filename != "<string>":
             break
@@ -308,11 +308,11 @@
 
     # The call to the function could be encased in a recast (e.g.
     # int(func_name())).
-    recast_regex = "([^ ]+\([ ]*)?"
-    import_name_regex = "([a-zA-Z0-9_]+\.)?"
+    recast_regex = "([^ ]+\\([ ]*)?"
+    import_name_regex = "([a-zA-Z0-9_]+\\.)?"
     func_name_regex = recast_regex + import_name_regex + "(" +\
         '|'.join(aliases) + ")"
-    pre_args_regex = ".*" + func_name_regex + "[ ]*\("
+    pre_args_regex = ".*" + func_name_regex + "[ ]*\\("
 
     # Search backward through source lines looking for the calling function
     # name.
@@ -325,9 +325,9 @@
             found = True
             break
     if not found:
-        print_error("Programmer error - Could not find the source line with" +
-                    " a reference to function \"" + real_called_func_name +
-                    "\".\n")
+        print_error("Programmer error - Could not find the source line with"
+                    + " a reference to function \"" + real_called_func_name
+                    + "\".\n")
         return
 
     # Search forward through the source lines looking for a line whose
@@ -375,7 +375,8 @@
         lvalues[ix] = lvalue
         ix += 1
     lvalue_prefix_regex = "(.*=[ ]+)?"
-    called_func_name_regex = lvalue_prefix_regex + func_name_regex + "[ ]*\(.*"
+    called_func_name_regex = lvalue_prefix_regex + func_name_regex +\
+        "[ ]*\\(.*"
     called_func_name = re.sub(called_func_name_regex, "\\4", composite_line)
     arg_list_etc = "(" + re.sub(pre_args_regex, "", composite_line)
     if local_debug:
@@ -805,7 +806,7 @@
                                     var_value & 0xffffffff)
         else:
             return format_string % ("", str(var_name) + ":", var_value)
-    elif type(var_value) is type:
+    elif isinstance(var_value, type):
         return sprint_varx(var_name, str(var_value).split("'")[1], hex,
                            loc_col1_indent, loc_col1_width, trailing_char,
                            key_list)
@@ -821,20 +822,20 @@
         ix = 0
         loc_trailing_char = "\n"
         type_is_dict = 0
-        if type(var_value) is dict:
+        if isinstance(var_value, dict):
             type_is_dict = 1
         try:
-            if type(var_value) is collections.OrderedDict:
+            if isinstance(var_value, collections.OrderedDict):
                 type_is_dict = 1
         except AttributeError:
             pass
         try:
-            if type(var_value) is DotDict:
+            if isinstance(var_value, DotDict):
                 type_is_dict = 1
         except NameError:
             pass
         try:
-            if type(var_value) is NormalizedDict:
+            if isinstance(var_value, NormalizedDict):
                 type_is_dict = 1
         except NameError:
             pass
@@ -851,7 +852,7 @@
                     # Since hex is being used as a format type, we want it
                     # turned off when processing integer dictionary values so
                     # it is not interpreted as a hex indicator.
-                    loc_hex = not (type(value) is int)
+                    loc_hex = not (isinstance(value, int))
                     buffer += sprint_varx("[" + key + "]", value,
                                           loc_hex, loc_col1_indent,
                                           loc_col1_width,
@@ -870,7 +871,7 @@
                 buffer += sprint_varx(var_name + "[" + str(key) + "]", value,
                                       hex, loc_col1_indent, loc_col1_width,
                                       loc_trailing_char, key_list)
-        elif type(var_value) is argparse.Namespace:
+        elif isinstance(var_value, argparse.Namespace):
             for key in var_value.__dict__:
                 ix += 1
                 if ix == length:
@@ -956,7 +957,7 @@
     var_name = get_arg_name(None, parm_num, stack_frame)
     # See if parm 1 is to be interpreted as "indent".
     try:
-        if type(int(var_name)) is int:
+        if isinstance(int(var_name), int):
             indent = int(var_name)
             args_list.pop(0)
             parm_num += 1
@@ -966,7 +967,7 @@
     var_name = get_arg_name(None, parm_num, stack_frame)
     # See if parm 1 is to be interpreted as "col1_width".
     try:
-        if type(int(var_name)) is int:
+        if isinstance(int(var_name), int):
             loc_col1_width = int(var_name)
             args_list.pop(0)
             parm_num += 1
@@ -976,7 +977,7 @@
     var_name = get_arg_name(None, parm_num, stack_frame)
     # See if parm 1 is to be interpreted as "hex".
     try:
-        if type(int(var_name)) is int:
+        if isinstance(int(var_name), int):
             hex = int(var_name)
             args_list.pop(0)
             parm_num += 1
@@ -1197,8 +1198,8 @@
 
     if robot_env:
         suite_name = BuiltIn().get_variable_value("${suite_name}")
-        buffer += sindent(sprint_time("Running test suite \"" + suite_name +
-                                      "\".\n"), indent)
+        buffer += sindent(sprint_time("Running test suite \"" + suite_name
+                                      + "\".\n"), indent)
 
     buffer += sindent(sprint_time() + "Running " + pgm_name + ".\n", indent)
     buffer += sindent(sprint_time() + "Program parameter values, etc.:\n\n",
@@ -1220,10 +1221,10 @@
             username = "root"
         else:
             username = "?"
-    buffer += sprint_varx("uid", userid_num + " (" + username +
-                          ")", 0, indent, loc_col1_width)
-    buffer += sprint_varx("gid", str(os.getgid()) + " (" +
-                          str(grp.getgrgid(os.getgid()).gr_name) + ")", 0,
+    buffer += sprint_varx("uid", userid_num + " (" + username
+                          + ")", 0, indent, loc_col1_width)
+    buffer += sprint_varx("gid", str(os.getgid()) + " ("
+                          + str(grp.getgrgid(os.getgid()).gr_name) + ")", 0,
                           indent, loc_col1_width)
     buffer += sprint_varx("host_name", socket.gethostname(), 0, indent,
                           loc_col1_width)
@@ -1516,7 +1517,6 @@
 def get_stack_var(var_name,
                   default="",
                   init_stack_ix=2):
-
     r"""
     Starting with the caller's stack level, search upward in the call stack,
     for a variable named var_name and return its value.  If the variable
@@ -1548,8 +1548,8 @@
     """
 
     return next((frame[0].f_locals[var_name]
-                for frame in inspect.stack()[init_stack_ix:]
-                if var_name in frame[0].f_locals), default)
+                 for frame in inspect.stack()[init_stack_ix:]
+                 if var_name in frame[0].f_locals), default)
 
 
 # hidden_text is a list of passwords which are to be replaced with asterisks
@@ -1707,8 +1707,8 @@
 # Templates for the various print wrapper functions.
 print_func_template = \
     [
-        "    <mod_qualifier>gp_print(<mod_qualifier>replace_passwords(" +
-        "<call_line>), stream='<output_stream>')"
+        "    <mod_qualifier>gp_print(<mod_qualifier>replace_passwords("
+        + "<call_line>), stream='<output_stream>')"
     ]
 
 qprint_func_template = \
@@ -1718,8 +1718,8 @@
 
 dprint_func_template = \
     [
-        "    if not int(<mod_qualifier>get_var_value(None, 0, \"debug\")):" +
-        " return"
+        "    if not int(<mod_qualifier>get_var_value(None, 0, \"debug\")):"
+        + " return"
     ] + print_func_template
 
 lprint_func_template = \
diff --git a/lib/gen_robot_plug_in.py b/lib/gen_robot_plug_in.py
index 1dc8983..d18c499 100755
--- a/lib/gen_robot_plug_in.py
+++ b/lib/gen_robot_plug_in.py
@@ -39,8 +39,8 @@
     if rc != 0:
         message = gp.sprint_varx("rc", rc, 1) + out_buf
         grp.rprintn(out_buf, 'STDERR')
-        BuiltIn().fail(gp.sprint_error("Validate plug ins call failed.  See" +
-                                       " stderr text for details.\n"))
+        BuiltIn().fail(gp.sprint_error("Validate plug ins call failed.  See"
+                                       + " stderr text for details.\n"))
 
     plug_in_packages_list = out_buf.split("\n")
     if len(plug_in_packages_list) == 1 and plug_in_packages_list[0] == "":
@@ -174,8 +174,8 @@
         if int(debug) == 1:
             grp.rpissuing(cmd_buf)
         else:
-            grp.rprint_timen("Processing " + call_point +
-                             " call point programs.")
+            grp.rprint_timen("Processing " + call_point
+                             + " call point programs.")
 
     proc_plug_pkg_rc = subprocess.call(cmd_buf, shell=True,
                                        executable='/bin/bash')
@@ -219,8 +219,8 @@
         grp.rprint_varx("grep_rc", grep_rc, hex)
         grp.rprint_varx("proc_plug_pkg_rc", proc_plug_pkg_rc, hex)
         # Show all of the failed plug in names and shell_rcs.
-        gc.cmd_fnc_u("egrep -A 1 '^failed_plug_in_name:[ ]+' " +
-                     temp_properties_file_path, quiet=1, show_err=0)
+        gc.cmd_fnc_u("egrep -A 1 '^failed_plug_in_name:[ ]+' "
+                     + temp_properties_file_path, quiet=1, show_err=0)
         rc = 1
 
     return rc, shell_rc, failed_plug_in_name
diff --git a/lib/gen_robot_print.py b/lib/gen_robot_print.py
index ca344b2..4430865 100755
--- a/lib/gen_robot_print.py
+++ b/lib/gen_robot_print.py
@@ -84,7 +84,7 @@
 
     # See if parm 1 is to be interpreted as "hex".
     try:
-        if type(int(args_list[0])) is int:
+        if isinstance(int(args_list[0]), int):
             hex = int(args_list[0])
             args_list.pop(0)
     except ValueError:
@@ -92,7 +92,7 @@
 
     # See if parm 2 is to be interpreted as "indent".
     try:
-        if type(int(args_list[0])) is int:
+        if isinstance(int(args_list[0]), int):
             indent = int(args_list[0])
             args_list.pop(0)
     except ValueError:
@@ -100,7 +100,7 @@
 
     # See if parm 3 is to be interpreted as "col1_width".
     try:
-        if type(int(args_list[0])) is int:
+        if isinstance(int(args_list[0]), int):
             loc_col1_width = int(args_list[0])
             args_list.pop(0)
     except ValueError:
@@ -259,10 +259,10 @@
         func_def = \
             [
                 "def " + robot_prefix + func_name + "(*args):",
-                "    s_func = getattr(" + object_name + ", \"s" + func_name +
-                "\")",
-                "    BuiltIn().log_to_console" +
-                "(gp.replace_passwords(s_func(*args)),"
+                "    s_func = getattr(" + object_name + ", \"s" + func_name
+                + "\")",
+                "    BuiltIn().log_to_console"
+                + "(gp.replace_passwords(s_func(*args)),"
                 " stream='" + output_stream + "',"
                 " no_newline=True)"
             ]
diff --git a/lib/gen_robot_ssh.py b/lib/gen_robot_ssh.py
index 5a4dbe1..5af114c 100755
--- a/lib/gen_robot_ssh.py
+++ b/lib/gen_robot_ssh.py
@@ -234,8 +234,8 @@
             index_or_alias = connection.index
         else:
             index_or_alias = connection.alias
-        gp.lprint_timen("Switching to existing connection: \"" +
-                        str(index_or_alias) + "\".")
+        gp.lprint_timen("Switching to existing connection: \""
+                        + str(index_or_alias) + "\".")
         sshlib.switch_connection(index_or_alias)
     else:
         gp.lprint_timen("Connecting to " + open_connection_args['host'] + ".")
@@ -270,11 +270,11 @@
                 # Now we must continue to next loop iteration to retry the
                 # execute_command.
                 continue
-            if (except_type is paramiko.ssh_exception.SSHException and
-                re.match(r"SSH session not active", str(except_value))) or\
-               (except_type is socket.error and
-                re.match(r"\[Errno 104\] Connection reset by peer",
-                         str(except_value))):
+            if (except_type is paramiko.ssh_exception.SSHException
+                and re.match(r"SSH session not active", str(except_value))) or\
+               (except_type is socket.error
+                and re.match(r"\[Errno 104\] Connection reset by peer",
+                             str(except_value))):
                 # Close and re-open a connection.
                 # Note: close_connection() doesn't appear to get rid of the
                 # connection.  It merely closes it.  Since there is a concern
@@ -283,8 +283,8 @@
                 # connections.
                 gp.lprint_timen("Closing all connections.")
                 sshlib.close_all_connections()
-                gp.lprint_timen("Connecting to " +
-                                open_connection_args['host'] + ".")
+                gp.lprint_timen("Connecting to "
+                                + open_connection_args['host'] + ".")
                 cix = sshlib.open_connection(**open_connection_args)
                 login_ssh(login_args)
                 continue
@@ -310,10 +310,10 @@
         gp.printn(stderr + stdout)
 
     if not ignore_err:
-        message = gp.sprint_error("The prior SSH" +
-                                  " command returned a non-zero return" +
-                                  " code:\n" + gp.sprint_var(rc, 1) + stderr +
-                                  "\n")
+        message = gp.sprint_error("The prior SSH"
+                                  + " command returned a non-zero return"
+                                  + " code:\n" + gp.sprint_var(rc, 1) + stderr
+                                  + "\n")
         BuiltIn().should_be_equal(rc, 0, message)
 
     if open_connection_args['alias'] == "device_connection":
diff --git a/lib/gen_robot_valid.py b/lib/gen_robot_valid.py
index 3af8750..8f761f9 100755
--- a/lib/gen_robot_valid.py
+++ b/lib/gen_robot_valid.py
@@ -173,7 +173,7 @@
         error_message = "Variable \"" + var_name +\
                         "\" not found (i.e. it's undefined).\n"
     else:
-        if type(range) is unicode:
+        if isinstance(range, unicode):
             range = range.split("..")
         if range[0] == "":
             range[0] = None
diff --git a/lib/gen_valid.py b/lib/gen_valid.py
index e18e847..f41c9cd 100755
--- a/lib/gen_valid.py
+++ b/lib/gen_valid.py
@@ -222,7 +222,7 @@
     success_message = ""
     error_message = ""
     try:
-        if type(int(str(var_value), 0)) is int:
+        if isinstance(int(str(var_value), 0), int):
             return success_message
     except ValueError:
         pass
@@ -467,8 +467,8 @@
                          " range:\n" +\
                          gp.sprint_varx(get_var_name(var_name), var_value) +\
                          gp.sprint_varx("valid_range",
-                                        str(valid_range[0]) + ".." +
-                                        str(valid_range[1]))
+                                        str(valid_range[0]) + ".."
+                                        + str(valid_range[1]))
         return error_message
 
     return error_message
diff --git a/lib/ipmi_utils.py b/lib/ipmi_utils.py
index 085ca2a..9f30e29 100644
--- a/lib/ipmi_utils.py
+++ b/lib/ipmi_utils.py
@@ -28,7 +28,8 @@
 
     Output:
     sol_info:
-      sol_info[Info]:                                SOL parameter 'Payload Channel (7)' not supported - defaulting to 0x0e
+      sol_info[Info]:                                SOL parameter 'Payload Channel (7)'
+                                                     not supported - defaulting to 0x0e
       sol_info[Character Send Threshold]:            1
       sol_info[Force Authentication]:                true
       sol_info[Privilege Level]:                     USER
@@ -66,12 +67,13 @@
     Set SOL setting with given value.
 
     # Description of argument(s):
-    # setting_name    SOL setting which needs to be set (e.g. "retry-count").
-    # setting_value   Value which needs to be set (e.g. "7").
+    # setting_name                  SOL setting which needs to be set (e.g.
+    #                               "retry-count").
+    # setting_value                 Value which needs to be set (e.g. "7").
     """
 
-    status, ret_values = grk.run_key_u("Run IPMI Standard Command  sol set " +
-                                       setting_name + " " + setting_value)
+    status, ret_values = grk.run_key_u("Run IPMI Standard Command  sol set "
+                                       + setting_name + " " + setting_value)
 
     return status
 
@@ -175,8 +177,8 @@
       [power_reading_state_is]:                   deactivated
 
     Description of argument(s):
-    strip_watts  Strip all dictionary values of the trailing " Watts"
-                 substring.
+    strip_watts                     Strip all dictionary values of the
+                                    trailing " Watts" substring.
     """
 
     status, ret_values = \
@@ -295,8 +297,9 @@
     Get IPMI Aux version info data and return it.
 
     Description of argument(s):
-    version_id    The data is obtained by from BMC /etc/os-release
-                  (e.g. "xxx-v2.1-438-g0030304-r3-gfea8585").
+    version_id                      The data is obtained by from BMC
+                                    /etc/os-release
+                                    (e.g. "xxx-v2.1-438-g0030304-r3-gfea8585").
 
     In the prior example, the 3rd field is "438" is the commit version and
     the 5th field is "r3" and value "3" is the release version.
@@ -305,10 +308,10 @@
     """
 
     # Commit version.
-    count = re.findall("-(\d{1,4})-", version_id)
+    count = re.findall("-(\\d{1,4})-", version_id)
 
     # Release version.
-    release = re.findall("-r(\d{1,4})", version_id)
+    release = re.findall("-r(\\d{1,4})", version_id)
     if release:
         aux_version = count[0] + "{0:0>4}".format(release[0])
     else:
@@ -372,7 +375,7 @@
                         ret_values)
 
     return [vf.key_value_outbuf_to_dict(x) for x in re.split("\n\n",
-            ret_values)]
+                                                             ret_values)]
 
 
 def get_component_fru_info(component='cpu',
@@ -385,11 +388,14 @@
     entries.  See get_fru_info's prolog for a layout of the data.
 
     Description of argument(s):
-    component  The component (e.g. "cpu", "dimm", etc.).
-    fru_objs   A fru_objs list such as the one returned by get_fru_info.  If
-               this is None, then this function will call get_fru_info to
-               obtain such a list.  Supplying this argument may improve
-               performance if this function is to be called multiple times.
+    component                       The component (e.g. "cpu", "dimm", etc.).
+    fru_objs                        A fru_objs list such as the one returned
+                                    by get_fru_info.  If this is None, then
+                                    this function will call get_fru_info to
+                                    obtain such a list.
+                                    Supplying this argument may improve
+                                    performance if this function is to be
+                                    called multiple times.
     """
 
     if fru_objs is None:
diff --git a/lib/logging_utils.py b/lib/logging_utils.py
index 7fc9fd7..b39aa3f 100644
--- a/lib/logging_utils.py
+++ b/lib/logging_utils.py
@@ -24,12 +24,14 @@
       directly from a robot script.
 
     Description of argument(s):
-    error_logs  An error log dictionary such as the one returned by the
-                'Get Error Logs' keyword.
-    key_list    The list of keys to be printed.  This may be specified as
-                either a python list or a space-delimited string.  In the
-                latter case, this function will convert it to a python list.
-                See the sprint_varx function prolog for additionatl details.
+    error_logs                      An error log dictionary such as the one
+                                    returned by the 'Get Error Logs' keyword.
+    key_list                        The list of keys to be printed.  This may
+                                    be specified as either a python list
+                                    or a space-delimited string.  In the
+                                    latter case, this function will convert
+                                    it to a python list. See the sprint_varx
+                                    function prolog for additionatl details.
 
     Example use from a python script:
 
@@ -41,16 +43,20 @@
     error_logs:
       [/xyz/openbmc_project/logging/entry/3]:
         [Timestamp]:                                  1521738335735
-        [Message]:                                    xyz.openbmc_project.Inventory.Error.Nonfunctional
+        [Message]:
+        xyz.openbmc_project.Inventory.Error.Nonfunctional
       [/xyz/openbmc_project/logging/entry/2]:
         [Timestamp]:                                  1521738334637
-        [Message]:                                    xyz.openbmc_project.Inventory.Error.Nonfunctional
+        [Message]:
+        xyz.openbmc_project.Inventory.Error.Nonfunctional
       [/xyz/openbmc_project/logging/entry/1]:
         [Timestamp]:                                  1521738300696
-        [Message]:                                    xyz.openbmc_project.Inventory.Error.Nonfunctional
+        [Message]:
+        xyz.openbmc_project.Inventory.Error.Nonfunctional
       [/xyz/openbmc_project/logging/entry/4]:
         [Timestamp]:                                  1521738337915
-        [Message]:                                    xyz.openbmc_project.Inventory.Error.Nonfunctional
+        [Message]:
+        xyz.openbmc_project.Inventory.Error.Nonfunctional
 
     Another example call using a robot list:
     ${error_logs}=  Get Error Logs
diff --git a/lib/obmc_boot_test.py b/lib/obmc_boot_test.py
index 8b6040a..97461c1 100755
--- a/lib/obmc_boot_test.py
+++ b/lib/obmc_boot_test.py
@@ -37,7 +37,7 @@
 # DB_Logging
 program_pid = os.getpid()
 master_pid = os.environ.get('AUTOBOOT_MASTER_PID', program_pid)
-pgm_name = re.sub('\.py$', '', os.path.basename(__file__))
+pgm_name = re.sub('\\.py$', '', os.path.basename(__file__))
 
 # Set up boot data structures.
 boot_table = create_boot_table()
@@ -327,8 +327,8 @@
     repo_bin_path = robot_pgm_dir_path.replace("/lib/", "/bin/")
     # If we can't find process_plug_in_packages.py, ssh_pw or
     # validate_plug_ins.py, then we don't have our repo bin in PATH.
-    shell_rc, out_buf = gc.cmd_fnc_u("which process_plug_in_packages.py" +
-                                     " ssh_pw validate_plug_ins.py", quiet=1,
+    shell_rc, out_buf = gc.cmd_fnc_u("which process_plug_in_packages.py"
+                                     + " ssh_pw validate_plug_ins.py", quiet=1,
                                      print_output=0, show_err=0)
     if shell_rc != 0:
         os.environ['PATH'] = repo_bin_path + ":" + os.environ.get('PATH', "")
@@ -421,8 +421,8 @@
     valid_boot_list(boot_list, valid_boot_types)
     valid_boot_list(boot_stack, valid_boot_types)
 
-    selected_PDU_boots = list(set(boot_list + boot_stack) &
-                              set(boot_lists['PDU_reboot']))
+    selected_PDU_boots = list(set(boot_list + boot_stack)
+                              & set(boot_lists['PDU_reboot']))
 
     if len(selected_PDU_boots) > 0 and pdu_host == "":
         error_message = "You have selected the following boots which" +\
@@ -480,12 +480,12 @@
     if transitional_boot_selected and not boot_success:
         prior_boot = next_boot
         boot_candidate = boot_stack.pop()
-        gp.qprint_timen("The prior '" + next_boot + "' was chosen to" +
-                        " transition to a valid state for '" + boot_candidate +
-                        "' which was at the top of the boot_stack.  Since" +
-                        " the '" + next_boot + "' failed, the '" +
-                        boot_candidate + "' has been removed from the stack" +
-                        " to avoid and endless failure loop.")
+        gp.qprint_timen("The prior '" + next_boot + "' was chosen to"
+                        + " transition to a valid state for '" + boot_candidate
+                        + "' which was at the top of the boot_stack.  Since"
+                        + " the '" + next_boot + "' failed, the '"
+                        + boot_candidate + "' has been removed from the stack"
+                        + " to avoid and endless failure loop.")
         if len(boot_stack) == 0:
             return ""
 
@@ -509,10 +509,10 @@
                     if not skip_boot_printed:
                         gp.qprint_var(stack_mode)
                         gp.qprintn()
-                        gp.qprint_timen("Skipping the following boot tests" +
-                                        " which are unnecessary since their" +
-                                        " required end states match the" +
-                                        " current machine state:")
+                        gp.qprint_timen("Skipping the following boot tests"
+                                        + " which are unnecessary since their"
+                                        + " required end states match the"
+                                        + " current machine state:")
                         skip_boot_printed = 1
                     gp.qprint_var(boot_candidate)
                     boot_candidate = ""
@@ -522,16 +522,16 @@
             gp.qprint_dashes()
             return boot_candidate
         if st.compare_states(state, boot_table[boot_candidate]['start']):
-            gp.qprint_timen("The machine state is valid for a '" +
-                            boot_candidate + "' boot test.")
+            gp.qprint_timen("The machine state is valid for a '"
+                            + boot_candidate + "' boot test.")
             gp.qprint_dashes()
             gp.qprint_var(boot_stack)
             gp.qprint_dashes()
             return boot_candidate
         else:
-            gp.qprint_timen("The machine state does not match the required" +
-                            " starting state for a '" + boot_candidate +
-                            "' boot test:")
+            gp.qprint_timen("The machine state does not match the required"
+                            + " starting state for a '" + boot_candidate
+                            + "' boot test:")
             gp.qprint_varx("boot_table[" + boot_candidate + "][start]",
                            boot_table[boot_candidate]['start'], 1)
             boot_stack.append(boot_candidate)
@@ -550,14 +550,14 @@
                 boot_candidates.append(boot_candidate)
 
     if len(boot_candidates) == 0:
-        gp.qprint_timen("The user's boot list contained no boot tests" +
-                        " which are valid for the current machine state.")
+        gp.qprint_timen("The user's boot list contained no boot tests"
+                        + " which are valid for the current machine state.")
         boot_candidate = default_power_on
         if not st.compare_states(state, boot_table[default_power_on]['start']):
             boot_candidate = default_power_off
         boot_candidates.append(boot_candidate)
-        gp.qprint_timen("Using default '" + boot_candidate +
-                        "' boot type to transition to valid state.")
+        gp.qprint_timen("Using default '" + boot_candidate
+                        + "' boot type to transition to valid state.")
 
     gp.dprint_var(boot_candidates)
 
@@ -621,8 +621,7 @@
 
     # Combine the files from plug_in_ffdc_list with the ffdc_file_list passed
     # in.  Eliminate duplicates and sort the list.
-    ffdc_file_list = list(set(ffdc_file_list + plug_in_ffdc_list))
-    ffdc_file_list.sort()
+    ffdc_file_list = sorted(set(ffdc_file_list + plug_in_ffdc_list))
 
     if status_file_path != "":
         ffdc_file_list.insert(0, status_file_path)
@@ -681,10 +680,10 @@
         call_point='ffdc', stop_on_plug_in_failure=0)
 
     AUTOBOOT_FFDC_PREFIX = os.environ['AUTOBOOT_FFDC_PREFIX']
-    status, ffdc_file_list = grk.run_key_u("FFDC  ffdc_prefix=" +
-                                           AUTOBOOT_FFDC_PREFIX +
-                                           "  ffdc_function_list=" +
-                                           ffdc_function_list, ignore=1)
+    status, ffdc_file_list = grk.run_key_u("FFDC  ffdc_prefix="
+                                           + AUTOBOOT_FFDC_PREFIX
+                                           + "  ffdc_function_list="
+                                           + ffdc_function_list, ignore=1)
     if status != 'PASS':
         gp.qprint_error("Call to ffdc failed.\n")
 
@@ -820,12 +819,12 @@
     gp.qprintn()
     if boot_status == "PASS":
         boot_success = 1
-        completion_msg = gp.sprint_timen("BOOT_SUCCESS: \"" + next_boot +
-                                         "\" succeeded.")
+        completion_msg = gp.sprint_timen("BOOT_SUCCESS: \"" + next_boot
+                                         + "\" succeeded.")
     else:
         boot_success = 0
-        completion_msg = gp.sprint_timen("BOOT_FAILED: \"" + next_boot +
-                                         "\" failed.")
+        completion_msg = gp.sprint_timen("BOOT_FAILED: \"" + next_boot
+                                         + "\" failed.")
 
     # Set boot_end_time for use by plug-ins.
     boot_end_time = completion_msg[1:33]
@@ -894,7 +893,7 @@
         # Get the parm_value if it was saved on the stack.
         try:
             parm_value = save_stack.pop(parm_name)
-        except:
+        except BaseException:
             # If it was not saved, no further action is required.
             continue
 
diff --git a/lib/openbmc_ffdc.py b/lib/openbmc_ffdc.py
index 9370847..eaca19f 100644
--- a/lib/openbmc_ffdc.py
+++ b/lib/openbmc_ffdc.py
@@ -50,8 +50,8 @@
         return ffdc_file_list
 
     if state['uptime'] == "":
-        gp.print_error("BMC is not communicating.  Terminating FFDC" +
-                       " collection.\n")
+        gp.print_error("BMC is not communicating.  Terminating FFDC"
+                       + " collection.\n")
         return ffdc_file_list
 
     gp.qprint_timen("Collecting FFDC.")
@@ -69,9 +69,9 @@
     grp.rqpissuing_keyword(cmd_buf)
     status, output = BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
     if status != "PASS":
-        error_message = grp.sprint_error_report("Create Directory failed" +
-                                                " with the following" +
-                                                " error:\n" + output)
+        error_message = grp.sprint_error_report("Create Directory failed"
+                                                + " with the following"
+                                                + " error:\n" + output)
         BuiltIn().fail(error_message)
 
     # FFDC_FILE_PATH is used by Header Message.
@@ -80,12 +80,11 @@
 
     status, ffdc_file_list = grk.run_key("Header Message")
     status, ffdc_file_sub_list = \
-        grk.run_key_u("Call FFDC Methods  ffdc_function_list=" +
-                      ffdc_function_list)
+        grk.run_key_u("Call FFDC Methods  ffdc_function_list="
+                      + ffdc_function_list)
 
     # Combine lists, remove duplicates and sort.
-    ffdc_file_list = list(set(ffdc_file_list + ffdc_file_sub_list))
-    ffdc_file_list.sort()
+    ffdc_file_list = sorted(set(ffdc_file_list + ffdc_file_sub_list))
 
     gp.qprint_timen("Finished collecting FFDC.")
 
diff --git a/lib/openbmc_ffdc_list.py b/lib/openbmc_ffdc_list.py
index b3b031b..ca56263 100755
--- a/lib/openbmc_ffdc_list.py
+++ b/lib/openbmc_ffdc_list.py
@@ -129,7 +129,7 @@
 FFDC_METHOD_CALL = {
     'BMC LOGS':
     {
-        # Description             Keyword name
+        # Description               Keyword name
         'FFDC Generic Report': 'BMC FFDC Manifest',
         'BMC Specific Files': 'BMC FFDC Files',
         'Get Request FFDC': 'BMC FFDC Get Requests',
@@ -148,134 +148,134 @@
 class openbmc_ffdc_list():
     def get_ffdc_bmc_cmd(self, i_type):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the list from the dictionary for cmds
         #   @param    i_type: @type string: string index lookup
         #   @return   List of key pair from the dictionary
-        ########################################################################
+        #######################################################################
         """
         return FFDC_BMC_CMD[i_type].items()
 
     def get_ffdc_bmc_file(self, i_type):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the list from the dictionary for scp
         #   @param    i_type: @type string: string index lookup
         #   @return   List of key pair from the dictionary
-        ########################################################################
+        #######################################################################
         """
         return FFDC_BMC_FILE[i_type].items()
 
     def get_ffdc_get_request(self, i_type):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the list from the dictionary for scp
         #   @param    i_type: @type string: string index lookup
         #   @return   List of key pair from the dictionary
-        ########################################################################
+        #######################################################################
         """
         return FFDC_GET_REQUEST[i_type].items()
 
     def get_ffdc_cmd_index(self):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the list index from dictionary
         #   @return   List of index to the dictionary
-        ########################################################################
+        #######################################################################
         """
         return FFDC_BMC_CMD.keys()
 
     def get_ffdc_get_request_index(self):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the list index from dictionary
         #   @return   List of index to the dictionary
-        ########################################################################
+        #######################################################################
         """
         return FFDC_GET_REQUEST.keys()
 
     def get_ffdc_file_index(self):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the list index from dictionary
         #   @return   List of index to the dictionary
-        ########################################################################
+        #######################################################################
         """
         return FFDC_BMC_FILE.keys()
 
     def get_ffdc_method_index(self):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the key pair from the dictionary
         #   @return   Index of the method dictionary
-        ########################################################################
+        #######################################################################
         """
         return FFDC_METHOD_CALL.keys()
 
     def get_ffdc_method_desc(self,
                              index):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief   This method returns the just the keys from the dictionary.
         #   @return  List of ffdc descriptions.
-        ########################################################################
+        #######################################################################
         """
         return FFDC_METHOD_CALL[index].keys()
 
     def get_ffdc_method_call(self, i_type):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the key pair from the dictionary
         #   @return   List of key pair keywords
-        ########################################################################
+        #######################################################################
         """
         return FFDC_METHOD_CALL[i_type].items()
 
     def get_ffdc_os_all_distros_index(self):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the key pair from the dictionary
         #   @return   Index of the method dictionary
-        ########################################################################
+        #######################################################################
         """
         return FFDC_OS_ALL_DISTROS_FILE.keys()
 
     def get_ffdc_os_all_distros_call(self, i_type):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the key pair from the dictionary
         #   @return   List of key pair keywords
-        ########################################################################
+        #######################################################################
         """
         return FFDC_OS_ALL_DISTROS_FILE[i_type].items()
 
     def get_ffdc_os_distro_index(self, distro):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the key pair from the dictionary
         #   @return   Index of the method dictionary
-        ########################################################################
+        #######################################################################
         """
         distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
         return eval(distro_file).keys()
 
     def get_ffdc_os_distro_call(self, i_type, distro):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    This method returns the key pair from the dictionary
         #   @return   List of key pair keywords
-        ########################################################################
+        #######################################################################
         """
         distro_file = "FFDC_OS_" + str(distro).upper() + "_FILE"
         return eval(distro_file)[i_type].items()
 
     def get_strip_string(self, i_str):
         r"""
-        ########################################################################
+        #######################################################################
         #   @brief    Returns the stripped strings
         #   @param    i_str: @type string: string name
         #   @return   Remove all special chars and return the string
-        ########################################################################
+        #######################################################################
         """
         return ''.join(e for e in i_str if e.isalnum())
 
diff --git a/lib/pythonutil.py b/lib/pythonutil.py
index dd23168..3fd6ffb 100644
--- a/lib/pythonutil.py
+++ b/lib/pythonutil.py
@@ -4,7 +4,7 @@
 
 def calcDottedNetmask(mask):
     bits = 0
-    for i in xrange(32-mask, 32):
+    for i in xrange(32 - mask, 32):
         bits |= (1 << i)
     packed_value = pack('!I', bits)
     addr = inet_ntoa(packed_value)
diff --git a/lib/state.py b/lib/state.py
index cddcf79..d078483 100755
--- a/lib/state.py
+++ b/lib/state.py
@@ -536,8 +536,8 @@
         # wait_until_keyword_succeeds to ensure a non-blank value is obtained.
         remote_cmd_buf = "read uptime filler 2>/dev/null < /proc/uptime" +\
             " && [ ! -z \"${uptime}\" ] && echo ${uptime}"
-        cmd_buf = ["BMC Execute Command", re.sub(r'\$', '\$', remote_cmd_buf),
-                   'quiet=1']
+        cmd_buf = ["BMC Execute Command",
+                   re.sub(r'\\$', '\\$', remote_cmd_buf), 'quiet=1']
         if not quiet:
             grp.rpissuing_keyword(cmd_buf)
             grp.rpissuing(remote_cmd_buf)
@@ -592,7 +592,7 @@
             for url_path in ret_values:
                 for attr_name in ret_values[url_path]:
                     # Create a state key value based on the attr_name.
-                    if type(ret_values[url_path][attr_name]) is unicode:
+                    if isinstance(ret_values[url_path][attr_name], unicode):
                         ret_values[url_path][attr_name] = \
                             re.sub(r'.*\.', "",
                                    ret_values[url_path][attr_name])
@@ -783,9 +783,9 @@
             alt_text = "cease to "
         else:
             alt_text = ""
-        gp.print_timen("Checking every " + str(interval) + " for up to " +
-                       str(wait_time) + " for the state of the machine to " +
-                       alt_text + "match the state shown below.")
+        gp.print_timen("Checking every " + str(interval) + " for up to "
+                       + str(wait_time) + " for the state of the machine to "
+                       + alt_text + "match the state shown below.")
         gp.print_var(match_state)
 
     if quiet:
@@ -864,7 +864,7 @@
     # a reboot has indeed occurred (vs random network instability giving a
     # false positive.  We also use wait_state because the BMC may take a short
     # while to be ready to process SSH requests.
-    match_state = DotDict([('uptime', '^[0-9\.]+$'),
+    match_state = DotDict([('uptime', '^[0-9\\.]+$'),
                            ('epoch_seconds', '^[0-9]+$')])
     state = wait_state(match_state, wait_time="2 mins", interval="1 second")
 
@@ -877,8 +877,8 @@
     if int(float(state['uptime'])) < elapsed_boot_time:
         uptime = state['uptime']
         gp.qprint_var(uptime)
-        gp.qprint_timen("The uptime is less than the elapsed boot time," +
-                        " as expected.")
+        gp.qprint_timen("The uptime is less than the elapsed boot time,"
+                        + " as expected.")
     else:
         error_message = "The uptime is greater than the elapsed boot time," +\
                         " which is unexpected:\n" +\
diff --git a/lib/state_map.py b/lib/state_map.py
index 191de65..a54ea6b 100644
--- a/lib/state_map.py
+++ b/lib/state_map.py
@@ -104,8 +104,8 @@
         BootProgress and OperatingSystemState.
         """
 
-        status, state = keyword.run_key("Read Properties  " +
-                                        var.SYSTEM_STATE_URI + "enumerate")
+        status, state = keyword.run_key("Read Properties  "
+                                        + var.SYSTEM_STATE_URI + "enumerate")
         bmc_state = state[var.SYSTEM_STATE_URI + 'bmc0']['CurrentBMCState']
         chassis_state = \
             state[var.SYSTEM_STATE_URI + 'chassis0']['CurrentPowerState']
@@ -125,9 +125,10 @@
         Validate a given set of states is valid.
 
         Description of argument(s):
-        boot_type   Boot type (e.g. off/running/host booted etc.)
-        state_set   State set
-                    (e.g.bmc,chassis,host,BootProgress,OperatingSystemState)
+        boot_type                   Boot type (e.g. off/running/host booted
+                                    etc.)
+        state_set                   State set (e.g.bmc,chassis,host,
+                                    BootProgress,OperatingSystemState)
         """
 
         if state_set in set(VALID_BOOT_STATES[boot_type]):
diff --git a/lib/tally_sheet.py b/lib/tally_sheet.py
index 7e6c7ed..76a2673 100755
--- a/lib/tally_sheet.py
+++ b/lib/tally_sheet.py
@@ -271,7 +271,7 @@
         first_rec = next(iter(self.__table.items()))
         for row_key, value in first_rec[1].items():
             field_num += 1
-            if type(value) is int:
+            if isinstance(value, int):
                 align = ':>'
             else:
                 align = ':<'
diff --git a/lib/utilities.py b/lib/utilities.py
index 8f23b33..ce8fa3b 100755
--- a/lib/utilities.py
+++ b/lib/utilities.py
@@ -60,15 +60,15 @@
 ################################################################
 def get_inventory_list(module_name):
 
-    l = []
+    inventory_list = []
     m = imp.load_source('module.name', module_name)
 
     for i in m.ID_LOOKUP['FRU']:
         s = m.ID_LOOKUP['FRU'][i]
         s = s.replace('<inventory_root>', m.INVENTORY_ROOT)
-        l.append(s)
+        inventory_list.append(s)
 
-    return l
+    return inventory_list
 
 
 ################################################################
@@ -80,15 +80,15 @@
 #   /org/openbmc/inventory//system/chassis/motherboard/cpu1]
 ################################################################
 def get_inventory_fru_type_list(module_name, fru):
-    l = []
+    inventory_list = []
     m = imp.load_source('module.name', module_name)
 
     for i in m.FRU_INSTANCES.keys():
         if m.FRU_INSTANCES[i]['fru_type'] == fru:
             s = i.replace('<inventory_root>', m.INVENTORY_ROOT)
-            l.append(s)
+            inventory_list.append(s)
 
-    return l
+    return inventory_list
 
 
 ################################################################
@@ -100,7 +100,7 @@
 #   /org/openbmc/inventory/system/chassis/motherboard/dimm1]
 ################################################################
 def get_vpd_inventory_list(module_name, fru):
-    l = []
+    inventory_list = []
     m = imp.load_source('module.name', module_name)
 
     for i in m.ID_LOOKUP['FRU_STR']:
@@ -108,9 +108,9 @@
 
         if m.FRU_INSTANCES[x]['fru_type'] == fru:
             s = x.replace('<inventory_root>', m.INVENTORY_ROOT)
-            l.append(s)
+            inventory_list.append(s)
 
-    return l
+    return inventory_list
 
 
 def call_keyword(keyword):
diff --git a/lib/wrap_utils.py b/lib/wrap_utils.py
index 2f4ee62..5513b07 100755
--- a/lib/wrap_utils.py
+++ b/lib/wrap_utils.py
@@ -85,7 +85,7 @@
     base_arg_default_list = list(base_arg_list)
     for ix in range(num_non_defaults, len(base_arg_default_list)):
         base_default_ix = ix - num_non_defaults
-        if type(base_default_list[base_default_ix]) is str:
+        if isinstance(base_default_list[base_default_ix], str):
             default_string = "'" + base_default_list[base_default_ix] + "'"
             # Convert "\n" to "\\n".
             default_string = default_string.replace("\n", "\\n")
@@ -97,8 +97,8 @@
     # Create the argument string which can be used to call the base function.
     # Example call_arg_string:
     # headers=headers, last=last, first=first
-    call_arg_string = ', '.join([val + "=" + val for val in base_arg_list] +
-                                var_args)
+    call_arg_string = ', '.join([val + "=" + val for val in base_arg_list]
+                                + var_args)
 
     # Compose the result values.
     func_def_line = "def " + wrap_func_name + "(" + base_arg_default_string +\