Skip to content

Commit 2d60aa8

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 Signed-off-by: Wojciech Ziółek <wojciech.ziolek@cern.ch>
1 parent c44fd8b commit 2d60aa8

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

harvestingkit/contrast_out.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
##
33
## This file is part of Harvesting Kit.
4-
## Copyright (C) 2013, 2014 CERN.
4+
## Copyright (C) 2013, 2014, 2016 CERN.
55
##
66
## Harvesting Kit is free software; you can redistribute it and/or
77
## modify it under the terms of the GNU General Public License as
@@ -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/elsevier_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
#
33
# This file is part of Harvesting Kit.
4-
# Copyright (C) 2013, 2014, 2015 CERN.
4+
# Copyright (C) 2013, 2014, 2015, 2016 CERN.
55
#
66
# Harvesting Kit is free software; you can redistribute it and/or
77
# modify it under the terms of the GNU General Public License as

harvestingkit/ftp_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
##
33
## This file is part of Harvesting Kit.
4-
## Copyright (C) 2014 CERN.
4+
## Copyright (C) 2014, 2016 CERN.
55
##
66
## Harvesting Kit is free software; you can redistribute it and/or
77
## modify it under the terms of the GNU General Public License as
@@ -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)