Commit 533fea409ff66ad082652486bbaf5fa6d17c9295

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

Treating errors when saveing report.

Showing 1 changed file with 23 additions and 23 deletions   Show diff stats
src/web/survey.py
... ... @@ -111,29 +111,29 @@ class Save:
111 111 end.write(end_time)
112 112  
113 113 # Save report
114   - #try:
115   - report = os.path.join(user_dir,"report")
116   - report_file = open(os.path.join(user_dir,"report"),'a')
117   - writer = csv.writer(report_file)
118   - if os.path.getsize(report) == 0:
119   - fieldnames = ('user','strategy','start','end','poor',
120   - 'redundant','useful','surprising','comments')
121   - writer.writerow(fieldnames)
122   - with open(os.path.join(strategy_dir,"start"),'r') as start:
123   - start_time = start.readline().strip()
124   - if web_input.has_key("comments"):
125   - comments = web_input['comments'].encode("utf-8")
126   - else:
127   - comments = ""
128   - writer.writerow((user_id,strategy,start_time,end_time,summary["poor"],
129   - summary["redundant"],summary["useful"],
130   - summary["surprising"],comments))
131   - #except:
132   - # error_msg = "Could not save evaluation report."
133   - # logging.critical(error_msg)
134   - # return render.error([error_msg], "/survey/","START")
135   - #finally:
136   - # report_file.close()
  114 + try:
  115 + report = os.path.join(user_dir,"report")
  116 + report_file = open(os.path.join(user_dir,"report"),'a')
  117 + writer = csv.writer(report_file)
  118 + if os.path.getsize(report) == 0:
  119 + fieldnames = ('user','strategy','start','end','poor',
  120 + 'redundant','useful','surprising','comments')
  121 + writer.writerow(fieldnames)
  122 + with open(os.path.join(strategy_dir,"start"),'r') as start:
  123 + start_time = start.readline().strip()
  124 + if web_input.has_key("comments"):
  125 + comments = web_input['comments'].encode("utf-8")
  126 + else:
  127 + comments = ""
  128 + writer.writerow((user_id,strategy,start_time,end_time,summary["poor"],
  129 + summary["redundant"],summary["useful"],
  130 + summary["surprising"],comments))
  131 + report_file.close()
  132 + except:
  133 + error_msg = "Could not save evaluation report."
  134 + logging.critical(error_msg)
  135 + if not os.path.exists(os.path.join(user_dir,"report")):
  136 + return render.error([error_msg], "/survey/","START")
137 137  
138 138 if web_input.has_key('continue_button'):
139 139 return Survey().POST()
... ...