@@ -128,7 +128,7 @@ class HandlerError:
128128def application (environ , start_response ):
129129 try :
130130 (status , c_type , output ) = handler (environ )
131- except HandlerError , exc :
131+ except HandlerError as exc :
132132 status = exc .status
133133 output = exc .output
134134 c_type = 'text/plain'
@@ -138,7 +138,7 @@ def application(environ, start_response):
138138 status = '500 Internal Server Error'
139139 output = '' .join (lines )
140140 c_type = 'text/plain'
141- response_headers = [('Content-Type' , c_type ),
141+ response_headers = [('Content-Type' , c_type ),
142142 ('Content-Length' , str (len (output )))]
143143 if c_type == 'image/nifti' :
144144 response_headers .append (('Content-Disposition' , 'attachment; filename=image.nii' ))
@@ -191,12 +191,12 @@ def patient_date_time(patient, date_time):
191191 for s in studies_getter ():
192192 if s .patient_name_or_uid () != patient :
193193 continue
194- if date_time != '%s_%s' % (s .date , s .time ):
194+ if date_time != '{}_{}' . format (s .date , s .time ):
195195 continue
196196 study = s
197197 break
198198 if study is None :
199- raise HandlerError , ('404 Not Found' , 'study not found' )
199+ raise HandlerError ('404 Not Found' , 'study not found' )
200200 template = template_env .from_string (patient_date_time_template )
201201 return template .render (study = study ).encode ('utf-8' )
202202
@@ -205,41 +205,41 @@ def nifti(patient, date_time, scan):
205205 for s in studies_getter ():
206206 if s .patient_name_or_uid () != patient :
207207 continue
208- if date_time != '%s_%s' % (s .date , s .time ):
208+ if date_time != '{}_{}' . format (s .date , s .time ):
209209 continue
210210 study = s
211211 break
212212 if study is None :
213- raise HandlerError , ('404 Not Found' , 'study not found' )
213+ raise HandlerError ('404 Not Found' , 'study not found' )
214214 ser = None
215215 for series in s .series :
216216 if series .number != scan :
217217 continue
218218 ser = series
219219 break
220220 if ser is None :
221- raise HandlerError , ('404 Not Found' , 'series not found' )
221+ raise HandlerError ('404 Not Found' , 'series not found' )
222222 return ser .as_nifti ()
223223
224224def png (patient , date_time , scan ):
225225 study = None
226226 for s in studies_getter ():
227227 if s .patient_name_or_uid () != patient :
228228 continue
229- if date_time != '%s_%s' % (s .date , s .time ):
229+ if date_time != '{}_{}' . format (s .date , s .time ):
230230 continue
231231 study = s
232232 break
233233 if study is None :
234- raise HandlerError , ('404 Not Found' , 'study not found' )
234+ raise HandlerError ('404 Not Found' , 'study not found' )
235235 ser = None
236236 for series in s .series :
237237 if series .number != scan :
238238 continue
239239 ser = series
240240 break
241241 if ser is None :
242- raise HandlerError , ('404 Not Found' , 'series not found' )
242+ raise HandlerError ('404 Not Found' , 'series not found' )
243243 index = len (ser .storage_instances ) / 2
244244 return ser .as_png (index , True )
245245
0 commit comments