vesposito/easyucs

Bug: AttributeError: 'ImageDraw' object has no attribute 'textsize'

Closed this issue · 4 comments

I am running in an AttributeError everytime I try to generate a report:
python easyucs.py report generate -t ucsm -i 10.0.0.1 -u admin -p C1sco4L1fe -o output/reports

MacOS: 14.0 (23A344)
EasyUCS: 0.9.8.5
Python (venv): 3.8.16, 3.10.6
UCS Manager: 4.2(2d), 4.2(2aS9)

2023-09-27 13:38:59,693 :: INFO :: 10.0.0.1:: manager.py :: in export_inventory :: Exporting inventory 668d2f79-bd06-4859-9cf2-1eb34e9543590 to file: output/reports/inventory_10.0.0.1.json
2023-09-27 13:38:59,707 :: INFO :: 10.0.0.1:: manager.py :: in export_config :: Exporting config 57191a45-f95e-49c0-ad91-1eb34e9543590 to file: output/reports/config_10.0.0.1.json
Traceback (most recent call last):
  File "easyucs.py", line 883, in <module>
    main()
  File "easyucs.py", line 876, in main
    init_process(device, args, json_string)
  File "easyucs.py", line 336, in init_process
    device.inventory_manager.draw_inventory()
  File "/Users/max/git/easyucs/inventory/ucs/manager.py", line 137, in draw_inventory
    UcsSystemDrawInfraServiceProfile(draw_chassis_front_list=chassis_front_draw_list,
  File "/Users/max/git/easyucs/draw/ucs/service_profile.py", line 90, in __init__
    self.font_size_name = self._max_length_sp_name()
  File "/Users/max/git/easyucs/draw/ucs/service_profile.py", line 228, in _max_length_sp_name
    while self.draw.textsize(max_name, font=font)[0] > min_length_equipment:
AttributeError: 'ImageDraw' object has no attribute 'textsize'

I've tried multiple UCS-Manager instances with different versions.
I've tried multiple python versions.

Workaround:
use Pillow==8.4 instead of Pillow>=7.1.2 in the requirements.txt.
Latest version from Pillow is 10.x which is not working for me.
I have not tested Pillow 9.x

Looks like textsize was deprecated in Pillow 10.x, the new attribute is textlength which gives the width of the text.
As a simple workaround for now we should indeed use a Pillow version lower than 10.x.

I have applied the workaround in the requirements file in v0.9.8.6.
Will look at replacing the use of textsize in a future release

This is fixed since v0.9.8.7