diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-01-30 13:00:26 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-03-29 15:44:10 -0400 |
commit | aea38c650b8554e8f6293483286eba18a5547cd9 (patch) | |
tree | 870f8e1645a20fce741e2f8572336f4a0931e2a7 | |
parent | dc63ed495112f1f7f36fd9b125d48b7fbf4b2323 (diff) | |
download | pyphosphor-aea38c650b8554e8f6293483286eba18a5547cd9.tar.gz pyphosphor-aea38c650b8554e8f6293483286eba18a5547cd9.zip |
Enable pycodestyle
Apply fix-ups and run pycodestyle during CI testing.
Change-Id: I1005495b11e228abdc8d40a51dbf81c4a6e6c92c
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r-- | obmc/dbuslib/bindings.py | 8 | ||||
-rw-r--r-- | obmc/dbuslib/propertycacher.py | 18 | ||||
-rw-r--r-- | obmc/sensors.py | 10 | ||||
-rw-r--r-- | obmc/utils/misc.py | 5 | ||||
-rw-r--r-- | setup.cfg | 3 |
5 files changed, 24 insertions, 20 deletions
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 @@ class DbusProperties(dbus.service.Object): 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 @@ class DbusProperties(dbus.service.Object): 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 @@ class DbusProperties(dbus.service.Object): 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 @@ class DbusProperties(dbus.service.Object): 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 @@ if sys.version_info[0] < 3: 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 @@ def save(obj_path, iface_name, properties): 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 @@ import dbus.service 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 @@ class BootProgressSensor(VirtualSensor): 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 @@ class BootCountSensor(VirtualSensor): # 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 @@ class PowerSupplyDeratingSensor(VirtualSensor): 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 @@ class TurboAllowedSensor(VirtualSensor): 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 @@ def org_dot_openbmc_match(name, sep='.', prefix=''): 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 |