diff options
author | Frederick Muriuki Muriithi | 2024-02-09 04:22:51 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-02-12 18:17:38 +0300 |
commit | 4c077c01db19e8adc01d9559677ad5693a1db909 (patch) | |
tree | 3aeedc2ef8b18aa5a6bddb162531487687ae11e9 /qc_app/upload | |
parent | dd369b846524fed0c08d1b7318fd73478506c3ee (diff) | |
download | gn-uploader-4c077c01db19e8adc01d9559677ad5693a1db909.tar.gz |
Raise error if file is missing rather than returning a Union value.
Diffstat (limited to 'qc_app/upload')
-rw-r--r-- | qc_app/upload/rqtl2.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py index afe0c2e..b96d9f0 100644 --- a/qc_app/upload/rqtl2.py +++ b/qc_app/upload/rqtl2.py @@ -152,13 +152,15 @@ def upload_rqtl2_bundle(species_id: int, population_id: int): species=species, population=population) - if not bool(request.files.get("rqtl2_bundle_file")): - raise __RequestError__("No R/qtl2 zip bundle provided.") - - the_file = save_file(request.files["rqtl2_bundle_file"], - Path(app.config["UPLOAD_FOLDER"])) - if not bool(the_file): - raise __RequestError__("Please provide a valid R/qtl2 zip bundle.") + try: + the_file = save_file(request.files["rqtl2_bundle_file"], + Path(app.config["UPLOAD_FOLDER"])) + except AssertionError: + flash("Please provide a valid R/qtl2 zip bundle.", + "alert-error error-rqtl2") + return redirect(url_for("upload.rqtl2.upload_rqtl2_bundle", + species_id=species_id, + population_id=population_id)) if not is_zipfile(str(the_file)): raise __RequestError__("Invalid file! Expected a zip file.") |