SHARE
TWEET

Untitled

a guest Nov 1st, 2014 360 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. import socket
  3. import time
  4. import urllib2
  5. import re
  6.  
  7.  
  8. sock2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  9. sock2.bind(('0.0.0.0', 9761))
  10. sock2.settimeout(20)
  11.  
  12. while True:
  13.         data, addr = sock2.recvfrom(1024) # buffer size is 1024 bytes
  14.         print "received message:", data
  15.         if re.search("\*\!",data):
  16.                 m = re.search(r'cUse":(\d+),"maxUse":(\d+),"todUse":(\d+),"yesUse":(\d+)',data)
  17.                 urllib2.urlopen("http://192.168.0.101:8080/json.htm?type=command&param=udevice&idx=46&nvalue=0&svalue="+m.group(1)+";"+m.group(3))
  18.                 print "http://192.168.0.101:8080/json.htm?type=command&param=udevice&idx=46&nvalue=0&svalue="+m.group(1)+";"+m.group(3)
  19.                 sock2.close()
  20.         sock2.close()
  21.         break
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top