From 35ad44942160ea920ce2f6e5dd95926ef03aed24 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 18 Oct 2017 09:16:15 +0200 Subject: [PATCH] try/except around get_file_type to catch corrupt gzip --- rowers/dataprep.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index abfde140..40ccfc3f 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -828,7 +828,13 @@ def new_workout_from_file(r,f2, makeprivate=False, notes=''): message = None - fileformat = get_file_type(f2) + try: + fileformat = get_file_type(f2) + except IOError: + os.remove(f2) + message = "Rowsandall could not process this file. The extension is supported but the file seems corrupt. Contact info@rowsandall.com if you think this is incorrect." + return (0,message,f2) + summary = '' oarlength = 2.89 inboard = 0.88