API-20141201: Fatal: couldn't parse XML to JSON.

API-20141201: Fatal: couldn't parse XML to JSON.

Postby hobbes1069 » Tue Jul 28, 2015 7:24 pm

I recently updated to the 20141201 API and thought everything was working. When I do a manual run everything works.

I created my own systemd service file with timer to automate schedule updates since as far as I know the JSON method still isn't compatible with mythfilldatabase.

Here's the full log:
Code: Select all
# systemctl status mfdb-json.service -l
● mfdb-json.service - JSON based schedule grabber for MythTV
   Loaded: loaded (/etc/systemd/system/mfdb-json.service; static)
   Active: inactive (dead) since Tue 2015-07-28 21:09:44 CDT; 29s ago
  Process: 30919 ExecStart=/usr/local/share/mfdb-json/mfdb-json.php (code=exited, status=0/SUCCESS)
 Main PID: 30919 (code=exited, status=0/SUCCESS)

Jul 28 21:09:43 calvin.localdomain mfdb-json.php[30919]: Using production server.
Jul 28 21:09:43 calvin.localdomain mfdb-json.php[30919]: 2015-07-29 02:09:43:Checking to see if we're running the latest client.
Jul 28 21:09:44 calvin.localdomain mfdb-json.php[30919]: 2015-07-29 02:09:44:mfdb-json.php developer grabber API:20141201 v0.27/2015-07-06
Jul 28 21:09:44 calvin.localdomain mfdb-json.php[30919]: 2015-07-29 02:09:44:Temp directory for Schedules is /tmp/mfdb_schedules_c6B4G4
Jul 28 21:09:44 calvin.localdomain mfdb-json.php[30919]: 2015-07-29 02:09:44:Temp directory for Programs is /tmp/mfdb_programs_Qj8sgq
Jul 28 21:09:44 calvin.localdomain mfdb-json.php[30919]: 2015-07-29 02:09:44:Fatal: couldn't parse XML to JSON.
Jul 28 21:09:44 calvin.localdomain mfdb-json.php[30919]: 2015-07-29 02:09:44:Open ticket with grabber@schedulesdirect.org and send the following:
Jul 28 21:09:44 calvin.localdomain mfdb-json.php[30919]: string(0) ""
Jul 28 21:09:44 calvin.localdomain mfdb-json.php[30919]: 2015-07-29 02:09:44:


From looking at mfdb-json.php it looks like because I'm not specifying a dbhost, it's running the "getLoginFromFiles()" function from functions.php which looks for config.xml in ~/.mythtv/config.xml first and then /etc/mythtv/config.xml.

It's strange that I'm not getting a message between the Temp directory lines and the Fatal line since there are obviously two printMSG calls, one of which should be executed, between the two resultant log entries which leads me to believe somehow BOTH if conditionals are failing:

Code: Select all
    if ($localFile === TRUE)
    {
        printMSG("Using database information from ~/.mythtv/config.xml");
        $xml = simplexml_load_file(getenv("HOME") . "/.mythtv/config.xml");
    }


or

Code: Select all
if ((isset($xml) === FALSE) AND ($etcFile === TRUE))
    {
        printMSG("Using database information from /etc/mythtv/config.xml");
        $xml = simplexml_load_file("/etc/mythtv/config.xml");



But I clearly have the file in /etc:

Code: Select all
# file /etc/mythtv/config.xml
/etc/mythtv/config.xml: ASCII text


I'm pretty sure I know why it's working when I run it manually and failing when I run through systemd... When I run manually from the shell $HOME exists and even though I keep deleting it ~/.mythtv/config.xml keeps getting recreated which is another problem I need to track down, but nonetheless, when it's executed through systemd, it's run directly, no shell, so $HOME isn't defined, but it SHOULD be finding /etc/mythtv/config.xml.

If I delete ~/.mythtv/config.xml I can recreate the error manually (until it's replaced obviously) and adding --dbhost=NONE gets it to work as well by skipping the function call getLoginFromFiles() and using the defaults.

Any ideas?
Thanks,
Richard
hobbes1069
 
Posts: 6
Joined: Sat Sep 20, 2014 8:23 am

Re: API-20141201: Fatal: couldn't parse XML to JSON.

Postby hobbes1069 » Tue Jul 28, 2015 7:40 pm

Also, it would probably be good to have a non-zero exit for this since it makes systemd think things exited correctly.
hobbes1069
 
Posts: 6
Joined: Sat Sep 20, 2014 8:23 am


Return to Developer

Who is online

Users browsing this forum: Google [Bot] and 8 guests

cron