Commit 67b6efc1 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

make FTPConnector.getFile binary mode by default, because ascii mode only...

make FTPConnector.getFile binary mode by default, because ascii mode only works with utf-8 encoding.

also propagate binary mode to SFTPClient.file().
parent 2e7fbe79
......@@ -84,7 +84,7 @@ class FTPConnector(XMLObject):
def getFile(self, filepath, binary=False):
def getFile(self, filepath, binary=True):
""" Try to get a file on the remote server """
conn = self.getConnection()
\ No newline at end of file
\ No newline at end of file
......@@ -94,10 +94,13 @@ class SFTPConnection:
except error, msg:
raise SFTPError(str(msg) + ' while writing file %s on %s' % (filepath, path, self.url))
def _getFile(self, filepath):
def _getFile(self, filepath, binary=True):
"""Retrieve the file"""
tmp_file = self.conn.file(filepath)
if binary:
tmp_file = self.conn.file(filepath, 'rb')
tmp_file = self.conn.file(filepath, 'r')
return Binary(
except error, msg:
......@@ -105,11 +108,11 @@ class SFTPConnection:
def readBinaryFile(self, filepath):
"""Retrieve the file in binary mode"""
return StringIO(str(self._getFile(filepath)))
return StringIO(str(self._getFile(filepath, binary=True)))
def readAsciiFile(self, filepath):
"""Retrieve the file in ASCII mode"""
binary = self._getFile(filepath)
binary = self._getFile(filepath, binary=False)
if binary:
return None
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment