examples: fix usage of input() with Python2

input() in Python2 evaluated the string and was thus unsafe. On
Python2, the right choice is raw_input. In Python3, input does
what raw_input did.

Work around this.

The main "problem" is that lgtm.com flags this as error. The fix
in the example is not important, but getting a low number of warnings
is.
This commit is contained in:
Thomas Haller 2021-05-26 18:03:13 +02:00
parent ebbf740c64
commit e1d40d89f0
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -54,6 +54,12 @@ for arg in sys.argv[2:]:
checkpoint = manager.CheckpointCreate(devList, interval, 1)
# DESTROY_ALL
try:
# Workaround for Python2
input = raw_input
except NameError:
pass
choice = input("Do you want to rollback [y/n]? ").lower()
if choice == "y":
print("Rollback checkpoint")