diff server/ts.py @ 35:4bfa9b7b2e4b

- fix mac/urllib to work - don't sent 'START' line
author Matt Johnston <matt@ucc.asn.au>
date Sat, 16 Jun 2012 09:03:15 +0800
parents 79124d7d3f79
children 9b5b202129c3
line wrap: on
line diff
--- a/server/ts.py	Fri Jun 15 23:36:41 2012 +0800
+++ b/server/ts.py	Sat Jun 16 09:03:15 2012 +0800
@@ -19,6 +19,8 @@
 import binascii
 import hmac
 import zlib
+import urllib
+import urllib2
 
 import config
 
@@ -57,7 +59,6 @@
         print>>sys.stderr, "Bad expected START line '%s'\n" % l.rstrip('\n')
         return None
     crc = crc16(l, crc)
-    lines.append(l)
 
     while True:
         l = readline(sock)
@@ -122,9 +123,9 @@
 
 def send_results(lines):
     enc_lines = binascii.b2a_base64(zlib.compress('\n'.join(lines)))
-    hmac.new(config.HMAC_KEY, enc_lines).hexdigest()
+    mac = hmac.new(config.HMAC_KEY, enc_lines).hexdigest()
 
-    url_data = urllib.url_encode( ('lines', enc_lines), ('hmac', mac) )
+    url_data = urllib.urlencode( {'lines': enc_lines, 'hmac': mac} )
     con = urllib2.urlopen(config.UPDATE_URL, url_data)
     result = con.read(100)
     if result == 'OK':