justinemter / pseudo-channel

This is a python based cli-app using the python-plex-api to control a plex-client and act like a real TV channel with show scheduling, commercial breaks, movie nights, etc. "Home-Brewed TV Channel(s) for Hackers"
GNU General Public License v3.0
128 stars 18 forks source link

generate_channels_daily_schedules.sh error #52

Closed MoeFwacky closed 6 years ago

MoeFwacky commented 6 years ago

I noticed this morning that the schedules hadn't updated for the day, so I ran generate_channels_daily_schedules.sh and got the following output. Running python PseudoChannel.py -g in each channel's folder works fine.

pi@controller:~/channels $ sudo ./generate-channels-daily-schedules.sh
+++++ There are 3 channels detected.
+++++ Trying to update: /usr/bin/python ./pseudo-channel_1/PseudoChannel.py -g
#### Generating Daily Schedule
Traceback (most recent call last):
  File "./pseudo-channel_1/PseudoChannel.py", line 732, in <module>
    pseudo_channel.generate_daily_schedule()
  File "./pseudo-channel_1/PseudoChannel.py", line 360, in generate_daily_schedule
    self.db.get_commercials(),
  File "/home/pi/channels/pseudo-channel_1/src/PseudoChannelDatabase.py", line 350, in get_commercials
    self.cursor.execute("SELECT * FROM commercials ORDER BY duration ASC")
sqlite3.OperationalError: no such table: commercials
+++++ Trying to update: /usr/bin/python ./pseudo-channel_3/PseudoChannel.py -g
#### Generating Daily Schedule
Traceback (most recent call last):
  File "./pseudo-channel_3/PseudoChannel.py", line 732, in <module>
    pseudo_channel.generate_daily_schedule()
  File "./pseudo-channel_3/PseudoChannel.py", line 360, in generate_daily_schedule
    self.db.get_commercials(),
  File "/home/pi/channels/pseudo-channel_3/src/PseudoChannelDatabase.py", line 350, in get_commercials
    self.cursor.execute("SELECT * FROM commercials ORDER BY duration ASC")
sqlite3.OperationalError: no such table: commercials
+++++ Trying to update: /usr/bin/python ./pseudo-channel_2/PseudoChannel.py -g
#### Generating Daily Schedule
Traceback (most recent call last):
  File "./pseudo-channel_2/PseudoChannel.py", line 732, in <module>
    pseudo_channel.generate_daily_schedule()
  File "./pseudo-channel_2/PseudoChannel.py", line 360, in generate_daily_schedule
    self.db.get_commercials(),
  File "/home/pi/channels/pseudo-channel_2/src/PseudoChannelDatabase.py", line 350, in get_commercials
    self.cursor.execute("SELECT * FROM commercials ORDER BY duration ASC")
sqlite3.OperationalError: no such table: commercials
justinemter commented 6 years ago

I just started a fresh multi channel dir using the develop branch. I first ran into a weird issue where it couldn't find the schedule python lib when trying to run the generate_channels_daily_schedules.sh file. I then tried to just run python PseudoChannel.py -g right in the channel_1 dir to see what would happen. I received the same error that you pasted above. I think I have an idea what is causing that issue, but wanted to ask you some questions first to help me figure it out...

1) does running the app manually for any of your channels work with the -g flag (or any flag)?

2) If the above errors, is any of this new? I remember you saying you've been using the multi channel setup for a while based on the develop branch. I am thinking you are just now experimenting with the generate_channels_daily_schedules.sh file, right?

My first idea is that the app isn't finding the database file for some reason and rather than outputting that the db isn't found, it is outputting that the 'commercials' table is not found.

MoeFwacky commented 6 years ago

Running manually with -g worked fine as normal. This was my first time with the generate_channels_daily_schedule.sh script, so these errors are new.

justinemter commented 6 years ago

Ok, so I'm trying to debug this but for some reason, my error is that the app cannot find the "schedule" module when running that script. I'm sure it's something really basic as the channelup.sh & channeldown.sh scripts both work great. Also, I added a stop-all-channels.sh script that will step through each channel to kill any running processes/the corresponding .pid along with the .prevplaying file. This seems to make debugging and tinkering a bit less of a headache.

justinemter commented 6 years ago

It seems to be working now in the develop branch. Python seemed to have difficulty finding the local .db for each channel (I think it was looking for it in the /channels/ dir). I am now pointing the generate-channels-daily-schedules.sh script to each channels' specific generate_daily_sched.sh script. You should be able to now run this to create a crontab (not yet tested):

crontab -e

0 0 * * * cd /home/pi/channels/ && bash ./generate-channels-daily-schedules.sh  > /dev/null 2>&1

change the above 'pi' home folder to whatever your home folder is, etc.

The above crontab will trigger the generate-channels-daily-schedules.sh script which will, in turn asynchronously trigger each channels' generate_daily_sched.sh script.

Also note, I am using virtualenv in my /channels/ dir named simply, /env. If you too are using virtualenv but have named your environment something different, you have to update that in the bash scripts... there is a var called: VIRTUAL_ENV_DIR. Virtualenv is not necessary for your pi setup tho and I don't think you are using it. That being said, I am using it and haven't tested this without it. I am thinking it should still work though. Tell me what happens.

We're getting close to a usable alpha.

justinemter commented 6 years ago

@MoeFwacky hold up on this update... I think I may see something goofy. I'm going to sit down and iron it out tomorrow. I want to also get the multi-channel branch up/tested and maybe merge that to master.

MoeFwacky commented 6 years ago

So I forgot about your note here and updated yesterday. The error is different now.

pi@controller:~/channels $ sudo ./generate-channels-daily-schedules.sh
./generate-channels-daily-schedules.sh: line 66: syntax error near unexpected token `fi'
./generate-channels-daily-schedules.sh: line 66: `              fi'
justinemter commented 6 years ago

Ok, so I think this is fixed with and commented in a different bug issue?