Reputation: 3011
cccI have a python script that is driving me nuts. Here is the offending code... the code in the if statement is not running, can someone suggest why?:
print("refresh_type is: " + refresh_type)
if (refresh_type == "update"):
print("hello world")
cmd = 'sudo svn %s --username %s --password %s %s' % ('up', un, pw, working_path)
print("command is: " + str(cmd))
elif(refresh_type == 'checkout' or refresh_type == 'co'):
cmd = 'sudo svn %s --username %s --password %s %s %s' % (refreshType, un, pw, rc_service_url, working_path)
print('username = ' + credentials['un'])
print('password = ' + credentials['pw'])
print("working path = " + working_path)
Here are the outputs of the print statements:
refresh_type is: 'update'
username = 'cccc'
password = 'vvvvv'
working path = '/home/ubuntu/workingcopy/rc_service'
Upvotes: 1
Views: 147
Reputation: 1121316
Your refresh_type
value is not update
, it's 'update'
. The rest of your variables suffer from the same ailment, they have quotes as part of the string value.
Use print "refresh_type is:", repr(refresh_type)
as a diagnostic aid in this.
You could use:
if refresh_type == "'update'":
but you have a more fundamental problem, one where you end up with extra quotes in your string values.
To illustrate, a short Python interpreter session:
>>> print 'update'
update
>>> print "'update'"
'update'
>>> "'update'" == 'update'
False
>>> foo = "'update'"
>>> print repr(foo)
"'update'"
Upvotes: 4