[mythtvnz] Problem running xmltv-proc-nz from user crontab
Robin Gilks
g8ecj at gilks.org
Wed May 19 05:47:13 BST 2010
>
> I have finally been able to spend some time debugging this problem,
> and I have found out what is going wrong in xmltv-proc-nz when run
> from a user cron job. It is in this piece of code:
>
> if sys.stdin.isatty():
> if len(args) == 0:
> log.critical('No input file')
> sys.exit(2)
> data = open(args[0]).read()
> else:
> data = sys.stdin.read()
>
> It appears that sys.stdin.isatty() returns false when run from my cron
> job. Which means that xmltv-proc-nz is not trying to read from the
> file specified on the command line and is trying to get its data from
> stdin. So it gets no data, and then the XML parsing fails on an
> immediate end of data.
>
> When I change my cron script from this:
>
> /usr/local/bin/xmltv-proc-nz sky.xml >temp.xml
>
> to this:
>
> cat sky.xml | /usr/local/bin/xmltv-proc-nz >temp.xml
>
> it works.
>
> Since my Python skills are sadly lacking and it works by piping the
> data, I have not tried to fix xmltv-proc-nz.
Looks to me as though the test is up-side-down. There will never be a tty
when run from cron so it MUST have an input file on the command line. As
it is it only looks for stdin input if its not run from a terminal.
--
Robin Gilks
More information about the mythtvnz
mailing list