From 38395b2307dff0c90c8ac3d94cbfd942abde8942 Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Fri, 10 Aug 2018 12:52:46 +0200 Subject: [PATCH] Fix print statement in console scripts Change-Id: Ibafcdde71542485b8141f2a16f049d76c74b50ab --- bin/fakebmc | 8 ++++---- bin/pyghmiutil | 36 +++++++++++++++++++----------------- bin/virshbmc | 2 +- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/bin/fakebmc b/bin/fakebmc index 8f1985a2..e2b25ebc 100755 --- a/bin/fakebmc +++ b/bin/fakebmc @@ -45,7 +45,7 @@ class FakeBmc(bmc.Bmc): def cold_reset(self): # Reset of the BMC, not managed system, here we will exit the demo - print 'shutting down in response to BMC cold reset request' + print('shutting down in response to BMC cold reset request') sys.exit(0) def get_power_state(self): @@ -54,18 +54,18 @@ class FakeBmc(bmc.Bmc): def power_off(self): # this should be power down without waiting for clean shutdown self.powerstate = 'off' - print 'abruptly remove power' + print('abruptly remove power') def power_on(self): self.powerstate = 'on' - print 'powered on' + print('powered on') def power_reset(self): pass def power_shutdown(self): # should attempt a clean shutdown - print 'politely shut down the system' + print('politely shut down the system') self.powerstate = 'off' def is_active(self): diff --git a/bin/pyghmiutil b/bin/pyghmiutil index d0130701..1410ffdd 100755 --- a/bin/pyghmiutil +++ b/bin/pyghmiutil @@ -27,8 +27,9 @@ import sys from pyghmi.ipmi import command if (len(sys.argv) < 3) or 'IPMIPASSWORD' not in os.environ: - print "Usage:" - print " IPMIPASSWORD=password %s bmc username " % sys.argv[0] + print("Usage:") + print(" IPMIPASSWORD=password %s bmc username " + % sys.argv[0]) sys.exit(1) password = os.environ['IPMIPASSWORD'] @@ -44,40 +45,41 @@ ipmicmd = None def docommand(result, ipmisession): cmmand = sys.argv[3] - print "Logged into %s" % ipmisession.bmc + print("Logged into %s" % ipmisession.bmc) if 'error' in result: - print result['error'] + print(result['error']) return if cmmand == 'power': if args: - print ipmisession.set_power(args[0], wait=True) + print(ipmisession.set_power(args[0], wait=True)) else: value = ipmisession.get_power() - print "%s: %s" % (ipmisession.bmc, value['powerstate']) + print("%s: %s" % (ipmisession.bmc, value['powerstate'])) elif cmmand == 'bootdev': if args: - print ipmisession.set_bootdev(args[0]) + print(ipmisession.set_bootdev(args[0])) else: - print ipmisession.get_bootdev() + print(ipmisession.get_bootdev()) elif cmmand == 'sensors': for reading in ipmisession.get_sensor_data(): - print repr(reading) + print(reading) elif cmmand == 'health': - print repr(ipmisession.get_health()) + print(ipmisession.get_health()) elif cmmand == 'inventory': for item in ipmisession.get_inventory(): - print repr(item) + print(item) elif cmmand == 'leds': for led in ipmisession.get_leds(): - print repr(led) + print(led) elif cmmand == 'graphical': - print ipmisession.get_graphical_console() + print(ipmisession.get_graphical_console()) elif cmmand == 'net': - print ipmisession.get_net_configuration() + print(ipmisession.get_net_configuration()) elif cmmand == 'raw': - print ipmisession.raw_command(netfn=int(args[0]), - command=int(args[1]), - data=map(lambda x: int(x, 16), args[2:])) + print(ipmisession.raw_command( + netfn=int(args[0]), + command=int(args[1]), + data=map(lambda x: int(x, 16), args[2:]))) bmcs = string.split(bmc, ",") for bmc in bmcs: diff --git a/bin/virshbmc b/bin/virshbmc index b4c3b917..fca2ffac 100755 --- a/bin/virshbmc +++ b/bin/virshbmc @@ -60,7 +60,7 @@ class LibvirtBmc(bmc.Bmc): def cold_reset(self): # Reset of the BMC, not managed system, here we will exit the demo - print 'shutting down in response to BMC cold reset request' + print('shutting down in response to BMC cold reset request') sys.exit(0) def get_power_state(self):