Revert "black: re-format"

This reverts commit 5731818de0ce446ceaafc7e75ae39da1b69942ae.

Signed-off-by: George Keishing <gkeishin@in.ibm.com>
Change-Id: Ie61cdc8c7f2825b0d9d66be87a6a3a058de2b372
diff --git a/lib/state.py b/lib/state.py
index 00fa124..26c3f79 100755
--- a/lib/state.py
+++ b/lib/state.py
@@ -27,27 +27,27 @@
 compared with the expected state.
 """
 
-import imp
-import os
-import re
-import sys
-
-import bmc_ssh_utils as bsu
-import gen_cmd as gc
 import gen_print as gp
-import gen_robot_utils as gru
 import gen_valid as gv
+import gen_robot_utils as gru
+import gen_cmd as gc
+import bmc_ssh_utils as bsu
+
 from robot.libraries.BuiltIn import BuiltIn
 from robot.utils import DotDict
 
+import re
+import os
+import sys
+import imp
+
+
 # NOTE: Avoid importing utils.robot because utils.robot imports state.py
 # (indirectly) which will cause failures.
 gru.my_import_resource("rest_client.robot")
 
-base_path = (
-    os.path.dirname(os.path.dirname(imp.find_module("gen_robot_print")[1]))
-    + os.sep
-)
+base_path = os.path.dirname(os.path.dirname(
+                            imp.find_module("gen_robot_print")[1])) + os.sep
 sys.path.append(base_path + "data/")
 
 # Previously, I had this coded:
@@ -76,243 +76,192 @@
 # is being removed but the OBMC_STATES_VERSION value will stay for now in the
 # event that it is needed in the future.
 
-OBMC_STATES_VERSION = int(os.environ.get("OBMC_STATES_VERSION", 1))
+OBMC_STATES_VERSION = int(os.environ.get('OBMC_STATES_VERSION', 1))
 
-redfish_support_trans_state = int(
-    os.environ.get("REDFISH_SUPPORT_TRANS_STATE", 0)
-) or int(
-    BuiltIn().get_variable_value("${REDFISH_SUPPORT_TRANS_STATE}", default=0)
-)
+redfish_support_trans_state = int(os.environ.get('REDFISH_SUPPORT_TRANS_STATE', 0)) or \
+    int(BuiltIn().get_variable_value("${REDFISH_SUPPORT_TRANS_STATE}", default=0))
 
-platform_arch_type = os.environ.get(
-    "PLATFORM_ARCH_TYPE", ""
-) or BuiltIn().get_variable_value("${PLATFORM_ARCH_TYPE}", default="power")
+platform_arch_type = os.environ.get('PLATFORM_ARCH_TYPE', '') or \
+    BuiltIn().get_variable_value("${PLATFORM_ARCH_TYPE}", default="power")
 
 # valid_os_req_states and default_os_req_states are used by the os_get_state
 # function.
 # valid_os_req_states is a list of state information supported by the
 # get_os_state function.
-valid_os_req_states = ["os_ping", "os_login", "os_run_cmd"]
+valid_os_req_states = ['os_ping',
+                       'os_login',
+                       'os_run_cmd']
 
 # When a user calls get_os_state w/o specifying req_states,
 # default_os_req_states is used as its value.
-default_os_req_states = ["os_ping", "os_login", "os_run_cmd"]
+default_os_req_states = ['os_ping',
+                         'os_login',
+                         'os_run_cmd']
 
 # Presently, some BMCs appear to not keep time very well.  This environment
 # variable directs the get_state function to use either the BMC's epoch time
 # or the local epoch time.
-USE_BMC_EPOCH_TIME = int(os.environ.get("USE_BMC_EPOCH_TIME", 0))
+USE_BMC_EPOCH_TIME = int(os.environ.get('USE_BMC_EPOCH_TIME', 0))
 
 # Useful state constant definition(s).
 if not redfish_support_trans_state:
     # When a user calls get_state w/o specifying req_states, default_req_states
     # is used as its value.
-    default_req_states = [
-        "rest",
-        "chassis",
-        "bmc",
-        "boot_progress",
-        "operating_system",
-        "host",
-        "os_ping",
-        "os_login",
-        "os_run_cmd",
-    ]
+    default_req_states = ['rest',
+                          'chassis',
+                          'bmc',
+                          'boot_progress',
+                          'operating_system',
+                          'host',
+                          'os_ping',
+                          'os_login',
+                          'os_run_cmd']
 
     # valid_req_states is a list of sub states supported by the get_state function.
     # valid_req_states, default_req_states and master_os_up_match are used by the
     # get_state function.
 
-    valid_req_states = [
-        "ping",
-        "packet_loss",
-        "uptime",
-        "epoch_seconds",
-        "elapsed_boot_time",
-        "rest",
-        "chassis",
-        "requested_chassis",
-        "bmc",
-        "requested_bmc",
-        "boot_progress",
-        "operating_system",
-        "host",
-        "requested_host",
-        "attempts_left",
-        "os_ping",
-        "os_login",
-        "os_run_cmd",
-    ]
+    valid_req_states = ['ping',
+                        'packet_loss',
+                        'uptime',
+                        'epoch_seconds',
+                        'elapsed_boot_time',
+                        'rest',
+                        'chassis',
+                        'requested_chassis',
+                        'bmc',
+                        'requested_bmc',
+                        'boot_progress',
+                        'operating_system',
+                        'host',
+                        'requested_host',
+                        'attempts_left',
+                        'os_ping',
+                        'os_login',
+                        'os_run_cmd']
 
     # default_state is an initial value which may be of use to callers.
-    default_state = DotDict(
-        [
-            ("rest", "1"),
-            ("chassis", "On"),
-            ("bmc", "Ready"),
-            ("boot_progress", "OSStart"),
-            ("operating_system", "BootComplete"),
-            ("host", "Running"),
-            ("os_ping", "1"),
-            ("os_login", "1"),
-            ("os_run_cmd", "1"),
-        ]
-    )
+    default_state = DotDict([('rest', '1'),
+                             ('chassis', 'On'),
+                             ('bmc', 'Ready'),
+                             ('boot_progress', 'OSStart'),
+                             ('operating_system', 'BootComplete'),
+                             ('host', 'Running'),
+                             ('os_ping', '1'),
+                             ('os_login', '1'),
+                             ('os_run_cmd', '1')])
 
     # A match state for checking that the system is at "standby".
-    standby_match_state = DotDict(
-        [
-            ("rest", "^1$"),
-            ("chassis", "^Off$"),
-            ("bmc", "^Ready$"),
-            ("boot_progress", "^Off|Unspecified$"),
-            ("operating_system", "^Inactive$"),
-            ("host", "^Off$"),
-        ]
-    )
+    standby_match_state = DotDict([('rest', '^1$'),
+                                   ('chassis', '^Off$'),
+                                   ('bmc', '^Ready$'),
+                                   ('boot_progress', '^Off|Unspecified$'),
+                                   ('operating_system', '^Inactive$'),
+                                   ('host', '^Off$')])
 
     # A match state for checking that the system is at "os running".
-    os_running_match_state = DotDict(
-        [
-            ("chassis", "^On$"),
-            ("bmc", "^Ready$"),
-            ("boot_progress", "FW Progress, Starting OS|OSStart"),
-            ("operating_system", "BootComplete"),
-            ("host", "^Running$"),
-            ("os_ping", "^1$"),
-            ("os_login", "^1$"),
-            ("os_run_cmd", "^1$"),
-        ]
-    )
+    os_running_match_state = DotDict([('chassis', '^On$'),
+                                      ('bmc', '^Ready$'),
+                                      ('boot_progress',
+                                       'FW Progress, Starting OS|OSStart'),
+                                      ('operating_system', 'BootComplete'),
+                                      ('host', '^Running$'),
+                                      ('os_ping', '^1$'),
+                                      ('os_login', '^1$'),
+                                      ('os_run_cmd', '^1$')])
 
     # A master dictionary to determine whether the os may be up.
-    master_os_up_match = DotDict(
-        [
-            ("chassis", "^On$"),
-            ("bmc", "^Ready$"),
-            ("boot_progress", "FW Progress, Starting OS|OSStart"),
-            ("operating_system", "BootComplete"),
-            ("host", "^Running|Quiesced$"),
-        ]
-    )
+    master_os_up_match = DotDict([('chassis', '^On$'),
+                                  ('bmc', '^Ready$'),
+                                  ('boot_progress',
+                                   'FW Progress, Starting OS|OSStart'),
+                                  ('operating_system', 'BootComplete'),
+                                  ('host', '^Running|Quiesced$')])
 
-    invalid_state_match = DotDict(
-        [
-            ("rest", "^$"),
-            ("chassis", "^$"),
-            ("bmc", "^$"),
-            ("boot_progress", "^$"),
-            ("operating_system", "^$"),
-            ("host", "^$"),
-        ]
-    )
+    invalid_state_match = DotDict([('rest', '^$'),
+                                   ('chassis', '^$'),
+                                   ('bmc', '^$'),
+                                   ('boot_progress', '^$'),
+                                   ('operating_system', '^$'),
+                                   ('host', '^$')])
 else:
     # When a user calls get_state w/o specifying req_states, default_req_states
     # is used as its value.
-    default_req_states = [
-        "redfish",
-        "chassis",
-        "bmc",
-        "boot_progress",
-        "host",
-        "os_ping",
-        "os_login",
-        "os_run_cmd",
-    ]
+    default_req_states = ['redfish',
+                          'chassis',
+                          'bmc',
+                          'boot_progress',
+                          'host',
+                          'os_ping',
+                          'os_login',
+                          'os_run_cmd']
 
     # valid_req_states is a list of sub states supported by the get_state function.
     # valid_req_states, default_req_states and master_os_up_match are used by the
     # get_state function.
 
-    valid_req_states = [
-        "ping",
-        "packet_loss",
-        "uptime",
-        "epoch_seconds",
-        "elapsed_boot_time",
-        "redfish",
-        "chassis",
-        "requested_chassis",
-        "bmc",
-        "requested_bmc",
-        "boot_progress",
-        "host",
-        "requested_host",
-        "attempts_left",
-        "os_ping",
-        "os_login",
-        "os_run_cmd",
-    ]
+    valid_req_states = ['ping',
+                        'packet_loss',
+                        'uptime',
+                        'epoch_seconds',
+                        'elapsed_boot_time',
+                        'redfish',
+                        'chassis',
+                        'requested_chassis',
+                        'bmc',
+                        'requested_bmc',
+                        'boot_progress',
+                        'host',
+                        'requested_host',
+                        'attempts_left',
+                        'os_ping',
+                        'os_login',
+                        'os_run_cmd']
 
     # default_state is an initial value which may be of use to callers.
-    default_state = DotDict(
-        [
-            ("redfish", "1"),
-            ("chassis", "On"),
-            ("bmc", "Enabled"),
-            (
-                "boot_progress",
-                "SystemHardwareInitializationComplete|OSBootStarted|OSRunning",
-            ),
-            ("host", "Enabled"),
-            ("os_ping", "1"),
-            ("os_login", "1"),
-            ("os_run_cmd", "1"),
-        ]
-    )
+    default_state = DotDict([('redfish', '1'),
+                             ('chassis', 'On'),
+                             ('bmc', 'Enabled'),
+                             ('boot_progress',
+                              'SystemHardwareInitializationComplete|OSBootStarted|OSRunning'),
+                             ('host', 'Enabled'),
+                             ('os_ping', '1'),
+                             ('os_login', '1'),
+                             ('os_run_cmd', '1')])
 
     # A match state for checking that the system is at "standby".
-    standby_match_state = DotDict(
-        [
-            ("redfish", "^1$"),
-            ("chassis", "^Off$"),
-            ("bmc", "^Enabled$"),
-            ("boot_progress", "^None$"),
-            ("host", "^Disabled$"),
-        ]
-    )
+    standby_match_state = DotDict([('redfish', '^1$'),
+                                   ('chassis', '^Off$'),
+                                   ('bmc', '^Enabled$'),
+                                   ('boot_progress', '^None$'),
+                                   ('host', '^Disabled$')])
 
     # A match state for checking that the system is at "os running".
-    os_running_match_state = DotDict(
-        [
-            ("chassis", "^On$"),
-            ("bmc", "^Enabled$"),
-            (
-                "boot_progress",
-                "SystemHardwareInitializationComplete|OSBootStarted|OSRunning",
-            ),
-            ("host", "^Enabled$"),
-            ("os_ping", "^1$"),
-            ("os_login", "^1$"),
-            ("os_run_cmd", "^1$"),
-        ]
-    )
+    os_running_match_state = DotDict([('chassis', '^On$'),
+                                      ('bmc', '^Enabled$'),
+                                      ('boot_progress',
+                                       'SystemHardwareInitializationComplete|OSBootStarted|OSRunning'),
+                                      ('host', '^Enabled$'),
+                                      ('os_ping', '^1$'),
+                                      ('os_login', '^1$'),
+                                      ('os_run_cmd', '^1$')])
 
     # A master dictionary to determine whether the os may be up.
-    master_os_up_match = DotDict(
-        [
-            ("chassis", "^On$"),
-            ("bmc", "^Enabled$"),
-            (
-                "boot_progress",
-                "SystemHardwareInitializationComplete|OSBootStarted|OSRunning",
-            ),
-            ("host", "^Enabled$"),
-        ]
-    )
+    master_os_up_match = DotDict([('chassis', '^On$'),
+                                  ('bmc', '^Enabled$'),
+                                  ('boot_progress',
+                                   'SystemHardwareInitializationComplete|OSBootStarted|OSRunning'),
+                                  ('host', '^Enabled$')])
 
-    invalid_state_match = DotDict(
-        [
-            ("redfish", "^$"),
-            ("chassis", "^$"),
-            ("bmc", "^$"),
-            ("boot_progress", "^$"),
-            ("host", "^$"),
-        ]
-    )
+    invalid_state_match = DotDict([('redfish', '^$'),
+                                   ('chassis', '^$'),
+                                   ('bmc', '^$'),
+                                   ('boot_progress', '^$'),
+                                   ('host', '^$')])
 
 # Filter the states based on platform type.
 if platform_arch_type == "x86":
+
     if not redfish_support_trans_state:
         default_req_states.remove("operating_system")
         valid_req_states.remove("operating_system")
@@ -331,7 +280,7 @@
     del invalid_state_match["boot_progress"]
 
 
-def return_state_constant(state_name="default_state"):
+def return_state_constant(state_name='default_state'):
     r"""
     Return the named state dictionary constant.
     """
@@ -379,10 +328,12 @@
     r"""
     Return expressions key constant.
     """
-    return "<expressions>"
+    return '<expressions>'
 
 
-def compare_states(state, match_state, match_type="and"):
+def compare_states(state,
+                   match_state,
+                   match_type='and'):
     r"""
     Compare 2 state dictionaries.  Return True if they match and False if they
     don't.  Note that the match_state dictionary does not need to have an entry
@@ -422,7 +373,7 @@
     match_type      This may be 'and' or 'or'.
     """
 
-    error_message = gv.valid_value(match_type, valid_values=["and", "or"])
+    error_message = gv.valid_value(match_type, valid_values=['and', 'or'])
     if error_message != "":
         BuiltIn().fail(gp.sprint_error(error_message))
 
@@ -431,7 +382,7 @@
     except TypeError:
         pass
 
-    default_match = match_type == "and"
+    default_match = (match_type == 'and')
     for key, match_state_value in match_state.items():
         # Blank match_state_value means "don't care".
         if match_state_value == "":
@@ -444,9 +395,7 @@
                     return match
         else:
             try:
-                match = (
-                    re.match(match_state_value, str(state[key])) is not None
-                )
+                match = (re.match(match_state_value, str(state[key])) is not None)
             except KeyError:
                 match = False
             if match != default_match:
@@ -455,14 +404,12 @@
     return default_match
 
 
-def get_os_state(
-    os_host="",
-    os_username="",
-    os_password="",
-    req_states=default_os_req_states,
-    os_up=True,
-    quiet=None,
-):
+def get_os_state(os_host="",
+                 os_username="",
+                 os_password="",
+                 req_states=default_os_req_states,
+                 os_up=True,
+                 quiet=None):
     r"""
     Get component states for the operating system such as ping, login,
     etc, put them into a dictionary and return them to the caller.
@@ -508,16 +455,11 @@
     if error_message != "":
         BuiltIn().fail(gp.sprint_error(error_message))
 
-    invalid_req_states = [
-        sub_state
-        for sub_state in req_states
-        if sub_state not in valid_os_req_states
-    ]
+    invalid_req_states = [sub_state for sub_state in req_states
+                          if sub_state not in valid_os_req_states]
     if len(invalid_req_states) > 0:
-        error_message = (
-            "The following req_states are not supported:\n"
-            + gp.sprint_var(invalid_req_states)
-        )
+        error_message = "The following req_states are not supported:\n" +\
+            gp.sprint_var(invalid_req_states)
         BuiltIn().fail(gp.sprint_error(error_message))
 
     # Initialize all substate values supported by this function.
@@ -526,37 +468,28 @@
     os_run_cmd = 0
 
     if os_up:
-        if "os_ping" in req_states:
+        if 'os_ping' in req_states:
             # See if the OS pings.
-            rc, out_buf = gc.shell_cmd(
-                "ping -c 1 -w 2 " + os_host,
-                print_output=0,
-                show_err=0,
-                ignore_err=1,
-            )
+            rc, out_buf = gc.shell_cmd("ping -c 1 -w 2 " + os_host,
+                                       print_output=0, show_err=0,
+                                       ignore_err=1)
             if rc == 0:
                 os_ping = 1
 
         # Programming note: All attributes which do not require an ssh login
         # should have been processed by this point.
-        master_req_login = ["os_login", "os_run_cmd"]
-        req_login = [
-            sub_state
-            for sub_state in req_states
-            if sub_state in master_req_login
-        ]
-        must_login = len(req_login) > 0
+        master_req_login = ['os_login', 'os_run_cmd']
+        req_login = [sub_state for sub_state in req_states if sub_state in
+                     master_req_login]
+        must_login = (len(req_login) > 0)
 
         if must_login:
-            output, stderr, rc = bsu.os_execute_command(
-                "uptime",
-                quiet=quiet,
-                ignore_err=1,
-                time_out=20,
-                os_host=os_host,
-                os_username=os_username,
-                os_password=os_password,
-            )
+            output, stderr, rc = bsu.os_execute_command("uptime", quiet=quiet,
+                                                        ignore_err=1,
+                                                        time_out=20,
+                                                        os_host=os_host,
+                                                        os_username=os_username,
+                                                        os_password=os_password)
             if rc == 0:
                 os_login = 1
                 os_run_cmd = 1
@@ -572,16 +505,14 @@
     return os_state
 
 
-def get_state(
-    openbmc_host="",
-    openbmc_username="",
-    openbmc_password="",
-    os_host="",
-    os_username="",
-    os_password="",
-    req_states=default_req_states,
-    quiet=None,
-):
+def get_state(openbmc_host="",
+              openbmc_username="",
+              openbmc_password="",
+              os_host="",
+              os_username="",
+              os_password="",
+              req_states=default_req_states,
+              quiet=None):
     r"""
     Get component states such as chassis state, bmc state, etc, put them into a
     dictionary and return them to the caller.
@@ -650,149 +581,116 @@
         if os_password is None:
             os_password = ""
 
-    invalid_req_states = [
-        sub_state
-        for sub_state in req_states
-        if sub_state not in valid_req_states
-    ]
+    invalid_req_states = [sub_state for sub_state in req_states
+                          if sub_state not in valid_req_states]
     if len(invalid_req_states) > 0:
-        error_message = (
-            "The following req_states are not supported:\n"
-            + gp.sprint_var(invalid_req_states)
-        )
+        error_message = "The following req_states are not supported:\n" +\
+            gp.sprint_var(invalid_req_states)
         BuiltIn().fail(gp.sprint_error(error_message))
 
     # Initialize all substate values supported by this function.
     ping = 0
-    packet_loss = ""
-    uptime = ""
-    epoch_seconds = ""
-    elapsed_boot_time = ""
-    rest = ""
-    redfish = ""
-    chassis = ""
-    requested_chassis = ""
-    bmc = ""
-    requested_bmc = ""
+    packet_loss = ''
+    uptime = ''
+    epoch_seconds = ''
+    elapsed_boot_time = ''
+    rest = ''
+    redfish = ''
+    chassis = ''
+    requested_chassis = ''
+    bmc = ''
+    requested_bmc = ''
     # BootProgress state will get populated when state logic enumerates the
     # state URI. This is to prevent state dictionary  boot_progress value
     # getting empty when the BootProgress is NOT found, making it optional.
-    boot_progress = "NA"
-    operating_system = ""
-    host = ""
-    requested_host = ""
-    attempts_left = ""
+    boot_progress = 'NA'
+    operating_system = ''
+    host = ''
+    requested_host = ''
+    attempts_left = ''
 
     # Get the component states.
-    if "ping" in req_states:
+    if 'ping' in req_states:
         # See if the OS pings.
-        rc, out_buf = gc.shell_cmd(
-            "ping -c 1 -w 2 " + openbmc_host,
-            print_output=0,
-            show_err=0,
-            ignore_err=1,
-        )
+        rc, out_buf = gc.shell_cmd("ping -c 1 -w 2 " + openbmc_host,
+                                   print_output=0, show_err=0,
+                                   ignore_err=1)
         if rc == 0:
             ping = 1
 
-    if "packet_loss" in req_states:
+    if 'packet_loss' in req_states:
         # See if the OS pings.
-        cmd_buf = (
-            "ping -c 5 -w 5 "
-            + openbmc_host
-            + " | egrep 'packet loss' | sed -re 's/.* ([0-9]+)%.*/\\1/g'"
-        )
-        rc, out_buf = gc.shell_cmd(
-            cmd_buf, print_output=0, show_err=0, ignore_err=1
-        )
+        cmd_buf = "ping -c 5 -w 5 " + openbmc_host +\
+            " | egrep 'packet loss' | sed -re 's/.* ([0-9]+)%.*/\\1/g'"
+        rc, out_buf = gc.shell_cmd(cmd_buf,
+                                   print_output=0, show_err=0,
+                                   ignore_err=1)
         if rc == 0:
             packet_loss = out_buf.rstrip("\n")
 
-    if "uptime" in req_states:
+    if 'uptime' in req_states:
         # Sometimes reading uptime results in a blank value. Call with
         # wait_until_keyword_succeeds to ensure a non-blank value is obtained.
-        remote_cmd_buf = (
-            "bash -c 'read uptime filler 2>/dev/null < /proc/uptime"
-            + ' && [ ! -z "${uptime}" ] && echo ${uptime}\''
-        )
-        cmd_buf = [
-            "BMC Execute Command",
-            re.sub("\\$", "\\$", remote_cmd_buf),
-            "quiet=1",
-            "test_mode=0",
-            "time_out=5",
-        ]
+        remote_cmd_buf = "bash -c 'read uptime filler 2>/dev/null < /proc/uptime" +\
+            " && [ ! -z \"${uptime}\" ] && echo ${uptime}'"
+        cmd_buf = ["BMC Execute Command",
+                   re.sub('\\$', '\\$', remote_cmd_buf), 'quiet=1',
+                   'test_mode=0', 'time_out=5']
         gp.qprint_issuing(cmd_buf, 0)
         gp.qprint_issuing(remote_cmd_buf, 0)
         try:
-            stdout, stderr, rc = BuiltIn().wait_until_keyword_succeeds(
-                "10 sec", "5 sec", *cmd_buf
-            )
+            stdout, stderr, rc =\
+                BuiltIn().wait_until_keyword_succeeds("10 sec", "5 sec",
+                                                      *cmd_buf)
             if rc == 0 and stderr == "":
                 uptime = stdout
         except AssertionError as my_assertion_error:
             pass
 
-    if "epoch_seconds" in req_states or "elapsed_boot_time" in req_states:
+    if 'epoch_seconds' in req_states or 'elapsed_boot_time' in req_states:
         date_cmd_buf = "date -u +%s"
         if USE_BMC_EPOCH_TIME:
-            cmd_buf = ["BMC Execute Command", date_cmd_buf, "quiet=${1}"]
+            cmd_buf = ["BMC Execute Command", date_cmd_buf, 'quiet=${1}']
             if not quiet:
                 gp.print_issuing(cmd_buf)
-            status, ret_values = BuiltIn().run_keyword_and_ignore_error(
-                *cmd_buf
-            )
+            status, ret_values = \
+                BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
             if status == "PASS":
                 stdout, stderr, rc = ret_values
                 if rc == 0 and stderr == "":
                     epoch_seconds = stdout.rstrip("\n")
         else:
-            shell_rc, out_buf = gc.cmd_fnc_u(
-                date_cmd_buf, quiet=quiet, print_output=0
-            )
+            shell_rc, out_buf = gc.cmd_fnc_u(date_cmd_buf,
+                                             quiet=quiet,
+                                             print_output=0)
             if shell_rc == 0:
                 epoch_seconds = out_buf.rstrip("\n")
 
-    if "elapsed_boot_time" in req_states:
+    if 'elapsed_boot_time' in req_states:
         global start_boot_seconds
         elapsed_boot_time = int(epoch_seconds) - start_boot_seconds
 
     if not redfish_support_trans_state:
-        master_req_rest = [
-            "rest",
-            "host",
-            "requested_host",
-            "operating_system",
-            "attempts_left",
-            "boot_progress",
-            "chassis",
-            "requested_chassisbmcrequested_bmc",
-        ]
+        master_req_rest = ['rest', 'host', 'requested_host', 'operating_system',
+                           'attempts_left', 'boot_progress', 'chassis',
+                           'requested_chassis' 'bmc' 'requested_bmc']
 
-        req_rest = [
-            sub_state
-            for sub_state in req_states
-            if sub_state in master_req_rest
-        ]
-        need_rest = len(req_rest) > 0
+        req_rest = [sub_state for sub_state in req_states if sub_state in
+                    master_req_rest]
+        need_rest = (len(req_rest) > 0)
         state = DotDict()
         if need_rest:
-            cmd_buf = [
-                "Read Properties",
-                SYSTEM_STATE_URI + "enumerate",
-                "quiet=${" + str(quiet) + "}",
-                "timeout=30",
-            ]
+            cmd_buf = ["Read Properties", SYSTEM_STATE_URI + "enumerate",
+                       "quiet=${" + str(quiet) + "}", "timeout=30"]
             gp.dprint_issuing(cmd_buf)
-            status, ret_values = BuiltIn().run_keyword_and_ignore_error(
-                *cmd_buf
-            )
+            status, ret_values = \
+                BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
             if status == "PASS":
-                state["rest"] = "1"
+                state['rest'] = '1'
             else:
-                state["rest"] = "0"
+                state['rest'] = '0'
 
-            if int(state["rest"]):
+            if int(state['rest']):
                 for url_path in ret_values:
                     # Skip conflicting "CurrentHostState" URL from the enum
                     # /xyz/openbmc_project/state/hypervisor0
@@ -808,69 +706,54 @@
                     for attr_name in ret_values[url_path]:
                         # Create a state key value based on the attr_name.
                         try:
-                            ret_values[url_path][attr_name] = re.sub(
-                                r".*\.", "", ret_values[url_path][attr_name]
-                            )
+                            ret_values[url_path][attr_name] = \
+                                re.sub(r'.*\.', "",
+                                       ret_values[url_path][attr_name])
                         except TypeError:
                             pass
                         # Do some key name manipulations.
-                        new_attr_name = re.sub(
-                            r"^Current|(State|Transition)$", "", attr_name
-                        )
-                        new_attr_name = re.sub(r"BMC", r"Bmc", new_attr_name)
-                        new_attr_name = re.sub(
-                            r"([A-Z][a-z])", r"_\1", new_attr_name
-                        )
+                        new_attr_name = re.sub(r'^Current|(State|Transition)$',
+                                               "", attr_name)
+                        new_attr_name = re.sub(r'BMC', r'Bmc', new_attr_name)
+                        new_attr_name = re.sub(r'([A-Z][a-z])', r'_\1',
+                                               new_attr_name)
                         new_attr_name = new_attr_name.lower().lstrip("_")
-                        new_attr_name = re.sub(
-                            r"power", r"chassis", new_attr_name
-                        )
+                        new_attr_name = re.sub(r'power', r'chassis', new_attr_name)
                         if new_attr_name in req_states:
-                            state[new_attr_name] = ret_values[url_path][
-                                attr_name
-                            ]
+                            state[new_attr_name] = ret_values[url_path][attr_name]
     else:
-        master_req_rf = [
-            "redfish",
-            "host",
-            "requested_host",
-            "attempts_left",
-            "boot_progress",
-            "chassis",
-            "requested_chassisbmcrequested_bmc",
-        ]
+        master_req_rf = ['redfish', 'host', 'requested_host',
+                         'attempts_left', 'boot_progress', 'chassis',
+                         'requested_chassis' 'bmc' 'requested_bmc']
 
-        req_rf = [
-            sub_state for sub_state in req_states if sub_state in master_req_rf
-        ]
-        need_rf = len(req_rf) > 0
+        req_rf = [sub_state for sub_state in req_states if sub_state in
+                  master_req_rf]
+        need_rf = (len(req_rf) > 0)
         state = DotDict()
         if need_rf:
             cmd_buf = ["Redfish Get States"]
             gp.dprint_issuing(cmd_buf)
             try:
-                status, ret_values = BuiltIn().run_keyword_and_ignore_error(
-                    *cmd_buf
-                )
+                status, ret_values = \
+                    BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
             except Exception as ex:
                 # Robot raised UserKeywordExecutionFailed error exception.
                 gp.dprint_issuing("Retrying Redfish Get States")
-                status, ret_values = BuiltIn().run_keyword_and_ignore_error(
-                    *cmd_buf
-                )
+                status, ret_values = \
+                    BuiltIn().run_keyword_and_ignore_error(*cmd_buf)
 
             gp.dprint_vars(status, ret_values)
             if status == "PASS":
-                state["redfish"] = "1"
+                state['redfish'] = '1'
             else:
-                state["redfish"] = "0"
+                state['redfish'] = '0'
 
-            if int(state["redfish"]):
-                state["chassis"] = ret_values["chassis"]
-                state["host"] = ret_values["host"]
-                state["bmc"] = ret_values["bmc"]
+            if int(state['redfish']):
+                state['chassis'] = ret_values['chassis']
+                state['host'] = ret_values['host']
+                state['bmc'] = ret_values['bmc']
                 if platform_arch_type != "x86":
-                    state["boot_progress"] = ret_values["boot_progress"]
+                    state['boot_progress'] = ret_values['boot_progress']
 
     for sub_state in req_states:
         if sub_state in state:
@@ -886,9 +769,8 @@
         # it doesn't exist.
         return state
 
-    os_req_states = [
-        sub_state for sub_state in req_states if sub_state.startswith("os_")
-    ]
+    os_req_states = [sub_state for sub_state in req_states
+                     if sub_state.startswith('os_')]
 
     if len(os_req_states) > 0:
         # The caller has specified an os_host and they have requested
@@ -902,14 +784,12 @@
             if sub_state in req_states:
                 os_up_match[sub_state] = master_os_up_match[sub_state]
         os_up = compare_states(state, os_up_match)
-        os_state = get_os_state(
-            os_host=os_host,
-            os_username=os_username,
-            os_password=os_password,
-            req_states=os_req_states,
-            os_up=os_up,
-            quiet=quiet,
-        )
+        os_state = get_os_state(os_host=os_host,
+                                os_username=os_username,
+                                os_password=os_password,
+                                req_states=os_req_states,
+                                os_up=os_up,
+                                quiet=quiet)
         # Append os_state dictionary to ours.
         state.update(os_state)
 
@@ -935,18 +815,16 @@
     exit_wait_early_message = value
 
 
-def check_state(
-    match_state,
-    invert=0,
-    print_string="",
-    openbmc_host="",
-    openbmc_username="",
-    openbmc_password="",
-    os_host="",
-    os_username="",
-    os_password="",
-    quiet=None,
-):
+def check_state(match_state,
+                invert=0,
+                print_string="",
+                openbmc_host="",
+                openbmc_username="",
+                openbmc_password="",
+                os_host="",
+                os_username="",
+                os_password="",
+                quiet=None):
     r"""
     Check that the Open BMC machine's composite state matches the specified
     state.  On success, this keyword returns the machine's composite state as a
@@ -995,16 +873,14 @@
     if expressions_key() in req_states:
         req_states.remove(expressions_key())
     # Initialize state.
-    state = get_state(
-        openbmc_host=openbmc_host,
-        openbmc_username=openbmc_username,
-        openbmc_password=openbmc_password,
-        os_host=os_host,
-        os_username=os_username,
-        os_password=os_password,
-        req_states=req_states,
-        quiet=quiet,
-    )
+    state = get_state(openbmc_host=openbmc_host,
+                      openbmc_username=openbmc_username,
+                      openbmc_password=openbmc_password,
+                      os_host=os_host,
+                      os_username=os_username,
+                      os_password=os_password,
+                      req_states=req_states,
+                      quiet=quiet)
     if not quiet:
         gp.print_var(state)
 
@@ -1018,36 +894,29 @@
     match = compare_states(state, match_state)
 
     if invert and match:
-        fail_msg = (
-            "The current state of the machine matches the match"
-            + " state:\n"
-            + gp.sprint_varx("state", state)
-        )
+        fail_msg = "The current state of the machine matches the match" +\
+                   " state:\n" + gp.sprint_varx("state", state)
         BuiltIn().fail("\n" + gp.sprint_error(fail_msg))
     elif not invert and not match:
-        fail_msg = (
-            "The current state of the machine does NOT match the"
-            + " match state:\n"
-            + gp.sprint_varx("state", state)
-        )
+        fail_msg = "The current state of the machine does NOT match the" +\
+                   " match state:\n" +\
+                   gp.sprint_varx("state", state)
         BuiltIn().fail("\n" + gp.sprint_error(fail_msg))
 
     return state
 
 
