Skip to content

Commit

Permalink
Slosh logging.
Browse files Browse the repository at this point in the history
Parsing this will be a bit of a pain.  May need to parse it on the way
in and emit records without xml declarations.
  • Loading branch information
dustin committed Dec 3, 2008
1 parent 3c55928 commit 4a81e1a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions misc/stream.py
@@ -0,0 +1,32 @@
#!/usr/bin/env python
"""
Log slosh output.
Copyright (c) 2008 Dustin Sallings <dustin@spy.net>
"""

import sys

from twisted.internet import reactor, task
from twisted.web import client

cookies = {}

def cb(factory):
def f(data):
global cookies
cookies = factory.cookies
print data
return f

def getPage(url):
factory = client.HTTPClientFactory(url, cookies=cookies)
scheme, host, port, path = client._parse(url)
reactor.connectTCP(host, port, factory)
factory.deferred.addCallback(cb(factory))
return factory.deferred

lc = task.LoopingCall(getPage, sys.argv[1])
lc.start(0)

reactor.run()

0 comments on commit 4a81e1a

Please sign in to comment.