Strange problem here. If I use fabric.operations.prompt
to get the value of a variable, it appears to store it just fine. However, it's confusing my while loop.
Here is the code setting the variable manually:
def test():
#var1 = fabric.operations.prompt("Var1:")
var1 = 3
var2 = 1
while (var1 > var2):
print("hi")
var2 = var2 + 1
print("var2: %s" % var2)
print("var1: %s" % var1)
Not surprisingly, the output is:
[me@host]$ fab test
hi
var2: 2
var1: 3
hi
var2: 3
var1: 3
Done.
However, if I change my code to be:
def test():
var1 = fabric.operations.prompt("Var1:")
var2 = 1
while (var1 > var2):
print("hi")
var2 = var2 + 1
print("var2: %s" % var2)
print("var1: %s" % var1)
The output is something like the below. Caught it as soon as I could, it executed extremely fast.
var1: 3
hi
var2: 34567
var1: 3
hi
var2: 34568
var1: 3
hi
var2: 34569
var1: 3
hi
var2: 34570
^C
Stopped.
This loop is telling me that 3 > 34570
. That's not true. I think this is fabric-specific and something with the .prompt
operation.
This has to be a variable, I can't set it manually.