TeamScheire / familiekiosk

Bouwplannen en uitleg om zelf een fotokanaal te maken, net zoals Maria in het RVT
https://www.canvas.be/team-scheire/maria-wil-meer-contact-met-haar-familie
Apache License 2.0
10 stars 4 forks source link

familiekiosk on python 3.7 #13

Closed janvangent closed 4 years ago

janvangent commented 4 years ago

The familiekiosk doesn't seem to be working anymore on a clean install with raspbian strecht or buster (tried both). This is the case for when running both python 2.7 or 3.7 by the way.

In an attempt to get it up& running again, it probably makes sense to start with Raspbian buster and python 3.7 (to be up to date).

First remark: all instances of ConfigParser should be changed to configparser in FK_Chatbot.py Without this change the service won't even start.

Once this is done, and the service is up and running, I get these errors when sending a picture through telegram: image

There is also an issue with FK_tvbox.py. When this service is started upon boot, it throws an error: image If started manually, it does seem to work

I believe there is quite some rework to be done to get it up and running on new installs... But i'm lacking experience to get this done.

bmcage commented 4 years ago

Ok, the service FK_tvbox.py needs to start after display is present. That seems to be no longer the case, so a matter of finding the correct time to launch it.

The error in chatbox is strange, as it is in a default library. To test, add .encode() to strftime output. Eg change on https://github.com/TeamScheire/familiekiosk/blob/master/src/picturehandler.py#L55

message.date.strftime('%Y-%m-%d %H:%M:%S')

into

message.date.strftime('%Y-%m-%d %H:%M:%S').encode()

Search on other strftime to do the same. Test in python 3.7:

>>> import datatime as dt
>>> test = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
>>> test
'2020-05-08 15:31:38'
>>> type(test)
<class 'str'>
>>> test2 = test.encode()
>>> type(test2)
<class 'bytes'>
bmcage commented 4 years ago

For the service error, I see buster uses wayland, not xorg https://www.debian.org/releases/stable/amd64/release-notes/ch-information.en.html#apps-in-gnome-on-wayland

We are assuming xorg stuff: https://github.com/TeamScheire/familiekiosk/blob/master/systemd/fk_tvbox.service#L7

Limited info at the moment what this means https://www.raspberrypi.org/documentation/linux/usage/systemd.md Try with

[Unit]
 Description=Family Kiosk System
 After=multi-user.target
 After=graphical.target

[Service]
 Type=idle
 ExecStart=/usr/bin/python /home/pi/familiekiosk/src/FK_TVbox.py > /home/pi/familiekiosk/output_TVbox.log 2>&1

If not working, try adding back in in the Service section

Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/pi/.Xauthority"
janvangent commented 4 years ago

I tried changing to add .encode, but without any luck. When I want to test it as you suggest: image

Result when sending picture: image

bmcage commented 4 years ago

Ok, best if I try to fix these issues with an updated raspberry pi.

For the test, it is import datetime, not datatime, I copied a wrong line in my example.

ErwinP commented 4 years ago

Hi all,

I just got FK_Chatbox and FK_TVbox, hopefully with all their dependencies, working on python 3.6 and python-telegram-bot v12.7 (fresh Rasbian install from ~3 months ago).

https://github.com/ErwinP/familiekiosk/commit/b6e45f8352aa1d739cd020c1e6b71191b4444a22 https://github.com/ErwinP/familiekiosk/commit/5d365a6cee01674a997e4608585ff8f041aa357c

The latest comment of Jan is fixed by opening the metafile in "w" mode, instead of "wb" mode. The b stands for bytes, whilst it indeed does try to write out strings.

I did this on a headless Raspberry Pi setup, which is not supposed to run Familiekiosk. Hence, I haven't checked how it behaves when started as a service on boot, nor how it reacts on button presses. I can report that when FK_Chatbox and FK_TVbox running, my chatbot is responsive, parses images and displays them on the screen (tested by porting the X-display over ssh).

Hope this helps! Erwin

Sn1ckerson commented 4 years ago

Hi all, Beginner programmer here. I receive the same error messages even when started up manually (after running "systemctl status fk_chatbot.service"). I was trying to implement the fix bmcage suggested and pressed the run button in FK_chatbot.py (just for fun) which gave me the following error:

Traceback (most recent call last): File "/home/pi/familiekiosk/src/FK_ChatBot.py", line 30, in from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters, Job, BaseFilter) ModuleNotFoundError: No module named 'telegram'

I followed all the steps as explained in the manual but it seems that I don't have telegram installed? Is this an error because of the way I ran the file or did I miss something? I thought the command telegram python API:sudo pip install python-telegram-bot --upgrade`` would install this?

ErwinP commented 4 years ago

Hi,

Indeed, that command should have installed it. Can you provide us with the output of $ python -m telegram , to double check if it has been installed?

Secondly, which python version are you on? You can check that with $ python --version.

Regards, Erwin

bmcage commented 4 years ago

@ErwinP Can you do a pull request for changing wb in w where needed? I would drop the python2 support, almost end of life

bmcage commented 4 years ago

@ErwinP I see you have it in your PR in #7
I'll comment there

bmcage commented 4 years ago

fixed with merge of #7