convert ftp.retrbinary to file object? - Python language lacks expression?
Robert
k.robert at gmx.de
Thu Feb 3 10:35:59 EST 2005
That turns into periodic new RETR commands with offset. Think its more
an "odd" trick. I'd even prefer a threaded approach (thread puts the
blocks into a stack; a while ... yield generator loop in the main thread
serves the .read() function of the pseudo file object, which is my
wish). Yet such tricks are all kind of OS-level tricks with a lot of
overhead.
I wonder really, if the Python language itself can express an elegant
flat solution to turn the block delivering callback function into a
generator/.read(bytes) solution? I found no way.
(Looking over some Ruby stuff, Ruby seems to be able to do so from the
language. I am not really familiar to Ruby. I always felt Python to be
as complete - but much more clean. I became somewhat jealous ... :-) )
As the solution in my case has to stand many different file systems
compatibly ( file.read(bytes) function !) and also other FTPS & SFTP
classes with different retrbinary functions have to be compatible, I
cannot even make a simple FTP subclassed retrbinary without getting
really weired. Thus the existing .retrbinary with callback is the
"official interface in this game".
> >> def callback(self, data):
> >> self.offset = self.offset + len(data)
> >> self.data = data
> >> ## now quit the RETR command?
> >> raise TransferAbort("stop right now")
More information about the Python-list
mailing list