[Twisted-Python] Re: synchronous problem
Wu Zhe
jessewoo at gmail.com
Tue Jul 8 08:12:43 EDT 2008
> def import_query(self, path_list):
> number_of_files = len(path_list)
> line = '3#%s' % number_of_files
> self.client_instance.sendLine(line)
>
> sender = FileSender()
> sender.CHUNK_SIZE = common.chunk_size
> for path in path_list:
> f = open(path, 'rb')
> s = f.read()
> filesize = len(s)
> crc = crc32(s)
> line = '3#%s:%s' % (filesize, crc)
> self.client_instance.sendLine(line)
>
> def transfer_completed(lastsent):
> f.close()
> self.client_instance.setLineMode()
>
> # send the file
> self.setRawMode()
sorry, the above line should be: self.client_instance.setRawMode()
self.client_instance is an instance of a subclass inherited from LineReceiver.
> d = sender.beginFileTransfer(f, self.client_instance.transport)
> d.addCallback(transfer_completed)
>
--
Wu Zhe
Best Regards
More information about the Twisted-Python
mailing list