gjr80 / weewx-stackedwindrose

A WeeWX extension to generate a polar windrose graphic
GNU General Public License v3.0
11 stars 2 forks source link

AttributeError running Under Pillow 10.0.0 #7

Closed N1OTX closed 11 months ago

N1OTX commented 1 year ago

Pillow 10.0.0 was Released on Jul 1, 2023 It contains some Backwards Incompatible Changes, including at least one which seems to affect Stacked Windrose Image Generator extension. The Font size method ImageDraw.textsize() was removed. Details from Pillow 10.0.0 Release Notes Font size and offset methods

Brief log showing error:

Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: Caught unrecoverable exception in generator 'user.stackedwindrose.StackedWindRoseImageGenerator' Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: type object 'ImageDraw' has no attribute 'textsize' Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: Traceback (most recent call last): Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: File "/home/panders/weewx-venv/lib/python3.11/site-packages/weewx/reportengine.py", line 196, in run Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: obj.start() Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: File "/home/panders/weewx-venv/lib/python3.11/site-packages/weewx/reportengine.py", line 384, in start Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: self.run() Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: File "/home/panders/weewx-data/bin/user/stackedwindrose.py", line 231, in run Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: self.gen_images(self.gen_ts) Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: File "/home/panders/weewx-data/bin/user/stackedwindrose.py", line 452, in gen_images Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: text_w, text_h = self.draw.textsize("0 (100%)", Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: File "/home/panders/weewx-data/bin/user/stackedwindrose.py", line 840, in textsize Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: ** return ImageDraw.ImageDraw.textsize(self, string, options) Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: AttributeError: type object 'ImageDraw' has no attribute 'textsize' Jul 02 12:20:18 rpi4dev python3[6011]: weewx[6011] ERROR weewx.reportengine: **** Generator terminated

Paul

gjr80 commented 1 year ago

Thanks, I fixed that last week but it seems that in doing so I introduced a regression error on systems using PIL < 10.0. I think I have fixed that one now, well at least it is running error free on my on-line system that uses PIL 8.something. I have tested on PIL 10.0, but it was a rather cursory test as I am away from home.

If you want to give the updated version a go you can download it with:

wget https://raw.githubusercontent.com/gjr80/weewx-saratoga/PIL_10/bin/user/stackedwindrose.py

The file is in another repo as the stacked windrose generator is also included in the weewx-saratoga extension (I need to remove that duplication). All you need do is download the updated stackedwindrose.py and replace the old version in /home/panders/weewx-data/bin/user/ and of course restart WeeWX.

Would appreciate feedback on the updated version.

N1OTX commented 1 year ago

Thank you very much for your speedy response, and immediate fix for the issue. Tested the updated Version: 3.0.2 Date: 6 July 2023 that you provided. It runs fine with Pillow 9.5.0 and 10.0.0.

Paul