Re: python, threading and a radio timer




Renato wrote:
Dear all,

I found this nifty article on how to record your favourite radio show
using cron and mplayer:
http://grimthing.com/archives/2004/05/20/recording-streaming-audio-with-mplayer/

Because I couldn't get the date in the filename (and was too lazy to
look into sh/bash manuals), I decided to use Python. It was a good
choice, because I decided to improve the timer - learning some more
Python along the way!

So, the idea is:
- cron runs the script at a specific time
- the script starts mplayer, and will keep checking the clock until
it's time to kill mplayer
- after mplayer has exited, oggenc is started to turn the raw WAV into
ogg
- and finally the remaining WAV is deleted

This basic setting is quite easy, and I used os.spawnvp(os.P_WAIT,...),
along with another CRON entry to kill mplayer.

But then I got more ambitious: I wanted the script to keep checking if
mplayer was alive - in case the connection goes down. Moreover, I would
rather have the script stop mplayer than cron.

At this point, I thought I should get some professional help... :) What
is the right way to go? Would threads be overkill? If so, where can I
go about looking for process control/management without delving into
complex daemon architectures?

So, rather than asking for code, I'm looking for guidance - this is a
didactic experience!

Cheers,

Renato

I would suggest you take a look at Python 'commands' module. The module
lets you run Unix commands by taking them as parameters to function
calls. That is all I can say with my level of expertise.

.



Relevant Pages

  • Re: whats the killer app for GNU/Linux systems?
    ... Cron and the ability to do timed ... I use cron, mplayer and a shell ... A Linux system makes a darn-good "tape recorder," so to ... I am big on automation because those of us in networking ...
    (Debian-User)
  • Re: flashblock version?
    ... After installing Python you just run python youtube.dl URL and then use ... mplayer etc to view the video. ... For every Flash video I've tried to access ... I got Python, got the script, tried it, it worked. ...
    (comp.os.os2.apps)
  • python, threading and a radio timer
    ... cron runs the script at a specific time ... the script starts mplayer, and will keep checking the clock until ... oggenc is started to turn the raw WAV into ...
    (comp.lang.python)
  • mplayer running of its own accord in dapper
    ... Mplayer seems to start periodically (once or twice a day) and I can't ... Obviously I don't remember starting it, nor can I find a cron ... Linux user #369094 ...
    (Ubuntu)
  • Cron Job Output
    ... I have cron checking services every 5-10 minutes, ... goes up or down it writes to a file, Im trying to write a script that ... Im extremely new to python and any point in the right direction or ... tutorials on the subject would be greatly appreicated. ...
    (comp.lang.python)