import light import urllib2 true = 1 while(true): try: response = urllib2.urlopen('http://192.168.1.6/light.php') status = response.read() except urllib2.httperror, e: print e.code except urllib2.urlerror, e: print e.args print status if status=='17': light.lighton(); elif status=='0': light.lightoff();
wild guess: response terminated newline. try this:
status = status.strip() print status if status=='17': light.lighton(); elif status=='0': light.lightoff();
Comments
Post a Comment