-
Notifications
You must be signed in to change notification settings - Fork 0
/
push_remote.py
executable file
·42 lines (30 loc) · 1.04 KB
/
push_remote.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from glue.client import Client, start_client
import urllib2, urllib
import json
import time
class ApeClient(Client):
name = "Local Ape"
purpose = "reader"
def read_data(self, message):
if message.find('<1SEC>') == 0:
server = 'http://s67.org/publish/?id=car'
#data = {'message':message
data = message.replace('<1SEC>', '').replace('(','').replace(')','')
if data.find('<') == -1:
try:
data = data.split(",")
except e:
pass
else:
message = {}
# Timestmap should always be first
for d in data:
field, value = d.split(":")
message[field] = value
#data = urllib.urlencode(data)
req = urllib2.Request(server, json.dumps(message))
response = urllib2.urlopen(req)
the_page = response.read()
print the_page
if __name__ == "__main__":
start_client(client=ApeClient())