summaryrefslogtreecommitdiffstats
path: root/pyinventorymgr
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2016-08-30 20:03:48 -0400
committerPatrick Williams <patrick@stwcx.xyz>2016-09-06 12:46:19 +0000
commitc91b0bfd5bc748c2b22dd226ab1d064235d08e4f (patch)
tree110ee4e6e86b35503ae7efbce846b9b649eea00d /pyinventorymgr
parent67a6f45b19ab1a6fddf4e9a116399d35a912d5f3 (diff)
downloadtalos-skeleton-c91b0bfd5bc748c2b22dd226ab1d064235d08e4f.tar.gz
talos-skeleton-c91b0bfd5bc748c2b22dd226ab1d064235d08e4f.zip
inventory: pep8 fixes
Change-Id: Ib27c332db35a9e3d5e0bba9d56d5b48966eef9a6 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'pyinventorymgr')
-rw-r--r--pyinventorymgr/inventory_items.py125
1 files changed, 60 insertions, 65 deletions
diff --git a/pyinventorymgr/inventory_items.py b/pyinventorymgr/inventory_items.py
index ddaec98..67a6838 100644
--- a/pyinventorymgr/inventory_items.py
+++ b/pyinventorymgr/inventory_items.py
@@ -1,13 +1,9 @@
-#!/usr/bin/python -u
+#!/usr/bin/env python
-import os
-import sys
import gobject
import dbus
import dbus.service
import dbus.mainloop.glib
-import cPickle
-import json
import obmc.dbuslib.propertycacher as PropertyCacher
from obmc.dbuslib.bindings import get_dbus, DbusProperties, DbusObjectManager
import obmc_system_config as System
@@ -16,62 +12,62 @@ INTF_NAME = 'org.openbmc.InventoryItem'
DBUS_NAME = 'org.openbmc.Inventory'
FRUS = System.FRU_INSTANCES
-class Inventory(DbusProperties,DbusObjectManager):
- def __init__(self,bus,name):
- DbusProperties.__init__(self)
- DbusObjectManager.__init__(self)
- dbus.service.Object.__init__(self,bus,name)
+
+class Inventory(DbusProperties, DbusObjectManager):
+ def __init__(self, bus, name):
+ DbusProperties.__init__(self)
+ DbusObjectManager.__init__(self)
+ dbus.service.Object.__init__(self, bus, name)
class InventoryItem(DbusProperties):
- def __init__(self,bus,name,data):
- DbusProperties.__init__(self)
- dbus.service.Object.__init__(self,bus,name)
-
- self.name = name
-
- if (data.has_key('present') == False):
- data['present'] = 'False'
- if (data.has_key('fault') == False):
- data['fault'] = 'False'
- if (data.has_key('version') == False):
- data['version'] = ''
-
- self.SetMultiple(INTF_NAME,data)
-
- ## this will load properties from cache
- PropertyCacher.load(name, INTF_NAME, self.properties)
-
-
- @dbus.service.method(INTF_NAME,
- in_signature='a{sv}', out_signature='')
- def update(self,data):
- self.SetMultiple(INTF_NAME,data)
- PropertyCacher.save(self.name, INTF_NAME, self.properties)
-
- @dbus.service.method(INTF_NAME,
- in_signature='s', out_signature='')
- def setPresent(self,present):
- self.Set(INTF_NAME,'present',present)
- PropertyCacher.save(self.name, INTF_NAME, self.properties)
-
- @dbus.service.method(INTF_NAME,
- in_signature='s', out_signature='')
- def setFault(self,fault):
- self.Set(INTF_NAME,'fault',fault)
- PropertyCacher.save(self.name, INTF_NAME, self.properties)
+ def __init__(self, bus, name, data):
+ DbusProperties.__init__(self)
+ dbus.service.Object.__init__(self, bus, name)
+
+ self.name = name
+
+ if 'present' not in data:
+ data['present'] = 'False'
+ if 'fault' not in data:
+ data['fault'] = 'False'
+ if 'version' not in data:
+ data['version'] = ''
+
+ self.SetMultiple(INTF_NAME, data)
+
+ ## this will load properties from cache
+ PropertyCacher.load(name, INTF_NAME, self.properties)
+
+ @dbus.service.method(
+ INTF_NAME, in_signature='a{sv}', out_signature='')
+ def update(self, data):
+ self.SetMultiple(INTF_NAME, data)
+ PropertyCacher.save(self.name, INTF_NAME, self.properties)
+
+ @dbus.service.method(
+ INTF_NAME, in_signature='s', out_signature='')
+ def setPresent(self, present):
+ self.Set(INTF_NAME, 'present', present)
+ PropertyCacher.save(self.name, INTF_NAME, self.properties)
+
+ @dbus.service.method(
+ INTF_NAME, in_signature='s', out_signature='')
+ def setFault(self, fault):
+ self.Set(INTF_NAME, 'fault', fault)
+ PropertyCacher.save(self.name, INTF_NAME, self.properties)
def getVersion():
- version = "Error"
- with open('/etc/os-release', 'r') as f:
- for line in f:
- p = line.rstrip('\n')
- parts = line.rstrip('\n').split('=')
- if (parts[0] == "VERSION_ID"):
- version = parts[1]
- version = version.strip('"')
- return version
+ version = "Error"
+ with open('/etc/os-release', 'r') as f:
+ for line in f:
+ p = line.rstrip('\n')
+ parts = line.rstrip('\n').split('=')
+ if (parts[0] == "VERSION_ID"):
+ version = parts[1]
+ version = version.strip('"')
+ return version
if __name__ == '__main__':
@@ -81,18 +77,17 @@ if __name__ == '__main__':
obj_parent = Inventory(bus, '/org/openbmc/inventory')
for f in FRUS.keys():
- obj_path=f.replace("<inventory_root>",System.INVENTORY_ROOT)
- obj = InventoryItem(bus,obj_path,FRUS[f])
- obj_parent.add(obj_path,obj)
+ obj_path = f.replace("<inventory_root>", System.INVENTORY_ROOT)
+ 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
- if (FRUS[f]['fru_type'] == "BMC"):
- version = getVersion()
- obj.update({'version': version})
+ ## 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})
obj_parent.unmask_signals()
- name = dbus.service.BusName(DBUS_NAME,bus)
+ name = dbus.service.BusName(DBUS_NAME, bus)
print "Running Inventory Manager"
mainloop.run()
-
OpenPOWER on IntegriCloud