Python 3 compatibility: use print as a function.

In Python 3 print is a function.
Especially for multiple string print, need to import
print_function from __future__.

Story: 2002909

Task: 24560

Signed-off-by: zhangyangyang <zhangyangyang@unionpay.com>

Change-Id: Ie31eb59368af57776eb9785dba494432111cd250
This commit is contained in:
zhangyangyang 2018-08-29 17:28:31 +08:00
parent 1868f2f9ad
commit f16577f6f8
3 changed files with 10 additions and 10 deletions

View File

@ -112,9 +112,9 @@ def main():
logger = Logger(logging.DEBUG).get_logger()
logger.info("Starting....")
logger.info("Parsed options: %s" % options)
print logger
print(logger)
buddy = BuddyInfo(logger)
print buddy
print(buddy)
if __name__ == '__main__':
main()

View File

@ -1218,7 +1218,7 @@ def checkDuration(duration):
return None
else:
time.sleep(duration)
print "Duration interval has ended. Killing processes now"
print("Duration interval has ended. Killing processes now")
logging.warning("Duration interval has ended. Killing processes now")
raise KeyboardInterrupt
@ -1262,7 +1262,7 @@ def createDB(influx_info, grafana_port, grafana_api_key):
if p is not None:
p.kill()
except Exception as e:
print e.message
print(e.message)
sys.exit(0)
@ -1277,7 +1277,7 @@ def deleteDB(influx_info, grafana_port, grafana_api_key):
if answer is None or answer == "" or answer == "y" or answer == "yes":
try:
logging.info("Removing database from InfluxDB and Grafana")
print "Removing database from InfluxDB and Grafana. Please wait..."
print("Removing database from InfluxDB and Grafana. Please wait...")
# delete database from InfluxDB
p = Popen("curl -s -XPOST 'http://'{}':'{}'/query' --data-urlencode 'q=DROP DATABASE {}'".format(influx_info[0], influx_info[1], influx_info[2]), shell=True, stdout=PIPE)
response = p.stdout.read().strip("\n")
@ -1306,7 +1306,7 @@ def deleteDB(influx_info, grafana_port, grafana_api_key):
if p is not None:
p.kill()
except Exception as e:
print e.message
print(e.message)
sys.exit(0)
@ -1322,7 +1322,7 @@ def appendToFile(file, content):
if __name__ == "__main__":
# make sure user is root
if os.geteuid() != 0:
print "Must be run as root!\n"
print("Must be run as root!\n")
sys.exit(0)
# initialize variables
@ -1432,7 +1432,7 @@ if __name__ == "__main__":
else:
SERVICES[service_tuple[0]] = {'name': service_tuple[1], 'api-port': None}
except Exception:
print "An error has occurred when parsing the engtools.conf configuration file: {}".format(sys.exc_info())
print("An error has occurred when parsing the engtools.conf configuration file: {}".format(sys.exc_info()))
sys.exit(0)
syseng_services = live_svc + static_svcs
@ -1579,7 +1579,7 @@ if __name__ == "__main__":
tasks.append(p)
p.start()
print "Sending data to InfluxDB. Please tail /tmp/livestream.log"
print("Sending data to InfluxDB. Please tail /tmp/livestream.log")
checkDuration(duration)
# give a small delay to ensure services have started

View File

@ -185,7 +185,7 @@ def main():
if len(sys.argv) == 2 :
licensefile = sys.argv[1]
else:
print "Usage: verify-license <license file>"
print("Usage: verify-license <license file>")
exit(-1)
try: