@@ -110,9 +110,9 @@ def display_bitmap(epd, filename):
110110 for b in range (8 ):
111111 if (rowdata [col ] & (0x80 >> b ) != 0 and blkpixel == 0 ) or (
112112 rowdata [col ] & (0x80 >> b ) == 0 and blkpixel == 1 ):
113- epd .pixel (col * 8 + b , row , Adafruit_EPD .BLACK )
114- except OSError :
115- display_message ("Error: couldn't read file " + filename )
113+ epd .pixel (col * 8 + b , row , Adafruit_EPD .BLACK )
114+ except ( ValueError ) as e :
115+ display_message ("Error: " + e . args [ 0 ] )
116116 except BMPError :
117117 display_message ("Error: unsupported BMP file " + filename )
118118 finally :
@@ -181,8 +181,8 @@ def show_files():
181181 display .display ()
182182 print ("done" )
183183 time .sleep (5 )
184- except ( ValueError , Exception ) as e :
185- display_message ("Error: " + file + " " + e . args [ 0 ] )
184+ except OSError :
185+ display_message ("Error: Couldn't display file " + file )
186186 led .value = False
187187 return
188188
@@ -219,7 +219,7 @@ def run_job(jobfile):
219219 try :
220220 out = open (config ["asgfolder" ] + "/asg" + job ["image" ], mode = "wb" )
221221 print ("writing to file asg" + job ["image" ])
222- except (OSError , Exception ):
222+ except (OSError ):
223223 # readonly filesystem, do not create file
224224 createfile = False
225225 if createfile : # == True
@@ -286,35 +286,35 @@ def run_job(jobfile):
286286 ) or (
287287 image [x - panelwidth // 2 , y ] == 0 and inv )
288288 )):
289- # offset = 4
290- if job ["imagegrayscale" ] == 0 :
291- offset = job ["imageheight" ]
292- else :
293- offset = (
294- image [x - panelwidth // 2 , y ]
295- * job ["grayscalecolors" ]
296- // 255
297- )
289+ # offset = 4
290+ if job ["imagegrayscale" ] == 0 :
291+ offset = job ["imageheight" ]
292+ else :
293+ offset = (
294+ image [x - panelwidth // 2 , y ]
295+ * job ["grayscalecolors" ]
296+ // 255
297+ )
298298 if offset != 0 :
299299 for x2 in range (x , display .width , panelwidth ):
300300 tcanvas [x2 ] = tcanvas [x2 + offset ]
301- for x in range (0 , display .width ):
301+ for x3 in range (0 , display .width ):
302302 # write line to eink display
303- if tcanvas [x ] != 0 :
304- display .pixel (x , y , Adafruit_EPD .BLACK )
303+ if tcanvas [x3 ] != 0 :
304+ display .pixel (x3 , y , Adafruit_EPD .BLACK )
305305 # else:
306306 # display.pixel(x,y,Adafruit_EPD.WHITE)
307307 if createfile :
308308 count = 0
309- for x in range (0 , display .width + 7 , 8 ):
309+ for x4 in range (0 , display .width + 7 , 8 ):
310310 value = 0
311311 for b in range (8 ):
312- value |= (tcanvas [x + b ] << 7 ) >> b
312+ value |= (tcanvas [x4 + b ] << 7 ) >> b
313313 out .write (bytes ([value ]))
314314 count += 1
315315 # add padding to end of line
316316 padding = (4 - (count % 4 )) % 4
317- for x in range (padding ):
317+ for x4 in range (padding ):
318318 out .write (bytes ([0 ]))
319319 if createfile :
320320 out .close ()
@@ -325,7 +325,7 @@ def run_job(jobfile):
325325 print ("updating display" )
326326 display .display ()
327327 print ("done" )
328- except (ValueError , Exception ) as e :
328+ except (ValueError ) as e :
329329 display_message ("Error: " + e .args [0 ])
330330 led .value = False
331331 return
0 commit comments