コード例 #1
0
    def _read_zipfile(self, ftppath):

        zipf = BytesIO()
        try:
            self._sec_ftp_session.retrbinary('RETR ' + ftppath, zipf.write)
        except EOFError:
            raise RemoteDataError('FTP server has closed the connection.')
        zipf.seek(0)
        with ZipFile(zipf, 'r') as zf:
            data = zf.open(zf.namelist()[0]).read().decode()

        return StringIO(data)
コード例 #2
0
    def _read_zipfile(self, ftppath):

        zipf = BytesIO()
        try:
            self._sec_ftp_session.retrbinary('RETR ' + ftppath, zipf.write)
        except EOFError:
            raise RemoteDataError('FTP server has closed the connection.')
        zipf.seek(0)
        with ZipFile(zipf, 'r') as zf:
            data = zf.open(zf.namelist()[0]).read().decode()

        return StringIO(data)
コード例 #3
0
    def _read_gzfile(self, ftppath):

        zipf = BytesIO()
        try:
            self._sec_ftp_session.retrbinary('RETR ' + ftppath, zipf.write)
        except EOFError:
            raise RemoteDataError('FTP server has closed the connection.')
        zipf.seek(0)
        zf = gzip.GzipFile(fileobj=zipf, mode='rb')
        try:
            data = zf.read().decode('iso-8859-1')
        finally:
            zf.close()

        return StringIO(data)
コード例 #4
0
    def _read_gzfile(self, ftppath):

        zipf = BytesIO()
        try:
            self._sec_ftp_session.retrbinary('RETR ' + ftppath, zipf.write)
        except EOFError:
            raise RemoteDataError('FTP server has closed the connection.')
        zipf.seek(0)
        zf = gzip.GzipFile(fileobj=zipf, mode='rb')
        try:
            data = zf.read().decode('iso-8859-1')
        finally:
            zf.close()

        return StringIO(data)