From: Oleg Broytman Date: Sun, 23 Apr 2017 20:41:24 +0000 (+0300) Subject: Fix log file encoding in ftpscan.py X-Git-Tag: 3.1.0~6 X-Git-Url: https://git.phdru.name/?p=m_lib.git;a=commitdiff_plain;h=6af016dd69398088ee255c5376c21f1c20075062 Fix log file encoding in ftpscan.py --- diff --git a/m_lib/net/ftp/ftpscan.py b/m_lib/net/ftp/ftpscan.py index ebff998..eb0681c 100755 --- a/m_lib/net/ftp/ftpscan.py +++ b/m_lib/net/ftp/ftpscan.py @@ -5,6 +5,7 @@ from __future__ import print_function import codecs import ftplib +import sys from .ftpparse import ftpparse @@ -222,7 +223,10 @@ def test(ftp_server, func, passive=None, reconnect=False): print(stop_time - start_time) logfname = "%s.list" % ftp_server - log = codecs.open(logfname, 'w', encoding='utf-8') + if sys.version_info[0] >= 3: + log = codecs.open(logfname, 'w', encoding='utf-8') + else: + log = open(logfname, 'w') for ftp_dir, files in tree: if ftp_dir == ftpscan_error_mark: