Closed dexn closed 1 year ago
I cannot reproduce the exception:
What do you get if you call:
{"paused": false}
{"display_is_on": true}
Should be a valid Json object
Yes I get {"paused": false}
and {"display_is_on": true}
.
If I call ?paused=true
I get {"ERROR": "Excepton:paused><lambda>() missing 2 required positional arguments: 'x' and 'y';", "paused": true}
, which does pause the frame and calling ?paused
gives {"paused": true}
Calling ?display_is_on=false
I get {"ERROR": "Excepton:display_is_on><lambda>() missing 2 required positional arguments: 'x' and 'y';", "display_is_on": true}
, which pauses the frame but doesn't turn the display off. Calling ?display_is_on=false
gives {"display_is_on": true}
and ?paused
gives {"paused": true}
I tried turning on "Display Blanking" and setting display_power: 1
to see if that helped but didn't with the exact same error. Running xset -display :0 dpms force off
did turn the display off though. Running vcgencmd display_power 0
did so too.
I've turned off "Display Blanking" again and set it back to display_power: 0
.
The error is here
Reading the the parameters from the browser and storing the values. But I don't understand why there are arguments missing.
@paddywwoof do you have a hint for me?
I'll have a look. x and y don't sound relevant arguments for toggling on or off!
@dexn do you have mqqt enabled?
The setter is calling publish_state(), which is defined as
self.publish_state = lambda x, y: None
We should call it only if mqtt is enabled. Will test this.
I've also noticed that it isn't detecting it as a Pi.
@dexn the PLATFORM number 0 to indicate it's a Pi really means it's running the original Broadcom OpenGLES2 driver that worked without the X server running. 3 is really standard linux.
@helgeerbe Hmm I wonder if I remember a clash between mqqt and the http server before?
@dexn I see in your config, that mqtt is disabled. I turned it off in my configuration and can now reproduce the error. Fix should be easy.
Is this due to a recent change? I don't think I've ever set mqtt on. I'm not running the latest version of picframe on the wall in the kitchen. Time to upgrade it! Paddy
I put the error in the code in May 2022 #267
struggling to get to the point where I can see if I get the same error.
import typing
...
model: type[Model]
seems to generate an error to the effect that type is not sub-scriptable - but it is python 3.7... Oh well, only 188 packages to upgrade!
Hmm, I'm still on Buster on my RPi 3 with python 3.7.3 which I see is also the version on @dexn setup above (also still using picframe:2022.12.15
). However I can't get past the type[Model]
step in interface_peripherals.py
. Is there something else I need to do now? Is there a minimum version of python required (type[Model]
works ok on my desktop computer with python 3.10.6)? Is the 'standard' instruction not to use Buster but follow @thomasedoff instructions and go 'full fat' driver?
I put a patch on the dev branch, which should solve throwing the exception. @dexn are you able to install it from a git repository, for testing? I'm not sure, if this fix the 'not blanking the screen' error.
@paddywwoof 3.7.3 should work. As far as I know typ hints like the type[Model]
were introduced with python 3.5 and alos buster should be fine.
The setup from @dexn works.
Not sure what it is then. Certainly if I run the following with python 3.9 or 3.10 there's no error. But on python 3.7 I get the complaint about type[]. I notice that changes to the picframe file causing the crash for me were made after the version of picframe listed by @dexn
Paddy
import typing
class Test:
a: int
def __init__(self):
self.a = 0
class TestType:
b: type[Test]
def __init__(self, b: Test):
self.b = b
a_test = Test()
a_test_type = TestType(a_test)
error message
Traceback (most recent call last):
File "test_typing.py", line 8, in <module>
class TestType:
File "test_typing.py", line 9, in TestType
b: type[Test]
TypeError: 'type' object is not subscriptable
PS I noticed there was a typing_extensions module, which I tried
installing, but it didn't fix the error (though I'm not really sure how
it would disambiguate type[X]
from type(X)
Won't load for me either.
~/picframe $ sudo xinit /usr/bin/python3 /home/pi/picframe_data/run_start.py /home/pi/picframe_data/config/configuration.yaml
X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 5.4.0-109-generic armv8l Raspbian
Current Operating System: Linux maraframe 5.10.103-v7l+ #1529 SMP Tue Mar 8 12:24:00 GMT 2022 armv7l
Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 video=HDMI-A-1:1920x1080M@60 smsc95xx.macaddr=DC:A6:32:4B:A8:31 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=ttyS0,115200 console=tty1 root=PARTUUID=6f14799a-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
Build Date: 04 April 2023 07:50:56AM
xorg-server 2:1.20.4-1+rpt4+deb10u9 (https://www.debian.org/support)
Current version of pixman: 0.36.0
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Wed May 17 11:12:47 2023
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(II) modeset(0): Initializing kms color map for depth 24, 8 bpc.
INFO:start.py:starting ['/home/pi/picframe_data/run_start.py', '/home/pi/picframe_data/config/configuration.yaml']
INFO:model.Model:Open config file: /home/pi/picframe_data/config/configuration.yaml:
INFO:controller.Controller:creating an instance of Controller
Traceback (most recent call last):
File "/home/pi/picframe_data/run_start.py", line 2, in <module>
start.main()
File "/usr/local/lib/python3.7/dist-packages/picframe/start.py", line 136, in main
c.start()
File "/usr/local/lib/python3.7/dist-packages/picframe/controller.py", line 330, in start
from picframe.interface_peripherals import InterfacePeripherals
File "/usr/local/lib/python3.7/dist-packages/picframe/interface_peripherals.py", line 17, in <module>
class InterfacePeripherals:
File "/usr/local/lib/python3.7/dist-packages/picframe/interface_peripherals.py", line 29, in InterfacePeripherals
model: type[Model],
TypeError: 'type' object is not subscriptable
OK, I installed python 3.7 through miniconda and got the same error. Had to learn that the ability to use the [] operator on types for type hinting was added in 3.9. Wondering, why this wasn't observed before.
So I see two possibilities. We declare python 3.9 as minimum python release, or we remove the type hinting.
Btw. I played around to use sanic as new webserver, which also requires at least 3.9. sanic runs in a separate process, so one can use the other cores of the pi.
Not to mix up the issues, let us continue in #320 with the type error.
I published 2023.05.17. So no more exceptions should be thrown, if you toggle pause and display_on in the web interface. Can you test it. Don't know if this solve your not going blank problem.
Fixed
@helgeerbe As far as I can tell the 2023.05.17 version runs fine. Before upgrading I tried changing the type lines to model: Model
which runs OK and I could then replicate the OP exceptions for paused
and display_is_on
.
I think type hinting is generally a good thing in python but it's essentially a documentation/readability feature (python not really respecting types) so maybe just having model: Model
would be sufficient.
I did wonder about using the flask
web server when I set up the http interface but thought it wasn't needed if the access was always local and just one simple page. In the end there were a few things that needed patching up in javascript so it might have been better to use a more sophisticated server in the first place. After reading @jamespreedy comment on #320 about upgrading python this might be a bit of an imposition for people.
@paddywwoof you might be right. I did some tests, because I also tried to use vue, to get a more responsive web interface. But at the end, the old server seems to be fine enough.
When I click pause or display_is_on I get an exception in the log. It does pause for both but display_is_on won't turn the display off.
Checking required packages...... PIL : 9.5.0 pi3d : 2.49 yaml : 6.0 paho.mqtt : 1.6.1 iptcinfo3 : 2.1.4 numpy : 1.16.2 ninepatch : installed, but no version info pi_heif : 0.11.0 defusedxml : 0.7.1
I've also noticed that it isn't detecting it as a Pi.