summaryrefslogtreecommitdiffstats
path: root/pyflashbmc
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 /pyflashbmc
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 'pyflashbmc')
-rw-r--r--pyflashbmc/bmc_update.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/pyflashbmc/bmc_update.py b/pyflashbmc/bmc_update.py
index c934e1a..8c5936e 100644
--- a/pyflashbmc/bmc_update.py
+++ b/pyflashbmc/bmc_update.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
-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
@@ -98,7 +102,7 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
if (filename != self.Get(DBUS_NAME, "filename")):
return
- print "Download complete. Updating..."
+ print("Download complete. Updating...")
self.Set(DBUS_NAME, "status", "Download Complete")
copy_files = {}
@@ -120,13 +124,13 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
for f in tar.getnames():
files[f] = True
tar.close()
- for f in copy_files.keys():
+ for f in list(copy_files.keys()):
if f not in files:
raise Exception(
"ERROR: File not found in update archive: "+f)
except Exception as e:
- print e
+ print(str(e))
self.Set(DBUS_NAME, "status", "Unpack Error")
return
@@ -136,7 +140,7 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
tar.close()
if self.Get(DBUS_NAME, "clear_persistent_files"):
- print "Removing persistent files"
+ print("Removing persistent files")
try:
os.unlink(UPDATE_PATH+"/whitelist")
except OSError as e:
@@ -159,11 +163,11 @@ class BmcFlashControl(DbusProperties, DbusObjectManager):
raise
if self.Get(DBUS_NAME, "preserve_network_settings"):
- print "Preserving network settings"
+ print("Preserving network settings")
save_fw_env()
except Exception as e:
- print e
+ print(str(e))
self.Set(DBUS_NAME, "status", "Unpack Error")
self.Verify()
@@ -327,7 +331,7 @@ if __name__ == '__main__':
obj.unmask_signals()
name = dbus.service.BusName(DBUS_NAME, bus)
- print "Running Bmc Flash Control"
+ print("Running Bmc Flash Control")
mainloop.run()
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
OpenPOWER on IntegriCloud