From 47ecc10dbac6d212a9c7ce331350664ac4c12ed5 Mon Sep 17 00:00:00 2001 From: "Bart van Blokland (on MECHANINJA)" Date: Thu, 13 Jul 2017 00:31:12 +0200 Subject: [PATCH] Fixed crash when an online test was aborted by the student --- scrape.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scrape.py b/scrape.py index aec072d..9c25882 100644 --- a/scrape.py +++ b/scrape.py @@ -1322,7 +1322,10 @@ def dumpOnlineTestAnswerTable(institution, session, dumpDirectory, results_root_ print('NO DETAILS WILL BE SAVED OF THIS TEST.') - bytesToTextFile(attempt_file_contents.encode('utf-8'), dumpDirectory + '/' + sanitiseFilename(student_name) + '/Attempt ' + str(attempt_index) + output_text_extension) + try: + bytesToTextFile(attempt_file_contents.encode('utf-8'), dumpDirectory + '/' + sanitiseFilename(student_name) + '/Attempt ' + str(attempt_index) + output_text_extension) + except FileNotFoundError: + print('\tFailed to save attempt. Usually occurs when an attempt could not be accessed, for instance when you or a student has aborted it prematurely.') def processOnlineTest(institution, pathThusFar, nttUrl, nttID, session): online_test_response = session.get(nttUrl, allow_redirects=True)