[Twisted-Python] Problem with ftp upload
Stéphane Brault
stephane_brault at yahoo.fr
Fri Nov 3 02:54:21 MST 2006
Thanks Thomas,
my problem is that I already applied the patch and it still doesn't work. That's what I don't understand.
Stéphane
----- Message d'origine ----
De : Thomas Jacob <jacob at internet24.de>
À : Twisted general discussion <twisted-python at twistedmatrix.com>
Envoyé le : Vendredi, 3 Novembre 2006, 10h32mn 52s
Objet : Re: [Twisted-Python] Problem with ftp upload
There is bug in storeFile's Consumer interface
(Cf. report + patch http://twistedmatrix.com/trac/ticket/1794 )
As for disconnecting, why not call ftpClient->quit() after
your upload has finished?
On Thu, 2006-11-02 at 20:57 +0000, Stéphane Brault wrote:
> Hi,
>
> I'm using twisted ftp api to upload files, I also added the ticket 1914 patch.
> Here is my code :
> class myFTP(object):
>
> def __init__(self, login, password):
> self.creator = ClientCreator(reactor, FTPClient, login, password, passive=0)
>
>
> def connectionFailed(self, f):
> print 'connection error'
>
>
> def success(self, response):
> print 'Success'
>
>
> def fail(self, error):
> print 'Erreur:' + error
>
>
> def doOperation(self, operation, data):
> d = self.creator.connectTCP(FTP_ADDRESS, 21)
> if operation == 'addItems':
> return d.addCallback(self.inventoryUpload, data).addErrback(self.connectionFailed)
> elif ....
>
>
>
> def _upload(self, consumer, file):
> return FileSender().beginFileTransfer(file, consumer).addCallback(lambda _: consumer.finish()).addCallback(lambda _: file.close())
>
>
> def inventoryUpload(self, ftpClient, file):
> name = '/stock/entrees/export_items_' + encodeDate(datetime.datetime.now()) + '.txt'
> return ftpClient.storeFile(name)[0].addCallback(self._upload, file).addCallbacks(self.success, self.fail)
>
> ....
>
> The operation is called this way:
> call = myFTP(login, password)
> call.doOperation('addItems', StringIO(data))
>
> The file is created but empty, it seems that _upload is not called, I can't understand why, any hint ?
> I was also wondering how to disconnect once my work is done, I don't think keeping open connections is a good thing.
>
> Thanks,
>
> Stéphane
>
>
>
>
>
>
>
>
> ___________________________________________________________________________
> Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
> Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
> http://fr.answers.yahoo.com
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com
More information about the Twisted-Python
mailing list