Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: AttributeError: 'Settings' object has no attribute 'image_folder' #357

Closed
Zer0great opened this issue Jul 4, 2024 · 8 comments · Fixed by #358
Closed

[BUG]: AttributeError: 'Settings' object has no attribute 'image_folder' #357

Zer0great opened this issue Jul 4, 2024 · 8 comments · Fixed by #358
Assignees
Labels
bug Something isn't working Current Release! Related to the most recent (public) release

Comments

@Zer0great
Copy link

Zer0great commented Jul 4, 2024

Hello, since about last week Inkycal is not working for me. Tried deleting whole Inkycal folder and redownloading with no success. Tried some steps to fix it, but I am obviously not competent to find a solution, as each step creates another problem for me.

RPi 4 8GB
Debian GNU/Linux 12 (bookworm)
E-paper display: 10_in_3
Was working until about 27.6., but I am unable to confirm whether it was broken by os update (apt update) or Inkycal update. I have attempted to download older release of Inkycal with git and I am not sure I am doing it correctly, but it behave the same. That would point in direction of OS update, but I do not know if that can cause error "AttributeError: 'Settings' object has no attribute 'image_folder'" in main.py

  1. first error is AttributeError: 'Settings' object has no attribute 'image_folder'.
04-07-2024 10:47:20 | inkycal.main |  INFO: Inkycal v2.0.4 booting up...
04-07-2024 10:47:20 | inkycal.main |  INFO: Checking if a settings file is present...
04-07-2024 10:47:20 | inkycal.main |  INFO: Looking for settings.json file in /boot folder...
04-07-2024 10:47:20 | inkycal.custom.openweathermap_wrapper |  INFO: OWM wrapper initialized for API version 2.5, language cs and timezone Europe/Prague.
04-07-2024 10:47:20 | inkycal.main |  INFO: name : Weather size : 1404x300 px
04-07-2024 10:47:20 | inkycal.main |  INFO: name : Calendar size : 1404x950 px
04-07-2024 10:47:20 | inkycal.main |  INFO: name : Slideshow size : 1404x622 px
04-07-2024 10:47:20 | inkycal.main |  INFO: Inkycal initialised successfully!
04-07-2024 10:47:20 | inkycal.main |  INFO: Inkycal version: v2.0.4
04-07-2024 10:47:20 | inkycal.main |  INFO: Selected E-paper display: 10_in_3
04-07-2024 10:47:20 | inkycal.main |  INFO: Starting new cycle...
04-07-2024 10:47:20 | inkycal.main |  INFO: Timestamp: 10:47:20 04.07.2024
04-07-2024 10:47:21 | inkycal.custom.openweathermap_wrapper |  INFO: OpenWeatherMap response did not contain a wind gust speed. Using base wind: 9.26 m/s.
04-07-2024 10:47:25 | inkycal.modules.ical_parser |  INFO: loaded iCalendars from URLs
slideshow - current image name: DSC03619B.jpg
04-07-2024 10:47:26 | inkycal.modules.inky_image |  INFO: loading image from local path
04-07-2024 10:47:27 | inkycal.modules.inky_image |  INFO: loaded Image
04-07-2024 10:47:28 | inkycal.modules.inky_image |  INFO: resized image from 5860 to 1404
04-07-2024 10:47:28 | inkycal.modules.inky_image |  INFO: resized image from 935 to 622
04-07-2024 10:47:28 | inkycal.modules.inky_image |  INFO: mapped image to specified palette
04-07-2024 10:47:28 | inkycal.modules.inky_image |  INFO: cleared previous image
04-07-2024 10:47:28 | inkycal.main |  INFO: All images generated successfully!
04-07-2024 10:47:29 | inkycal.main |  INFO: Attempting to render image on display...
Traceback (most recent call last):
  File "/home/berry/Inkycal/inky_run.py", line 43, in <module>
    asyncio.run(run())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/berry/Inkycal/inky_run.py", line 20, in run
    await inky.run()  # If there were no issues, you can run Inkycal nonstop
    ^^^^^^^^^^^^^^^^
  File "/home/berry/Inkycal/inkycal/main.py", line 375, in run
    im_black = self._merge_bands()
               ^^^^^^^^^^^^^^^^^^^
  File "/home/berry/Inkycal/inkycal/main.py", line 418, in _merge_bands
    im1_path = os.path.join(settings.image_folder, "canvas.png")
                            ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Settings' object has no attribute 'image_folder'
  1. I have looked into main.py and all settings.IMAGE_FOLDER are upper case and the one on line 418 was lower case, so I tried to change it to upper case. This moves bit further. But ends in "FileNotFoundError: Inkycal cannot find images to merge". main.py should be trying to open canvas.png and canvas_colour.png , however those files do not exist in Inkycal/image_folder, there is only full-screen.png
Traceback (most recent call last):
  File "/home/berry/Inkycal/inky_run.py", line 43, in <module>
    asyncio.run(run())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/berry/Inkycal/inky_run.py", line 20, in run
    await inky.run()  # If there were no issues, you can run Inkycal nonstop
    ^^^^^^^^^^^^^^^^
  File "/home/berry/Inkycal/inkycal/main.py", line 375, in run
    im_black = self._merge_bands()
               ^^^^^^^^^^^^^^^^^^^
  File "/home/berry/Inkycal/inkycal/main.py", line 434, in _merge_bands
    raise FileNotFoundError("Inkycal cannot find images to merge")
FileNotFoundError: Inkycal cannot find images to merge
  1. so I tried to make two duplicates of full-screen.png named canvas.png and canvas_colour.png, to see what happens. This gives error /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd: command not found
    This is, because it is looking for the display/drivers/ folder inside /home/berry/Inkycal/inkycal/inkycal... there is one too many "inkycal" folder in the path for some reason.
    So I tried to copy the display folder from /home/berry/Inkycal/inkycal/ to /home/berry/Inkycal/inkycal/inkycal/

Initialising..Updating display......sudo /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd -2.0 0 /home/berry/Inkycal/inkycal/../image_foldercanvas.bmp
sudo: /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd: command not found
Done
Sending E-Paper to deep sleep...Done
``
4) that seemingly make it work, but display is empty, probably because file /home/berry/Inkycal/inkycal/../image_foldercanvas.bmp does not exist

Initialising..Updating display......sudo /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd -2.0 0 /home/berry/Inkycal/inkycal/../image_foldercanvas.bmp
/***********************************/
bcm2835 init success !!!
/***********************************/
VCOM value:2000
Display mode:0
Panel(W,H) = (1872,1404)
Memory Address = 119F00
FW Version = SWv_0.1.
LUT Version = M841_TFA5210
VCOM = -2.00V
A2 Mode:6
Set image Rotate 0
mirror image x:none, y:none
Loading image from file
Set image Rotate 0
mirror image x:none, y:none
Done
Sending E-Paper to deep sleep...Done
  1. creating the file manually (converting image_foldercanvas.png to bmw a putting it in the correct path) does not change anything

Regards
Martin

@aceisace aceisace self-assigned this Jul 4, 2024
@aceisace aceisace changed the title Inkycal not working since last week AttributeError: 'Settings' object has no attribute 'image_folder' [BUG]: AttributeError: 'Settings' object has no attribute 'image_folder' Jul 4, 2024
@aceisace aceisace added bug Something isn't working Current Release! Related to the most recent (public) release labels Jul 4, 2024
@aceisace
Copy link
Member

aceisace commented Jul 4, 2024

Hi there Martin,
thank you very much for reporting this issue. This will require a hot-fix and I'll get started right away. Thank you also for writing up what went wrong and for the traceback. It helps a lot with debugging!

@aceisace
Copy link
Member

aceisace commented Jul 4, 2024

@Zer0great I've got a fix ready for this and would like you test it before I attempt to merge it.
Please run the following commands, line by line in a Terminal:

cd ~/Inkycal
source venv/bin/activate
git pull
git checkout hotfix/#357
python inky_run.py

That should fix the issue and it does work on my end. However, as you are using a parallel display and I currently don't have access to one, I'm relying on your help to test this out.

@Zer0great
Copy link
Author

Zer0great commented Jul 5, 2024

Hello @aceisace ,
I am trying the hotfix just now. I did reinstall if Inkycal before, to start with clean slate.
It is better, the first errors are not present.

  1. Running it straight away gives the error with display driver (this was point 3 in original post)
    sudo: /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd: command not found
    as there is one /inkycal too many in the path

full run log:

05-07-2024 09:21:07 | inkycal.main |  INFO: Inkycal v2.0.4 booting up...
05-07-2024 09:21:07 | inkycal.main |  INFO: Checking if a settings file is present...
05-07-2024 09:21:07 | inkycal.main |  INFO: Looking for settings.json file in /boot folder...
05-07-2024 09:21:07 | inkycal.custom.openweathermap_wrapper |  INFO: OWM wrapper initialized for API version 2.5, language cs and timezone Europe/Prague.
05-07-2024 09:21:07 | inkycal.main |  INFO: name : Weather size : 1404x300 px
05-07-2024 09:21:07 | inkycal.main |  INFO: name : Calendar size : 1404x950 px
05-07-2024 09:21:07 | inkycal.main |  INFO: name : Slideshow size : 1404x622 px
05-07-2024 09:21:07 | inkycal.main |  INFO: Inkycal initialised successfully!
05-07-2024 09:21:07 | inkycal.main |  INFO: Inkycal version: v2.0.4
05-07-2024 09:21:07 | inkycal.main |  INFO: Selected E-paper display: 10_in_3
05-07-2024 09:21:07 | inkycal.main |  INFO: Starting new cycle...
05-07-2024 09:21:07 | inkycal.main |  INFO: Timestamp: 09:21:07 05.07.2024
05-07-2024 09:21:07 | inkycal.custom.openweathermap_wrapper |  INFO: OpenWeatherMap response did not contain a wind gust speed. Using base wind: 6.69 m/s.
05-07-2024 09:21:12 | inkycal.modules.ical_parser |  INFO: loaded iCalendars from URLs
slideshow - current image name: DSC03619B.jpg
05-07-2024 09:21:12 | inkycal.modules.inky_image |  INFO: loading image from local path
05-07-2024 09:21:13 | inkycal.modules.inky_image |  INFO: loaded Image
05-07-2024 09:21:14 | inkycal.modules.inky_image |  INFO: resized image from 5860 to 1404
05-07-2024 09:21:14 | inkycal.modules.inky_image |  INFO: resized image from 935 to 622
05-07-2024 09:21:14 | inkycal.modules.inky_image |  INFO: mapped image to specified palette
05-07-2024 09:21:14 | inkycal.modules.inky_image |  INFO: cleared previous image
05-07-2024 09:21:14 | inkycal.main |  INFO: All images generated successfully!
05-07-2024 09:21:16 | inkycal.main |  INFO: Attempting to render image on display...
05-07-2024 09:21:16 | inkycal.modules.inky_image |  INFO: merged given images into one
Initialising..Updating display......sudo /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd -2.0 0 /home/berry/Inkycal/inkycal/../image_foldercanvas.bmp
sudo: /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd: command not found
Done
Sending E-Paper to deep sleep...Done
05-07-2024 09:21:16 | inkycal.main |  INFO:
No errors since 1 display updates
05-07-2024 09:21:16 | inkycal.main |  INFO: program started just now
39 minutes left until next refresh
  1. So I try to duplicate the folder so the path is correct:
    /home/berry/Inkycal/inkycal/display/
    to
    /home/berry/Inkycal/inkycal/inkycal/display/

This seemingly runs Inkycal with no problem, the display blinks few times, but remains blank. I think the problem is there is no file "image_foldercanvas.bmp" present in Inkycal folder and subfolders.
I have:

/home/berry/Inkycal/image_folder/canvas.bmp
/home/berry/Inkycal/image_folder/canvas.png
/home/berry/Inkycal/image_folder/canvas_colour.png
/home/berry/Inkycal/image_foldercanvas_colour.png
/home/berry/Inkycal/image_foldercanvas.png

But no image_foldercanvas.bmp

run log

(venv) berry@inkycal:~/Inkycal $ python inky_run.py
05-07-2024 09:27:37 | inkycal.main |  INFO: Inkycal v2.0.4 booting up...
05-07-2024 09:27:37 | inkycal.main |  INFO: Checking if a settings file is present...
05-07-2024 09:27:37 | inkycal.main |  INFO: Looking for settings.json file in /boot folder...
05-07-2024 09:27:37 | inkycal.custom.openweathermap_wrapper |  INFO: OWM wrapper initialized for API version 2.5, language cs and timezone Europe/Prague.
05-07-2024 09:27:37 | inkycal.main |  INFO: name : Weather size : 1404x300 px
05-07-2024 09:27:37 | inkycal.main |  INFO: name : Calendar size : 1404x950 px
05-07-2024 09:27:37 | inkycal.main |  INFO: name : Slideshow size : 1404x622 px
05-07-2024 09:27:37 | inkycal.main |  INFO: Inkycal initialised successfully!
05-07-2024 09:27:37 | inkycal.main |  INFO: Inkycal version: v2.0.4
05-07-2024 09:27:37 | inkycal.main |  INFO: Selected E-paper display: 10_in_3
05-07-2024 09:27:37 | inkycal.main |  INFO: Starting new cycle...
05-07-2024 09:27:37 | inkycal.main |  INFO: Timestamp: 09:27:37 05.07.2024
05-07-2024 09:27:38 | inkycal.custom.openweathermap_wrapper |  INFO: OpenWeatherMap response did not contain a wind gust speed. Using base wind: 6.69 m/s.
05-07-2024 09:27:43 | inkycal.modules.ical_parser |  INFO: loaded iCalendars from URLs
slideshow - current image name: DSC03619B.jpg
05-07-2024 09:27:44 | inkycal.modules.inky_image |  INFO: loading image from local path
05-07-2024 09:27:44 | inkycal.modules.inky_image |  INFO: loaded Image
05-07-2024 09:27:45 | inkycal.modules.inky_image |  INFO: resized image from 5860 to 1404
05-07-2024 09:27:45 | inkycal.modules.inky_image |  INFO: resized image from 935 to 622
05-07-2024 09:27:45 | inkycal.modules.inky_image |  INFO: mapped image to specified palette
05-07-2024 09:27:45 | inkycal.modules.inky_image |  INFO: cleared previous image
05-07-2024 09:27:45 | inkycal.main |  INFO: All images generated successfully!
05-07-2024 09:27:47 | inkycal.main |  INFO: Attempting to render image on display...
05-07-2024 09:27:47 | inkycal.modules.inky_image |  INFO: merged given images into one
Initialising..Updating display......sudo /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd -2.0 0 /home/berry/Inkycal/inkycal/../image_foldercanvas.bmp
/***********************************/
bcm2835 init success !!!
/***********************************/
VCOM value:2000
Display mode:0
Panel(W,H) = (1872,1404)
Memory Address = 119F00
FW Version = SWv_0.1.
LUT Version = M841_TFA5210
VCOM = -2.00V
A2 Mode:6
Set image Rotate 0
mirror image x:none, y:none
Loading image from file
Set image Rotate 0
mirror image x:none, y:none
Done
Sending E-Paper to deep sleep...Done
05-07-2024 09:28:16 | inkycal.main |  INFO:
No errors since 2 display updates
05-07-2024 09:28:16 | inkycal.main |  INFO: program started 39 seconds ago
32 minutes left until next refresh
  1. So last thing I tried was running manually the command to display the file "canvas.bmp", this successfully displayed today's image. So it does gets rendered, but the paths are wrong.
sudo /home/berry/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd -2.0 0 /home/berry/Inkycal/image_folder/canvas.bmp

All in all I see two relatively simple problems now:
-wrong path to the display driver somewhere
is $HOME/Inkycal/inkycal/inkycal/display/drivers/parallel_drivers/epd
should be $HOME/Inkycal/inkycal/display/drivers/parallel_drivers/epd

-wrong final file name and path being generated or used in script or missing some step to copy or rename the file.
Inkycal is expecting the file to be $HOME/Inkycal/inkycal/../image_foldercanvas.bmp - such file does not exist
When in reality the file is in $HOME/Inkycal/image_folder/canvas.bmp - this can be used to get the desired display output

Thank you
Regards
Martin

@aceisace
Copy link
Member

aceisace commented Jul 5, 2024

Thanks for testing and for the detailed report @Zer0great . I've just pushed the change that should fix this too.
I was trying to remove hardcoded variables in the settings.py file, it seems some things were not working correctly for the parallel displays.
Please run the following and let me know if it works now:

cd ~/Inkycal
source venv/bin/activate
git pull
# I'm assuming you're still on the hotfix/#357 branch
python inky_run.py

@Zer0great
Copy link
Author

Zer0great commented Jul 5, 2024

We are getting there, @aceisace , looks like just one final step remains :-)
This time no problem with display driver location, the script is running it from correct location.

Initialising..Updating display......sudo /home/berry/Inkycal/inkycal/display/drivers/parallel_drivers/epd -2.0 0 /home/berry/Inkycal/inkycal/../image_foldercanvas.bmp

However there is still problem with the BMP file location.
The script is searching for file

/home/berry/Inkycal/inkycal/../image_foldercanvas.bmp

but such file does not exist, so it produces just blank display.

I think the correct path is

$HOME/Inkycal/image_folder/canvas.bmp

as this file exists and I can verify by its time stamp, it is generated during Inkycal run.

Manually running this command renders the picture on display correctly for me:

sudo /home/berry/Inkycal/inkycal/display/drivers/parallel_drivers/epd -2.0 0 /home/berry/Inkycal/inkycal/../image_folder/canvas.bmp

Regards
Martin

@aceisace
Copy link
Member

aceisace commented Jul 5, 2024

Thanks for testing, just pushed that fix too:

cd ~/Inkycal
source venv/bin/activate
git pull
# Still assuming you're on the hotfix/#357 branch
python inky_run.py

@Zer0great
Copy link
Author

Tried it just now and looks like all problems are fixed and Inkycal runs again, as it should.
Did not notice any other/new problems after the hotfix.

Thank you
Martin

@aceisace
Copy link
Member

aceisace commented Jul 5, 2024

Glad to hear that and happy to help! Thank you very much for your quick and detailed testing too Martin!
I'll have this merged into main so it will be official very soon

@aceisace aceisace linked a pull request Jul 5, 2024 that will close this issue
aceisace added a commit that referenced this issue Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Current Release! Related to the most recent (public) release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants