[Twisted-Python] ftpClient.py, retrieveFile, and line ending issues

Keith.Gunderson at act.org Keith.Gunderson at act.org
Tue Dec 6 17:41:07 EST 2005


If any of you have a spare minute, I can't figure out else where I might
solve my present dilemma.  Its certainly likely that my only issues are
ignorance about Python's file operations or the features that are a part of
other FTP clients that I use.

I'm using the ftpclient.py code to write a script which downloads file via
FTP.  My example code shows the basics.  The file is transferred, but the
lines seem to have different line endings when I view them 'hexlified' in
xemacs.  My twisted-created files has hex 0D0D 0D0D 0D0D at the end of
lines while a file downloaded using SmartFTP has hex 0D0A 0D0A.

Is it clear, based on that information, if there is an issue in my code?
Or an easy way to fix it?

class FileWriterProtocol(Protocol):
    def __init__(self, filename):
        self.file = open(filename, 'w')

    def dataReceived(self, data):

def connectionMade(ftpClient):

    proto2 = FileWriterProtocol( 'c:/ftpfile1.txt' )

    # Get the file, and quit when done
    d = ftpClient.retrieveFile( 's1/s2/T2005C.processed' ,
    d.addCallback(lambda result: reactor.stop())

Thanks very much,

Keith Gunderson

More information about the Twisted-Python mailing list