Changeset 243 for indytube/trunk

Show
Ignore:
Timestamp:
10/14/07 23:52:37 (15 months ago)
Author:
andy
Message:

Updates to get bittorrent perseptive broker impl

Location:
indytube/trunk/bittorrent
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • indytube/trunk/bittorrent/client.py

    r241 r243  
    5656 
    5757        def _callRemoteFailed(self, result): 
    58                 print "failed! %s " % result 
     58 
     59                print "failed! "  
     60                print " .__class__ =", result.__class__ 
     61                print " .getErrorMessage() =", result.getErrorMessage() 
     62                print " .type =", result.type 
    5963                self._doReactorStop() 
    6064 
    6165        def runReactor(self): 
    62                 reactor.run(installSignalHandlers=0) 
     66                #start the twisted reactor 
     67                # see http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#Igetexceptions.ValueError:signalonlyworksinmainthreadwhenItrytorunmyTwistedprogramWhatswrong 
     68                # if you want to not install the signal handlers 
     69                #reactor.run(installSignalHandlers=0) 
     70                reactor.run() 
    6371         
    6472        def _doReactorStop(self): 
    65                 reactor.crash() 
     73                reactor.stop() 
     74                print "stopping reactor!" 
     75                #crash? if you do installSignalHandlers = 0 you may need it 
     76                #reactor.crash() 
     77 
     78 
     79def main(): 
     80        # test a simple connection to the server, on the localhost 
     81        client = IndyTubeClient('localhost',9119) 
     82        client.setupOperation('http://localhost/download/video','filename.ogg') 
     83        client.connectToServer() 
     84        client.runReactor() 
     85 
     86# this only runs if the module was *not* imported 
     87if __name__ == '__main__': 
     88    main() 
     89 
  • indytube/trunk/bittorrent/server.py

    r239 r243  
    9090        self.pb_downloadDir = config.get('pb-server', 'DOWNLOAD_DIR') 
    9191        self.pb_serverName = config.get('pb-server', 'SERVER_NAME') 
     92        self.pb_trackerUrl = config.get('pb-server', 'TRACKER_URL') 
    9293 
    93         print "I have %s %s %s %s " % ( self.pb_protocolPort , self.pb_torrentDir , self.pb_downloadDir, self.pb_serverName ) 
     94        print "I have %s %s %s %s %s " % ( self.pb_protocolPort , self.pb_torrentDir , self.pb_downloadDir, self.pb_serverName, self.pb_trackerUrl ) 
    9495 
    9596    def __init__(self): 
     
    117118        torrent_filepath = self.pb_torrentDir + '/' + filename + ".torrent" 
    118119        incoming_comment = "Torrent file made by Indytube" 
    119         make_meta_files( trackerURL, [incoming_fp], piece_len_pow2=18, comment=incoming_comment, target = torrent_filepath) 
     120        make_meta_files( self.pb_trackerUrl, [incoming_fp], piece_len_pow2=18, comment=incoming_comment, target = torrent_filepath) 
    120121 
    121122        #4. Seeding and tracking! 
     
    162163# 
    163164#Ready for running via  
    164 #$ twisted -ny <nameofscript.py> 
     165#$ twisted -ny bittorrent/server.py