Run python script in CE

I tried to run a python script which asks username/password via /storage/.config/autostart.sh but after reboot I don’t see username prompt of the script. Script don’t use any graphic libraries - only text. When I run it via ssh session it runs successfully.

after adding line

sleep 20

before running python script in /storage/.config/autostart.sh I saw the following in log:

# journalctl -u kodi-autostart -l --no-pager
-- Logs begin at Thu 2015-01-01 00:00:13 UTC, end at Wed 2022-02-09 14:23:58 UTC. --
Jan 01 00:00:16 NODE-1 systemd[1]: Starting Kodi user autostart script...
Jan 01 00:00:16 NODE-1 systemd[1]: Started Kodi user autostart script.
Feb 09 14:23:51 NODE-1 sh[2835]: Username: 
Feb 09 14:23:51 NODE-1 sh[2835]: Enter password:

But I still can’t see username prompt on TV set, it occurred only in log.

No idea what you are trying but autostart.sh is run in shell not in Mediacenter.

You can try with this in autostart.sh

(
echo 1 > /sys/class/vtconsole/vtcon1/bind
python your_script.py > /dev/tty0 < /dev/tty0
echo 0 > /sys/class/vtconsole/vtcon1/bind
)

I want to run python authentication script which will be visible in Mediacenter or shell. But I think it will more difficult realize it for Mediacenter because maybe need to use PyQt or another framework for it…Although maybe exists some add-on with autentication feature.

As far as i am aware there is no visible shell available in the mediacentre, its a corner case use so no one has implemented one. All scripts are run in console via ssh or bash invisibly in the background.
Really CE is not suitable for what you are trying to do.

Shoog

You can use the Mediacenter python bindings to send a password context. There are plenty of examples in the Kodi wiki or their forum. Our media center is compatible with kodi.

thanks! is it possible to run script in foreground on CE?

Thanks! My username/passwords save on remote db so as I understand your proposal to use python bindings to send password context is not suitable in my case…

What do you mean by forground ?

To have something visible on the TV you would need to call a python library which generates a window for Kodi just like any of the Addons which are available for Kodi.
As I said there is no visible console as standard in CE so there is no way to use standard Linux calls to ask for an input.

Shoog

1 Like

No you misunderstood (or maybe I have) You want to turn on CE and then input a username and password from within the Mediacenter to authenticate something?
Then you need to use kodi python bindings and make a service addon.

by other words it will possible in one case - if use my python script+graphic python library which will generate a window for Kodi with username/password prompts?

Yes.

Shoog

thanks, maybe exists similar service addon as template for creating my service addon?

and my script+graphic python library=new service addon?

I have never done it for Kodi, but I did use a standard python library to generate an output window for a plug in one wire thermometer. Basically I used a library to to read the thermometer and a library to generate a window - with almost zero python experience I had a working program in less than a day. Thats was in ubuntu but it should be similar in CE/Kodi.

Shoog

thx! I.e. it’s possible to use my script+python library for generate output window in Kodi? do you remember the name of this library for window generate?

The library I used was for a standard Linux x-windowing system - would not work in Kodi.

Shoog

Kodi already has UI library.

Something to get a feeling: How to implement search function for my video add-on

Thank you, for useful link. I will try to use it.