Skip to content

Commit fac14f4

Browse files
author
Wojciech Ziółek
committed
ftp_utils: New configuration variables and FTP/SFTP ls method update
* Adds new configuration variables for Elsevier SFTP connection - port, sftp * Adds an addition cleaning to file names on the list of files/folders from ls method in ftp_utils.py
1 parent c44fd8b commit fac14f4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

harvestingkit/contrast_out.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def connect(self):
9999
try:
100100
self.ftp = FtpHandler(self.config.ELSEVIER.URL,
101101
self.config.ELSEVIER.LOGIN,
102-
self.config.ELSEVIER.PASSWORD)
102+
self.config.ELSEVIER.PASSWORD,
103+
port = int(self.config.ELSEVIER.PORT),
104+
sftp = self.config.ELSEVIER.SFTP)
103105
self.logger.debug(('Successful connection to the '
104106
'Elsevier server'))
105107
return

harvestingkit/ftp_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,17 @@ def ls(self, folder=''):
195195
contents = self._sftp_client.listdir()
196196
files = filter(lambda a: str(self._sftp_client.lstat(a)).split()[0].startswith('-'), contents)
197197
folders = filter(lambda a: str(self._sftp_client.lstat(a)).split()[0].startswith('d'), contents)
198+
files = map(lambda a: ' '.join(a.split()[8:]), files)
199+
folders = map(lambda a: ' '.join(a.split()[8:]), folders)
198200
self._sftp_client.chdir(current_folder)
199201
else:
200202
current_folder = self._ftp.pwd()
201203
self.cd(folder)
202204
self._ftp.retrlines('LIST', lambda a: contents.append(a))
203205
files = filter(lambda a: a.split()[0].startswith('-'), contents)
204206
folders = filter(lambda a: a.split()[0].startswith('d'), contents)
207+
files = map(lambda a: ' '.join(a.split()[8:]), files)
208+
folders = map(lambda a: ' '.join(a.split()[8:]), folders)
205209
self._ftp.cwd(current_folder)
206210
return files, folders
207211

user_config.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
login = empty
33
password = empty
44
url = empty
5+
port = 21
6+
sftp = True
57

68
[OXFORD]
79
login = empty

0 commit comments

Comments
 (0)