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 /obmc/dbuslib | |
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>
Diffstat (limited to 'obmc/dbuslib')
-rw-r--r-- | obmc/dbuslib/bindings.py | 8 | ||||
-rw-r--r-- | obmc/dbuslib/propertycacher.py | 18 |
2 files changed, 13 insertions, 13 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) |