From 6af016dd69398088ee255c5376c21f1c20075062 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 23 Apr 2017 23:41:24 +0300 Subject: [PATCH] Fix log file encoding in ftpscan.py --- m_lib/net/ftp/ftpscan.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: -- 2.39.5