-def wait_state(
-    match_state=(),
-    wait_time="1 min",
-    interval="1 second",
-    invert=0,
-    openbmc_host="",
-    openbmc_username="",
-    openbmc_password="",
-    os_host="",
-    os_username="",
-    os_password="",
-    quiet=None,
-):
+def wait_state(match_state=(),
+               wait_time="1 min",
+               interval="1 second",
+               invert=0,
+               openbmc_host="",
+               openbmc_username="",
+               openbmc_password="",
+               os_host="",
+               os_username="",
+               os_password="",
+               quiet=None):
     r"""
     Wait for the Open BMC machine's composite state to match the specified
     state.  On success, this keyword returns the machine's composite state as
@@ -1098,15 +967,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:
@@ -1119,24 +982,16 @@
         # In debug we print state so no need to print the "#".
         print_string = ""
     check_state_quiet = 1 - debug
-    cmd_buf = [
-        "Check State",
-        match_state,
-        "invert=${" + str(invert) + "}",
-        "print_string=" + print_string,
-        "openbmc_host=" + openbmc_host,
-        "openbmc_username=" + openbmc_username,
-        "openbmc_password=" + openbmc_password,
-        "os_host=" + os_host,
-        "os_username=" + os_username,
-        "os_password=" + os_password,
-        "quiet=${" + str(check_state_quiet) + "}",
-    ]
+    cmd_buf = ["Check State", match_state, "invert=${" + str(invert) + "}",
+               "print_string=" + print_string, "openbmc_host=" + openbmc_host,
+               "openbmc_username=" + openbmc_username,
+               "openbmc_password=" + openbmc_password, "os_host=" + os_host,
+               "os_username=" + os_username, "os_password=" + os_password,
+               "quiet=${" + str(check_state_quiet) + "}"]
     gp.dprint_issuing(cmd_buf)
     try:
-        state = BuiltIn().wait_until_keyword_succeeds(
-            wait_time, interval, *cmd_buf
-        )
+        state = BuiltIn().wait_until_keyword_succeeds(wait_time, interval,
+                                                      *cmd_buf)
     except AssertionError as my_assertion_error:
         gp.printn()
         message = my_assertion_error.args[0]
@@ -1169,7 +1024,8 @@
 set_start_boot_seconds(0)
 
 
-def wait_for_comm_cycle(start_boot_seconds, quiet=None):
+def wait_for_comm_cycle(start_boot_seconds,
+                        quiet=None):
     r"""
     Wait for the BMC uptime to be less than elapsed_boot_time.
 
@@ -1199,19 +1055,15 @@
 
     # Wait for uptime to be less than elapsed_boot_time.
     set_start_boot_seconds(start_boot_seconds)
-    expr = "int(float(state['uptime'])) < int(state['elapsed_boot_time'])"
-    match_state = DotDict(
-        [
-            ("uptime", "^[0-9\\.]+$"),
-            ("elapsed_boot_time", "^[0-9]+$"),
-            (expressions_key(), [expr]),
-        ]
-    )
+    expr = 'int(float(state[\'uptime\'])) < int(state[\'elapsed_boot_time\'])'
+    match_state = DotDict([('uptime', '^[0-9\\.]+$'),
+                           ('elapsed_boot_time', '^[0-9]+$'),
+                           (expressions_key(), [expr])])
     wait_state(match_state, wait_time="12 mins", interval="5 seconds")
 
     gp.qprint_timen("Verifying that REST/Redfish API interface is working.")
     if not redfish_support_trans_state:
-        match_state = DotDict([("rest", "^1$")])
+        match_state = DotDict([('rest', '^1$')])
     else:
-        match_state = DotDict([("redfish", "^1$")])
+        match_state = DotDict([('redfish', '^1$')])
     state = wait_state(match_state, wait_time="5 mins", interval="2 seconds")