Enable pycodestyle

Apply fix-ups and run pycodestyle during CI testing.

Change-Id: I1005495b11e228abdc8d40a51dbf81c4a6e6c92c
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/obmc/dbuslib/bindings.py b/obmc/dbuslib/bindings.py
index 8a04447..acc8792 100644
--- a/obmc/dbuslib/bindings.py
+++ b/obmc/dbuslib/bindings.py
@@ -56,7 +56,7 @@
         try:
             v = d[property_name]
             return v
-        except:
+        except Exception:
             raise dbus.exceptions.DBusException(
                 "Unknown property: '{}'".format(property_name),
                 name="org.freedesktop.DBus.Error.UnknownProperty")
@@ -68,7 +68,7 @@
         try:
             d = self.properties[interface_name]
             return d
-        except:
+        except Exception:
             raise dbus.exceptions.DBusException(
                 "Unknown interface: '{}'".format(interface_name),
                 name="org.freedesktop.DBus.Error.UnknownInterface")
@@ -91,7 +91,7 @@
                     self.PropertiesChanged(
                         interface_name, {property_name: new_value}, [])
 
-        except:
+        except Exception:
             self.properties[interface_name][property_name] = new_value
             if self._export:
                 self.PropertiesChanged(
@@ -112,7 +112,7 @@
                     self.properties[interface_name][property_name] = new_value
                     value_changed = True
 
-            except:
+            except Exception:
                 self.properties[interface_name][property_name] = new_value
                 value_changed = True
         if (value_changed is True and self._export):
diff --git a/obmc/dbuslib/propertycacher.py b/obmc/dbuslib/propertycacher.py
index 875b164..6086bc6 100644
--- a/obmc/dbuslib/propertycacher.py
+++ b/obmc/dbuslib/propertycacher.py
@@ -14,6 +14,7 @@
 # implied. See the License for the specific language governing
 # permissions and limitations under the License.
 
+import json
 import os
 # TODO: openbmc/openbmc#2994 remove python 2 support
 import sys
@@ -21,19 +22,18 @@
     import cPickle as pickle
 else:
     import pickle
-import json
 
 CACHE_PATH = '/var/cache/obmc/'
 
 
 def getCacheFilename(obj_path, iface_name):
     name = obj_path.replace('/', '.')
-    filename = CACHE_PATH+name[1:]+"@"+iface_name+".props"
+    filename = CACHE_PATH + name[1:] + "@" + iface_name + ".props"
     return filename
 
 
 def save(obj_path, iface_name, properties):
-    print("Caching: "+obj_path)
+    print("Caching: "+ obj_path)
     filename = getCacheFilename(obj_path, iface_name)
     parent = os.path.dirname(filename)
     try:
@@ -41,23 +41,23 @@
             os.makedirs(parent)
         with open(filename, 'wb') as output:
             try:
-                ## use json module to convert dbus datatypes
+                # use json module to convert dbus datatypes
                 props = json.dumps(properties[iface_name])
                 prop_obj = json.loads(props)
                 pickle.dump(prop_obj, output)
             except Exception as e:
-                print("ERROR: "+str(e))
-    except:
-        print("ERROR opening cache file: "+filename)
+                print("ERROR: " + str(e))
+    except Exception:
+        print("ERROR opening cache file: " + filename)
 
 
 def load(obj_path, iface_name, properties):
-    ## overlay with pickled data
+    # overlay with pickled data
     filename = getCacheFilename(obj_path, iface_name)
     if (os.path.isfile(filename)):
         if iface_name in properties:
             properties[iface_name] = {}
-        print("Loading from cache: "+filename)
+        print("Loading from cache: " + filename)
         try:
             p = open(filename, 'rb')
             data = pickle.load(p)
diff --git a/obmc/sensors.py b/obmc/sensors.py
index e61ddac..ffee5d1 100644
--- a/obmc/sensors.py
+++ b/obmc/sensors.py
@@ -21,7 +21,7 @@
 from obmc.dbuslib.bindings import DbusProperties
 
 
-## Abstract class, must subclass
+# Abstract class, must subclass
 class SensorValue(DbusProperties):
     IFACE_NAME = 'org.openbmc.SensorValue'
 
@@ -61,7 +61,7 @@
         if (state == "HOST_POWERED_OFF"):
             self.setValue("Off")
 
-    ##override setValue method
+    # override setValue method
     @dbus.service.method(
         SensorValue.IFACE_NAME,
         in_signature='v', out_signature='')
@@ -87,7 +87,7 @@
         # SBE side switch boot attempt
         self.setValue(3)
 
-    ## override setValue method for debug purposes
+    # override setValue method for debug purposes
     @dbus.service.method(
         SensorValue.IFACE_NAME, in_signature='v', out_signature='')
     def setValue(self, value):
@@ -158,7 +158,7 @@
         VirtualSensor.__init__(self, bus, name)
         super(PowerSupplyDeratingSensor, self).setValue(90)
 
-    ## override setValue method
+    # override setValue method
     @dbus.service.method(
         SensorValue.IFACE_NAME, in_signature='v', out_signature='')
     def setValue(self, value):
@@ -170,7 +170,7 @@
         VirtualSensor.__init__(self, bus, name)
         self.setValue(0)
 
-    ## override setValue method
+    # override setValue method
     @dbus.service.method(
         SensorValue.IFACE_NAME, in_signature='b', out_signature='')
     def setValue(self, value):
diff --git a/obmc/utils/misc.py b/obmc/utils/misc.py
index 12d0489..b55ef6d 100644
--- a/obmc/utils/misc.py
+++ b/obmc/utils/misc.py
@@ -14,6 +14,7 @@
 # implied. See the License for the specific language governing
 # permissions and limitations under the License.
 
+
 def org_dot_openbmc_match_strings(sep='.', prefix=''):
     matches = [
         ['org', 'openbmc'],
@@ -30,8 +31,8 @@
 
 
 class ListMatch(object):
-    def __init__(self, l):
-        self.l = l
+    def __init__(self, lst):
+        self.lst = lst
 
     def __call__(self, match):
         return match in self.l
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..96c1d9a
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,3 @@
+[pycodestyle]
+max-line-length = 80
+select=E226