[mythtvnz] Problem running xmltv-proc-nz from user crontab

Stephen Worthington stephen_agent at jsw.gen.nz
Wed May 19 04:49:54 BST 2010


On Tue, 04 May 2010 13:37:23 +1200, you wrote:

>I have been running my EPG script manually (from user stephen) while I
>tweaked it, and it was working fine.  Now, when I am trying to run it
>from user stephen's crontab, xmltv-proc-nz (0.5.6) is failing:
>
>Running xmltv-proc-nz on the Freeview data
>Movies: TMDB module not found.
>Traceback (most recent call last):
>  File "/usr/local/bin/xmltv-proc-nz", line 551, in <module>
>    tree = ElementTree.XML(data)
>  File "<string>", line 86, in XML
>SyntaxError: no element found: line 1, column 0
>xmltv-proc-nz failed, rc = 1
>
>The line in the script that runs xmltv-proc-nz is this:
>
>/usr/local/bin/xmltv-proc-nz freeview.xml >temp.xml
>
>Line 86 in the freeview.xml file is the start of the first <programme>
>element after the <channel> elements.  If I again run the script
>manually immediately after the crontab job fails, it works correctly.
>
>I have no experience with Python or user crontabs, so I am hoping
>someone out there will be able to give me a clue as to what this might
>mean.

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.



More information about the mythtvnz mailing list