summaryrefslogtreecommitdiffstats
path: root/pyinventorymgr
diff options
context:
space:
mode:
authorCamVan Nguyen <ctnguyen@us.ibm.com>2018-02-27 15:14:41 -0600
committerCamVan Nguyen <ctnguyen@us.ibm.com>2018-03-12 12:44:32 -0500
commitd65b2d501ba69c8371634ffc4907d85dc614074f (patch)
treeae19a691b1a4659a2a08423f36e5d2766c73b2ad /pyinventorymgr
parentc182e5ece4a7a4079c935d381ea787390cf0feb5 (diff)
downloadtalos-skeleton-d65b2d501ba69c8371634ffc4907d85dc614074f.tar.gz
talos-skeleton-d65b2d501ba69c8371634ffc4907d85dc614074f.zip
Port to python 3
Port code to python 3 yet remain backward compatible to python 2. This port is in preparation for yocto 2.4 upgrade. Partially resolves openbmc/openbmc#2920 Change-Id: If174ce9444bde4e21fb086764f4def017e423201 Signed-off-by: CamVan Nguyen <ctnguyen@us.ibm.com>
Diffstat (limited to 'pyinventorymgr')
-rw-r--r--pyinventorymgr/inventory_items.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/pyinventorymgr/inventory_items.py b/pyinventorymgr/inventory_items.py
index 17b5eab..168e3d6 100644
--- a/pyinventorymgr/inventory_items.py
+++ b/pyinventorymgr/inventory_items.py
@@ -2,7 +2,11 @@
import os
import sys
-import gobject
+# TODO: openbmc/openbmc#2994 remove python 2 support
+try: # python 2
+ import gobject
+except ImportError: # python 3
+ from gi.repository import GObject as gobject
import dbus
import dbus.service
import dbus.mainloop.glib
@@ -88,7 +92,7 @@ if __name__ == '__main__':
try:
inv = json.load(f)
except ValueError:
- print "Invalid JSON detected in " + INVENTORY_FILE
+ print("Invalid JSON detected in " + INVENTORY_FILE)
else:
FRUS = inv
else:
@@ -98,7 +102,7 @@ if __name__ == '__main__':
except ImportError:
pass
- for f in FRUS.keys():
+ for f in list(FRUS.keys()):
import obmc.inventory
obj_path = f.replace("<inventory_root>", obmc.inventory.INVENTORY_ROOT)
obj = InventoryItem(bus, obj_path, FRUS[f])
@@ -112,7 +116,7 @@ if __name__ == '__main__':
obj_parent.unmask_signals()
name = dbus.service.BusName(DBUS_NAME, bus)
- print "Running Inventory Manager"
+ print("Running Inventory Manager")
mainloop.run()
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
OpenPOWER on IntegriCloud