Commit 8531dfe231e839298a48045f52fa0690eec8a9fa

Authored by Tássia Camões Araújo
1 parent e3e4041f
Exists in master and in 1 other branch add_vagrant

Moving file removal to try block (thanks krishna).

Showing 1 changed file with 3 additions and 2 deletions   Show diff stats
src/web/survey.py
@@ -99,12 +99,13 @@ class Save: @@ -99,12 +99,13 @@ class Save:
99 prediction_file.seek(0) 99 prediction_file.seek(0)
100 prediction_file.close() 100 prediction_file.close()
101 evaluation_file.close() 101 evaluation_file.close()
  102 + os.remove(os.path.join(strategy_dir,"prediction"))
102 except: 103 except:
103 error_msg = "Could not write evaluation to file." 104 error_msg = "Could not write evaluation to file."
104 logging.critical(error_msg) 105 logging.critical(error_msg)
105 - return render.error([error_msg], "/survey/","START") 106 + if not os.path.exists(os.path.join(strategy_dir,"evaluation")):
  107 + return render.error([error_msg], "/survey/","START")
106 finally: 108 finally:
107 - os.remove(os.path.join(strategy_dir,"prediction"))  
108 with open(os.path.join(strategy_dir,"end"),'w') as end: 109 with open(os.path.join(strategy_dir,"end"),'w') as end:
109 end_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S") 110 end_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
110 end.write(end_time) 111 end.write(end_time)