mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-04 15:21:12 +00:00
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:
parent
ebbf740c64
commit
e1d40d89f0
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue