pep8 fixes

Also ignore the configs/ directory since it only contains
system configuration files named <system>.py.

Change-Id: I0416239c4030ce5bc39473e65e560016cd4ffc75
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/pychassisctl/chassis_control.py b/pychassisctl/chassis_control.py
index 16fb554..091b8d6 100644
--- a/pychassisctl/chassis_control.py
+++ b/pychassisctl/chassis_control.py
@@ -28,7 +28,7 @@
                     uuid = data
                 else:
                     print "ERROR:  UUID is not formatted correctly: " + data
-        except:
+        except Exception:
             print "ERROR: Unable to open uuid file: " + MACHINE_ID
 
         return uuid
@@ -37,7 +37,7 @@
         super(ChassisControlObject, self).__init__(
             conn=bus,
             object_path=name)
-        ## load utilized objects
+        # load utilized objects
         self.dbus_objects = {
             'power_control': {
                 'bus_name': 'org.openbmc.control.Power',
@@ -154,7 +154,7 @@
         intf = self.getInterface('power_control')
         return intf.getPowerState()
 
-    ## Signal handler
+    # Signal handler
 
     def SystemStateHandler(self, state_name):
         if state_name in ["HOST_POWERED_OFF", "HOST_POWERED_ON"]:
diff --git a/pyflashbmc/bmc_update.py b/pyflashbmc/bmc_update.py
index a83eafe..c934e1a 100644
--- a/pyflashbmc/bmc_update.py
+++ b/pyflashbmc/bmc_update.py
@@ -30,14 +30,16 @@
 def save_fw_env():
     fw_env = "/etc/fw_env.config"
     lines = 0
-    files=[]
+    files = []
     envcfg = open(fw_env, 'r')
     try:
         for line in envcfg.readlines():
             # ignore lines that are blank or start with #
-            if (line.startswith("#")): continue
-            if (not len(line.strip())): continue
-            fn = line.partition("\t")[0];
+            if (line.startswith("#")):
+                continue
+            if (not len(line.strip())):
+                continue
+            fn = line.partition("\t")[0]
             files.append(fn)
             lines += 1
     finally:
@@ -46,6 +48,7 @@
             raise Exception("Error parsing %s\n" % fw_env)
     shutil.copyfile(files[0], os.path.join(UPDATE_PATH, "image-u-boot-env"))
 
+
 class BmcFlashControl(DbusProperties, DbusObjectManager):
     def __init__(self, bus, name):
         super(BmcFlashControl, self).__init__(
@@ -85,13 +88,13 @@
         self.Set(DBUS_NAME, "filename", filename)
         pass
 
-    ## Signal handler
+    # Signal handler
     def download_error_handler(self, filename):
         if (filename == self.Get(DBUS_NAME, "filename")):
             self.Set(DBUS_NAME, "status", "Download Error")
 
     def download_complete_handler(self, outfile, filename):
-        ## do update
+        # do update
         if (filename != self.Get(DBUS_NAME, "filename")):
             return
 
@@ -100,7 +103,7 @@
         self.Set(DBUS_NAME, "status", "Download Complete")
         copy_files = {}
 
-        ## determine needed files
+        # determine needed files
         if not self.Get(DBUS_NAME, "update_kernel_and_apps"):
             copy_files["image-bmc"] = True
         else:
@@ -110,7 +113,7 @@
         if self.Get(DBUS_NAME, "restore_application_defaults"):
             copy_files["image-rwfs"] = True
 
-        ## make sure files exist in archive
+        # make sure files exist in archive
         try:
             tar = tarfile.open(outfile, "r")
             files = {}
@@ -178,7 +181,7 @@
             self.Set(DBUS_NAME, "status", "Image ready to apply.")
             if (self.Get(DBUS_NAME, "auto_apply")):
                 self.Apply()
-        except:
+        except Exception:
             self.Set(DBUS_NAME, "auto_apply", False)
             try:
                 subprocess.check_output([
@@ -218,7 +221,7 @@
         if self.update_process:
             try:
                 self.update_process.kill()
-            except:
+            except Exception:
                 pass
         for file in os.listdir(UPDATE_PATH):
             if file.startswith('image-'):
@@ -285,13 +288,13 @@
                 progress.close()
                 os.unlink(progress.name)
                 self.progress_name = None
-            except:
+            except Exception:
                 pass
             raise
 
         try:
             progress.close()
-        except:
+        except Exception:
             pass
 
     @dbus.service.method(
diff --git a/pyinventorymgr/inventory_items.py b/pyinventorymgr/inventory_items.py
index 254cd9e..17b5eab 100644
--- a/pyinventorymgr/inventory_items.py
+++ b/pyinventorymgr/inventory_items.py
@@ -40,7 +40,7 @@
 
         self.SetMultiple(INTF_NAME, data)
 
-        ## this will load properties from cache
+        # this will load properties from cache
         PropertyCacher.load(name, INTF_NAME, self.properties)
 
     @dbus.service.method(
@@ -104,8 +104,8 @@
         obj = InventoryItem(bus, obj_path, FRUS[f])
         obj_parent.add(obj_path, obj)
 
-        ## TODO:  this is a hack to update bmc inventory item with version
-        ## should be done by flash object
+        # TODO:  this is a hack to update bmc inventory item with version
+        # should be done by flash object
         if (FRUS[f]['fru_type'] == "BMC"):
             version = getVersion()
             obj.update({'version': version})
diff --git a/pyinventorymgr/sync_inventory_items.py b/pyinventorymgr/sync_inventory_items.py
index b00ef5c..a96c015 100644
--- a/pyinventorymgr/sync_inventory_items.py
+++ b/pyinventorymgr/sync_inventory_items.py
@@ -71,6 +71,7 @@
             mproxy = obj.get_dbus_method('Get', PROP_INTF_NAME)
             return mproxy(INV_INTF_NAME, prop)
 
+
 # Get Network Interface object.
 def get_network_interface_object(bus):
     mapper = obmc.mapper.Mapper(bus)
@@ -125,7 +126,7 @@
     sys_mac = ''
     try:
         sys_mac = subprocess.check_output(["fw_printenv", "-n", "ethaddr"])
-    except:
+    except Exception:
         # Handle when mac does not exist in u-boot
         return sys_mac
     return sys_mac
@@ -159,6 +160,7 @@
     else:
         print "Error setting uuid"
 
+
 if __name__ == '__main__':
     arg = argparse.ArgumentParser()
     arg.add_argument('-p')
diff --git a/pyipmitest/ipmi_debug.py b/pyipmitest/ipmi_debug.py
index d81cb2e..a8b1001 100644
--- a/pyipmitest/ipmi_debug.py
+++ b/pyipmitest/ipmi_debug.py
@@ -14,6 +14,7 @@
 DBUS_NAME = 'org.openbmc.HostIpmi'
 OBJ_NAME = '/org/openbmc/HostIpmi/1'
 
+
 def header(seq, netfn, lun, cmd):
     return (
         'seq:   0x%02x\nnetfn: 0x%02x\n\nlun: 0x%02d\ncmd:   0x%02x\n') % (
@@ -25,6 +26,7 @@
     str += 'data:  [%s]' % ', '.join(['0x%02x' % x for x in data])
     print str
 
+
 def print_response(seq, netfn, lun, cmd, cc, data):
     str = header(seq, netfn, lun, cmd)
     str += 'cc:    0x%02x\ndata:  [%s]' % (
@@ -32,9 +34,10 @@
             )
     print str
 
+
 class IpmiDebug(dbus.service.Object):
-    def __init__(self,bus,name):
-        dbus.service.Object.__init__(self,bus,name)
+    def __init__(self, bus, name):
+        dbus.service.Object.__init__(self, bus, name)
 
     @dbus.service.signal(DBUS_NAME, "yyyyay")
     def ReceivedMessage(self, seq, netfn, lun, cmd, data):
@@ -51,6 +54,7 @@
     def setAttention(self):
         print "IPMI SMS_ATN set"
 
+
 class ConsoleReader(object):
     def __init__(self, ipmi_obj):
         self.buffer = ''
@@ -83,6 +87,7 @@
         self.seq += 1
         self.ipmi_obj.ReceivedMessage(self.seq, data[0], 0, data[1], data[2:])
 
+
 def main():
     dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
     bus = dbus.SystemBus()
@@ -94,9 +99,10 @@
     name = dbus.service.BusName(DBUS_NAME, bus)
 
     print ("Enter IPMI packet as hex values. First three bytes will be used"
-            "as netfn and cmd.\nlun will be zero.")
+           "as netfn and cmd.\nlun will be zero.")
     mainloop.run()
 
+
 if __name__ == '__main__':
     sys.exit(main())
 
diff --git a/pysensormgr/sensor_manager2.py b/pysensormgr/sensor_manager2.py
index 9e423e0..cfd8868 100644
--- a/pysensormgr/sensor_manager2.py
+++ b/pysensormgr/sensor_manager2.py
@@ -44,13 +44,14 @@
         else:
             print "ERROR: Sensor not found: "+path
 
+
 if __name__ == '__main__':
     dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
     bus = get_dbus()
     root_sensor = SensorManager(bus, OBJ_PATH)
 
-    ## instantiate non-polling sensors
-    ## these don't need to be in separate process
+    # instantiate non-polling sensors
+    # these don't need to be in separate process
     if has_system:
         for (id, the_sensor) in System.MISC_SENSORS.items():
             sensor_class = the_sensor['class']
diff --git a/pystatemgr/discover_system_state.py b/pystatemgr/discover_system_state.py
index cc2ae10..9324eba 100644
--- a/pystatemgr/discover_system_state.py
+++ b/pystatemgr/discover_system_state.py
@@ -69,12 +69,14 @@
     intf = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
     return intf.Get(objs[key]['interface_name'], prop)
 
+
 def setProperty(bus, objs, key, prop, prop_value):
     obj = bus.get_object(
         objs[key]['bus_name'], objs[key]['object_name'])
     intf = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
     return intf.Set(objs[key]['interface_name'], prop, prop_value)
 
+
 bus = dbus.SystemBus()
 pgood = getProperty(bus, dbus_objects, 'power', 'pgood')
 
diff --git a/pysystemmgr/obmc/system/__init__.py b/pysystemmgr/obmc/system/__init__.py
index ff6c537..03dc235 100644
--- a/pysystemmgr/obmc/system/__init__.py
+++ b/pysystemmgr/obmc/system/__init__.py
@@ -1,6 +1,7 @@
 from os.path import join
 from glob import glob
 
+
 def find_gpio_base(path="/sys/class/gpio/"):
     pattern = "gpiochip*"
     for gc in glob(join(path, pattern)):
@@ -12,8 +13,10 @@
     # trigger a file not found exception
     open(join(path, "gpiochip"))
 
+
 GPIO_BASE = find_gpio_base()
 
+
 def convertGpio(name):
     offset = int(filter(str.isdigit, name))
     port = filter(str.isalpha, name.upper())
diff --git a/pysystemmgr/system_manager.py b/pysystemmgr/system_manager.py
index 575304b..a36b7af 100644
--- a/pysystemmgr/system_manager.py
+++ b/pysystemmgr/system_manager.py
@@ -184,7 +184,7 @@
         return r
 
     @dbus.service.method(DBUS_NAME, in_signature='',
-            out_signature='ssa(sb)a(sb)a(sbb)ssssa(sb)')
+                         out_signature='ssa(sb)a(sb)a(sbb)ssssa(sb)')
     def getGpioConfiguration(self):
         power_config = System.GPIO_CONFIGS.get('power_config', {})
         power_good_in = power_config.get('power_good_in', '')
@@ -198,8 +198,9 @@
         fsi_enable = hostctl_config.get('fsi_enable', '')
         cronus_sel = hostctl_config.get('cronus_sel', '')
         optionals = hostctl_config.get('optionals', [])
-        r = [power_good_in, latch_out, power_up_outs, reset_outs, pci_reset_outs,\
-             fsi_data, fsi_clk, fsi_enable, cronus_sel, optionals]
+        r = [power_good_in, latch_out, power_up_outs, reset_outs,
+             pci_reset_outs, fsi_data, fsi_clk, fsi_enable, cronus_sel,
+             optionals]
         print "Power GPIO config: " + str(r)
         return r
 
diff --git a/setup.cfg b/setup.cfg
index ed3bf6e..b5cec1b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,4 @@
 [install]
 install_scripts=/usr/sbin
+[pycodestyle]
+exclude=./configs/