pimoroni / breakout-garden

Documentation, software, and examples for the Breakout Garden ecosystem.
https://shop.pimoroni.com/products/breakout-garden-hat
MIT License
70 stars 13 forks source link

weather example open icons #16

Closed jorgevinagre closed 5 years ago

jorgevinagre commented 5 years ago

Hi

I´ve changed the weather example to use bm280, instead of bme680. Yet I have an error when opening the icons file:

Traceback (most recent call last): File "weather_bmp280.py", line 100, in icon_image = Image.open(f) File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2319, in open prefix = fp.read(16) File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

Is there something wrong with the files? Is there any optional parameter on the objects used that I can change?

Thanks

jorgevinagre commented 5 years ago

Hi again I solved my own problem: Now I load the image directly from disk, instead of call open first

icon_file_name = icon.split("/")[1]
    icon_name = icon.split("/")[1].replace(".png", "")
    # Here get abs path for file
    img_path = os.path.abspath(os.path.join(os.path.dirname(__file__),'icons', icon_file_name))
    # open from path
    icon_image = Image.open(img_path)
    icons[icon_name] = icon_image

Also initialized BeautifulSoup with "html.parser" because I didnt´t had lxml installed

Now ir working fine Nice sample