mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 02:30:08 +01: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
1 changed files with 6 additions and 0 deletions
|
|
@ -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…
Add table
Reference in a new issue