Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(206)

Unified Diff: update-client.py

Issue 975: Add support for removes in updater.py and update-client.py SVN Base: http://malfind2.googlecode.com/svn/trunk/
Patch Set: Created 4 months, 3 weeks ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side by-side-diff with in-line comments
Download patch
Index: update-client.py
===================================================================
--- update-client.py (revision 10)
+++ update-client.py (working copy)
@@ -7,18 +7,17 @@
hashes = []
count = 0
-def AddHashes(hashes):
- body = urllib.urlencode({"data": ",".join(hashes)})
-
+def UpdateHashes(hashes):
+ body = urllib.urlencode({'data': ''.join(hashes)})
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': len(body),
}
try:
- # conn = httplib.HTTPConnection("localhost:8080")
- conn = httplib.HTTPConnection("malfind.appspot.com")
- conn.request("POST", "/update", body, headers)
+ #conn = httplib.HTTPConnection("localhost:8080")
+ conn = httplib.HTTPConnection('malfind.appspot.com')
+ conn.request('POST', '/update', body, headers)
response = conn.getresponse()
conn.close()
print response.status, response.reason
@@ -29,24 +28,23 @@
return False
-def TryAddHashes(hashes):
+def TryUpdateHashes(hashes):
retries = 0
while retries < 2:
- if AddHashes(hashes):
+ if UpdateHashes(hashes):
hashes = []
break
- print "Error, Retrying in 60 secs"
+ print 'Error, Retrying in 60 secs'
time.sleep(60)
retries += 1
if retries == 2:
- print "Too many errors, aborting"
+ print 'Too many errors, aborting'
sys.exit(-1)
-
for line in open('/tmp/sbcache.txt'):
- if not line[0] == '+':
+ if not line.startswith('+') and not line.startswith('-'):
print 'Ignoring ' + line.strip('\n')
continue
@@ -54,14 +52,13 @@
if count < 19000:
continue
- hashes.append(line.strip('+').strip('\t\n'))
-
+ hashes.append(line.strip('\t\n'))
if count % 50 == 0:
print count
- TryAddHashes(hashes)
+ TryUpdateHashes(hashes)
hashes = []
time.sleep(0.2)
-TryAddHashes(hashes)
+TryUpdateHashes(hashes)
-print "Success"
+print 'Success'

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r338