I have a few scripts that run on events. Usually, when I first start testing them (actually run by MythTV) I only see 'result 1' (failure) in mythbackend.log but any output from the script is lost. Any tips on debugging? Does the output get logged anywhere?
I have other scripts that are running, so I already know to check ownership and mode of files accessed/written. I even have them writing both stdout and stderr to a specific log file. The script works when I run it in xterm, even when I copy the full command out of mythbackend.log. I've compared the values for working jobs to the non-working one in table settings for values EventCmd* and see no mistakes there.
Every time I make a new event or job script I go through this. No output about what's going wrong, even though my script should write it to a log file (and does, for the working event scripts.)
'result 1' for event commands, where does output go?
Moderator: Forum Moderators
Re: 'result 1' for event commands, where does output go?
Any output from a script is lost unless the user sends it to a file as you've
mentioned above.
If you haven't, run with -v system:debug and you may get some more
clues, buy only about the command being run and results. Not script
output. mythbackend --setverbose system:debug lets you change it
on a running backend. system:alert turns it off.
If you use the Python bindings, there is a logging module that provides
the 'traditional' mythAnyProgramName switches. You can do:
and then pass command like arguments like. Just type yourPython.py --help
to see what's available. Of course you can add any additional switches you
like. I use the argparse module for that.
mentioned above.
If you haven't, run with -v system:debug and you may get some more
clues, buy only about the command being run and results. Not script
output. mythbackend --setverbose system:debug lets you change it
on a running backend. system:alert turns it off.
If you use the Python bindings, there is a logging module that provides
the 'traditional' mythAnyProgramName switches. You can do:
Code: Select all
from MythTV import MythLog
...
MythLog.loadArgParse(parser)
logger = MythLog(module='your command name')
...
# And, just a sample:
logger(MythLog.GENERAL, MythLog.INFO, "***** Job arguments.", job.args)
to see what's available. Of course you can add any additional switches you
like. I use the argparse module for that.
Re: 'result 1' for event commands, where does output go?
Ugh! Figured it out.
I was putting all my imports at the top of my Python script, where they're "supposed" to be.
Then defining a logger class and redirecting stdout and stderr to it.
Problem is, there was a ModuleNotFoundError happening before the logger got set up.
I moved all imports except sys below the logger setup, and now I see the ModuleNotFoundError in my log file.
[smacks forehead]
I was putting all my imports at the top of my Python script, where they're "supposed" to be.
Then defining a logger class and redirecting stdout and stderr to it.
Problem is, there was a ModuleNotFoundError happening before the logger got set up.
I moved all imports except sys below the logger setup, and now I see the ModuleNotFoundError in my log file.
[smacks forehead]
Re: 'result 1' for event commands, where does output go?
My full 'top-o-script':
I use argparse before MythLog. The default v31+ is build is with python3.
I agree that most of the time, imports belong at the top. pylint is happy with mine.
Code: Select all
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
''' Test MythTV job features '''
import argparse
import os
import sys
from MythTV import (exceptions, Job, MythDB, MythLog)
I agree that most of the time, imports belong at the top. pylint is happy with mine.