How to pip?

Dord

Dabbler
Joined
Oct 3, 2016
Messages
15
So I migrated from Core over the weekend and was able to setup pretty much everything the way I wanted to but there's one thing I'm a bit struggling with.
In Core I had this python project called CATT running in my Home Assistant jail, it basically casts webpages to a nesthub.

They way I had it setup on Core was that I installed CATT in the Home Assistant jail via pipx, and then because the nesthub times out every 10 minutes, I had a script with my CATT command in it, and I had an automation running in Home Assistant to call that script every 10 minutes to cast again to go around the timing out issue.

Now with SCALE I have Home Assistant installed via the Truecharts app, and so I'm not sure where/how to best install CATT and was wondering what would be the most elegant way to get it installed.

I don't think I should mess with the Truecharts Home Assistant app to try and have CATT installed in there. (I don't think it's possible either)
I don't think I should install CATT directly along Truenas either.

So I was thinking of maybe running a Python docker image as an "app" with TTY, pass on a parameter to have it 'pip install catt', and run a cronjob inside the container to run my script every 10 minutes (probably keeping that script outside and mounting it to the app). But since I can't even get the Python image running - it hangs on "deploying" forever - I'm now realizing that because Python isn't really an "app" in the first place, SCALE's container system probably can't run it that way.

So I think I'm looking at this all wrong, what would be the easiest/best way to install CATT (or any other Python package) within SCALE?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I don't think I should mess with the Truecharts Home Assistant app to try and have CATT installed in there. (I don't think it's possible either)
You shouldn't mess with it, but you can certainly ask them to add a package. Head over to their discord and see what they say.
 

Dord

Dabbler
Joined
Oct 3, 2016
Messages
15
Just to close the loop on this, I ended up creating my own docker image with CATT and a script running through a cronjob. For those stumbling upon this thread looking to achieve something similar:

My dockerfile:

Code:
FROM python:3.7
USER root

# Install CRON/CATT
RUN apt-get update -y && \
    apt-get install -y pip cron
RUN pip install catt

# Copy catt script
COPY catt.sh /mnt/catt.sh
RUN chmod +x /mnt/catt.sh

# Add script to cronjob
RUN echo "*/9 * * * * root /mnt/catt.sh >> /var/log/cron.log 2>&1" > /etc/cron.d/catt
RUN chmod +x /etc/cron.d/catt

# Start cron
COPY entrypoint /mnt/entrypoint
RUN chmod +x /mnt/entrypoint
ENTRYPOINT ["/mnt/entrypoint"]

the entrypoint:
Code:
#!/bin/sh

# Fix link-count
touch /etc/crontab /etc/cron.*/*

service cron start

# Hand off to the CMD
exec "$@"


And for those who might care, here is the script to cast my HomeAssisstant dashboard to my nesthub:
Code:
#!/bin/bash
/usr/local/bin/catt stop
/usr/local/bin/catt cast_site https://domain.com/dashboard
/usr/local/bin/catt volume 0
exit


And then in Truenas I just run it with CMD=sleep and Arg=infinity and added an external interface with my Truenas host + DHCP, everything else default.

I had some trouble with cron, it's pretty finicky in docker, but that's how I finally got it to run perfectly on my debian desktop. But sadly that same image on Truenas won't start cron automatically despite the entrypoint, so I'll have to look into that later, but for the time being I'm ok with manually starting it whenever the app restarts, which is going to be as close to never as possible.
 
Top