<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
from twisted.internet.protocol import Protocol, ClientFactory<br>from sys import stdout<br>from twisted.internet import reactor<br><br>from misc.configobj import ConfigObj<br>from misc.get_keywords import get_keywords<br>import time<br>import Queue<br>from bing_runner import msn<br>import simplejson as json<br>import base64<br>from time import sleep<br><br>class ses(object):<br> def __init__(self,client):<br> print "INITIATED"<br> self.client = client<br> self.main()<br> <br> def act_on(self,msg):<br> print "WE GOT IT BACK"<br> print msg <br> def main(self):<br> print "Downloading List"<br> self.client.sendMessage("get_data\r\n").addCallback(self.act_on)<br><br>class Echo(Protocol):<br> def connectionMade(self):<br> print "Connected To Server"<br> s = ses(self)<br><br> def sendMessage(self, msg):<br> print "Sending: %s"%msg<br> self.transport.write(msg)<br> d = defer.Deferred()<br> sleep(5) <br><br> def dataReceived(self, data):<br> stdout.write(data)<br> self.s.server_data = data<br> return encoded<br><br>class EchoClientFactory(ClientFactory):<br> protocol = Protocol<br> def startedConnecting(self, connector):<br> print 'Started to connect.'<br> <br> def buildProtocol(self, addr):<br> print 'Connected.'<br> return Echo();<br> def clientConnectionLost(self, connector, reason):<br> print 'Lost connection. Reason:', reason<br> <br> def clientConnectionFailed(self, connector, reason):<br> print 'Connection failed. Reason:', reason<br> #def clientConnectionLost(self, connector, reason):<br> #connector.connect()<br><br># this connects the protocol to a server runing on port 8000<br>def main():<br> f = EchoClientFactory()<br> f.protocol = Echo<br> reactor.connectTCP("localhost", 8000, f)<br> reactor.run()<br><br><br># this only runs if the module was *not* imported<br>if __name__ == '__main__':<br> main()<br><br>I am trying to figure out a way so I can access the datareceived outside of the Echo Class so I can run operations on the data received. Fairly new to twisted. Any help is appreciated<br>                                            <br /><hr />Get Windows 7 for only $39.99-CDN College or University students only. <a href='http://go.microsoft.com/?linkid=9691814' target='_new'>This offer ends Jan 3-upgrade now!</a></body>
</html>