diff --git a/rowers/management/commands/processemail.py b/rowers/management/commands/processemail.py index f5b6c8f5..1d2424e4 100644 --- a/rowers/management/commands/processemail.py +++ b/rowers/management/commands/processemail.py @@ -48,6 +48,13 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False): except AttributeError: filename = fileobj[6:] + # test if file exists and is not empty + try: + with open(filename,'r') as fop: + line = fop.readline() + except IOError: + return 0 + workoutid = [ make_new_workout_from_email(rower, filename, title,testing=testing) ] @@ -104,7 +111,10 @@ def get_from_address(message): else: body = message.get_body().splitlines() - first_line = body[0].lower() + try: + first_line = body[0].lower() + except IndexError: + first_line = '' if "quiske" in first_line: match = re.search(r'[\w\.-]+@[\w\.-]+', first_line)