aboutsummaryrefslogtreecommitdiff
path: root/qc_app/upload
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-08 11:25:37 +0300
committerFrederick Muriuki Muriithi2024-01-08 11:25:37 +0300
commitcba824f61ad1d1dc489a54a3919351ffa956234c (patch)
tree680cf7f4eaf57cd53874d0690b371a8bfd45bb39 /qc_app/upload
parent8595c75345fb5849a4d8894f3ee7a926dd8cdf8f (diff)
downloadgn-uploader-cba824f61ad1d1dc489a54a3919351ffa956234c.tar.gz
Fix errors with types.
Diffstat (limited to 'qc_app/upload')
-rw-r--r--qc_app/upload/rqtl2.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/qc_app/upload/rqtl2.py b/qc_app/upload/rqtl2.py
index 53e7f3f..d60ea65 100644
--- a/qc_app/upload/rqtl2.py
+++ b/qc_app/upload/rqtl2.py
@@ -103,6 +103,9 @@ def create_population(species_id: int):
pgsrc="create-population"),
code=307)
+class __RequestError__(Exception): #pylint: disable=[invalid-name]
+ """Internal class to avoid pylint's `too-many-return-statements` error."""
+
@rqtl2.route(("/upload/species/<int:species_id>/population/<int:population_id>"
"/rqtl2-bundle"),
methods=["GET", "POST"])
@@ -133,22 +136,21 @@ def upload_rqtl2_bundle(species_id: int, population_id: int):
species=species,
population=population)
+ if not bool(request.files.get("rqtl2_bundle")):
+ raise __RequestError__("No R/qtl2 zip bundle provided.")
+
the_file = save_file(
- request.files.get("rqtl2_bundle"), Path(app.config["UPLOAD_FOLDER"]))
+ request.files["rqtl2_bundle"], Path(app.config["UPLOAD_FOLDER"]))
if not bool(the_file):
- flash("Please provide a valid R/qtl2 zip bundle.",
- "alert-error alert-danger error-rqtl2")
- return this_page_with_errors
+ raise __RequestError__("Please provide a valid R/qtl2 zip bundle.")
- if not is_zipfile(the_file):
- flash("Invalid file! Expected a zip file.",
- "alert-error alert-danger error-rqtl2")
- return this_page_with_errors
+ if not is_zipfile(str(the_file)):
+ raise __RequestError__("Invalid file! Expected a zip file.")
try:
- with ZipFile(the_file, "r") as zfile:
+ with ZipFile(str(the_file), "r") as zfile:
r_qtl2.validate_bundle(zfile)
return "WOULD PROCESS THE BUNDLE..."
- except InvalidFormat as invf:
- flash("".join(invf.args), "alert-error alert-danger error-rqtl2")
+ except (InvalidFormat, __RequestError__) as exc:
+ flash("".join(exc.args), "alert-error alert-danger error-rqtl2")
return this_page_with_errors