Page 1 of 1

[SOLVED] cron compatible way to launch pyplanet?

Posted: 02 Apr 2018, 04:17
by TheBigG.
Hi,
is there a way to launch pyplanet via cron? The way i do it for PHP stuff doesn't work with it and google could not bring up a working solution sadly

Code: Select all

su -s /bin/bash -c "python3 /home/tm2/py_6001_pyplanet/manage.py start --detach --pid-file=pyplanet.pid" pyplanet
That produce this error

Code: Select all

Traceback (most recent call last):
  File "/home/tm2/py_6001_pyplanet/manage.py", line 8, in <module>
    from pyplanet.core.management import execute_from_command_line
ImportError: No module named 'pyplanet'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tm2/py_6001_pyplanet/manage.py", line 14, in <module>
    ) from exc
ImportError: Couldn't import PyPlanet. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
Thanks for help

Re: cron compatible way to launch pyplanet?

Posted: 02 Apr 2018, 09:21
by toffe
Are you using a virtualenv? You need to activate it in the whole command as well.

For this you can prefix your command with:

Code: Select all

source /path/to/env/bin/activate && start_cmd
Or in case of pyenv

Code: Select all

eval "$(pyenv init -)" && start_cmd
Let me know if this helps for you,
Toffe

Re: cron compatible way to launch pyplanet?

Posted: 02 Apr 2018, 12:28
by TheBigG.
I finaly found the problem, if you follow the doku of pyplanet you create a standalone python installation but i started pyplanet always with the system python. starting the manage.py with /home/pyplanet/.pyenv/shims/python3 solved it.
I realy dislike how this python stuff has its own update mechanism and that it does create standalone installations. running pyplanet in a docker container to stop python screwing the complete system up would be nice.
Maybe you could think about a docker image for pyplanet?

Re: cron compatible way to launch pyplanet?

Posted: 02 Apr 2018, 12:53
by toffe
Indeed. You kinda have to use the virtualenv so you won't screw your OS installation of python, that's unfortunately a downside of the python architecture. I already looked into making a single executable for PyPlanet which has an embedded python version inside, but with the loading of the dynamic apps and templates for manialinks it's kind of hard to get it working perfectly. I should invest more time in finding a working solution for it.

Well in fact, there is already a beginning of an docker image for pyplanet and maniaplanet. I've made the images on the hub page here: https://hub.docker.com/u/pyplanet/

Toffe