diff --git a/pi/monitor.py b/pi/monitor.py index aacf566..f4bc016 100644 --- a/pi/monitor.py +++ b/pi/monitor.py @@ -15,7 +15,16 @@ print "No id" exit(1) +if len(sys.argv) < 3: + print "No url" + exit(1) + +ext = "" +if len(sys.argv) > 3: + ext = sys.argv[3] + id = int(sys.argv[1]) +url_base = sys.argv[2] l = GP.LED(18) @@ -42,7 +51,7 @@ print "status now: " + str(status) try: - response = urllib2.urlopen("https://www.mhack.io/bathroom/status-update.php?door_id=" + str(id) + "&status=" + ("1" if status else "0")) + response = urllib2.urlopen(baseUrl + "/status-update" + ext + ".php?door_id=" + str(id) + "&status=" + ("1" if status else "0")) enc_verify = base64.b64decode(response.read()) @@ -50,7 +59,7 @@ print " verifying with: " + verify - response = urllib2.urlopen("https://www.mhack.io/bathroom/verify-status.php?door_id=" + str(id) + "&verify=" + verify) + response = urllib2.urlopen(baseUrl + "/verify-status" + ext + ".php?door_id=" + str(id) + "&verify=" + verify) print " returned: " + response.read() except Exception as e: print str(e)