genouest / biomaj-download

Download microservice for BioMAJ
GNU Affero General Public License v3.0
1 stars 7 forks source link

Raise exceptions in method list #30

Closed duboism closed 4 years ago

duboism commented 4 years ago

This PR addresses issue #29. This is mainly raising errors when something goes wrong on list.

There are 2 changes that could impact other aspects :

Functional tests are done in genouest/biomaj#120.

Note that the tests use assertLogs which requires python >= 3.4 so we needed to drop support for python 2 before (see afefe2d).

osallou commented 4 years ago

Is it ready for merge? If yes, could you add modification info in changes file?

duboism commented 4 years ago

Hello,

I think the PR is ready for merge. I have updated CHANGES.txt. Shall I increment the version in setup.py ?

duboism commented 4 years ago

@osallou Thanks for merging. I think that genouest/biomaj#120 can be merged too.

duboism commented 4 years ago

Based on the merged code the examples in #29 are:

>>> sftpd = CurlDownload(curl_protocol="sftp", host="test.rebex.net", rootdir="/toto")
>>> sftpd.set_credentials("demo:password")
>>> sftpd.list()
Error while listing sftp://test.rebex.net/toto - (78, 'Could not open remote file for reading: SFTP server: Path not found.')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mdubois/Code/BioMAJ/biomaj-download/biomaj_download/download/curl.py", line 432, in list
    raise e
  File "/home/mdubois/Code/BioMAJ/biomaj-download/biomaj_download/download/curl.py", line 423, in list
    self.crl.perform()
pycurl.error: (78, 'Could not open remote file for reading: SFTP server: Path not found.')

And:

>>> sftpd = CurlDownload(curl_protocol="sftp", host="test.rebex.net", rootdir="/")
>>> sftpd.set_credentials("demo:badpassword")
>>> sftpd.list()
Error while listing sftp://test.rebex.net/ - (67, 'Authentication failure')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mdubois/Code/BioMAJ/biomaj-download/biomaj_download/download/curl.py", line 432, in list
    raise e
  File "/home/mdubois/Code/BioMAJ/biomaj-download/biomaj_download/download/curl.py", line 423, in list
    self.crl.perform()
pycurl.error: (67, 'Authentication failure')