Skip to content
This repository was archived by the owner on Nov 15, 2019. It is now read-only.

Commit 36a8a48

Browse files
committed
Improve logging for FTP connection errors.
1 parent f5cba11 commit 36a8a48

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fetch/ftp.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
import re
88

9-
from . import DataSource, fetch_file
9+
from . import DataSource, fetch_file, RemoteFetchException
1010

1111
_log = logging.getLogger(__name__)
1212
DEFAULT_SOCKET_TIMEOUT_SECS = 60 * 5.0
@@ -31,7 +31,15 @@ def _fetch_files(hostname,
3131
:type reporter: ResultHandler
3232
"""
3333

34-
ftp = ftplib.FTP(hostname, timeout=DEFAULT_SOCKET_TIMEOUT_SECS)
34+
try:
35+
ftp = ftplib.FTP(hostname, timeout=DEFAULT_SOCKET_TIMEOUT_SECS)
36+
except:
37+
_log.exception('Error connecting to FTP')
38+
raise RemoteFetchException(
39+
'Error connecting to FTP',
40+
'host: {}, timeout: {}'.format(hostname, DEFAULT_SOCKET_TIMEOUT_SECS)
41+
)
42+
3543
try:
3644
ftp.login()
3745

0 commit comments

Comments
 (0)