jeudi 13 août 2015

Python evaluating a local fabric curl command

Seems like this should work but it doesn't really. I've played around with various methods like using range, seeing if the expression evaluates to True, etc. I use local to run the command locally with fabric.

This is what it looks like now:

def test_health_check():
    test = local('curl -I -sL -w "%{http_code} %{url_effective}\\n" --user username:username --location-mylocation "http://ift.tt/1TxM5iO" -o /dev/null | cut -d " " -f 1')
    if test == 200:
        print "success"
    else:
        print "failure"

If I set the if test portion to if test >= 200: then it evaluates True but evaluates false for anything else. I want to be able to return True if the range is 200 thru 302. Also, is there a better way of doing this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire