genouest / biomaj-download

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

Correctly detect iRODS exceptions and set error status. #21

Closed duboism closed 4 years ago

duboism commented 4 years ago

This PR corrects 2 bugs in IRODSDownload:

  1. iRODS exception are not correctly detected (because the catch is based on the custom ExceptionIRODS class and not iRODS' exceptions).
  2. the error status is not set in case of errors.

With those modifications trying to download a non-existent file (as below) is correctly detected (i.e. it raise a BioMAJ exception):

from biomaj_download.download.protocolirods import IRODSDownload

irodsd = IRODSDownload("localhost", "/tempZone/home/rods")
irodsd.set_options(dict(skip_check_uncompress=True))
irodsd.set_param(dict(
    user='rods',
    password='rods',
))
# Download a fake file
irodsd.set_files_to_download([
    {'name': 'TOTO.zip', 'year': 2016, 'month': 2, 'day': 19,
     'size': 1, 'save_as': 'TOTO1KB'}
])
irodsd.download("/tmp")

Without them, this code triggers iRODS errors.