Skip to content

Instantly share code, notes, and snippets.

@ketang ketang/gist:4120671
Created Nov 20, 2012

Embed
What would you like to do?
Simplified Indeed log repository reader
def readLogEntries(host, port, eventType, start, end):
command = "%d %d %s\n" % (start, end, eventType)
sock = socket.socket()
sock.connect((host, port))
try:
sock.send(command)
fd = sock.makefile()
for line in fd:
valueMap = urlparse.parse_qs(line)
flattened = dict(((k, v[0]) for k, v in valueMap.iteritems()))
yield flattened
finally:
sock.close()
# output:
# {
# 'type': 'mobsavejob',
# 'uid': '17bkeek5d19nm2hg',
# 'v': '0',
# 'lang': 'en',
# 'a': 'remove', 'origin':
# 'saved', 'pos': 'star',
# 'jk': '494741af1b48d496'
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.