mythpython documentation?

Post Reply
wmorrison
Senior
Posts: 165
Joined: Sat Dec 01, 2018 12:05 am
United States of America

mythpython documentation?

Post by wmorrison »

I see there's an executable "mythpython" where the description is simply "mythpython is a command line utility shell for the python bindings of MythTV."

Googling mythpython returns no useful info that I've found so far other than the description above.

Is mythpython current, or an "old way" of doing things? Can those python bindings be used in standard python?

In other words, should I look into using mythpython instead of standard python, or just forget it?

I've generally been a Perl guy (for scripting, that is, Java and other languages for other stuff,) but I've been wanting to learn Python anyway, and it's really nice that you can call MythTV services requesting JSON and convert the response into a Python dictionary without adding any external libraries, and create and pass dictionaries for the parameters of an API request. (Using "import requests".)

Already using mysql.connector for selects. (Not updates, those done via APIs. Just selects for data that doesn't have an API.)

Just wondering if mythpython would make some things easier/possible.
User avatar
bill6502
Developer
Posts: 2323
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: mythpython documentation?

Post by bill6502 »

Yes, MythTV etc. can be imported in Python scripts. There are lots of scripts on the Wiki if you'd like
examples, e.g. https://www.mythtv.org/wiki/Find_orphans.py


mythpython is just a tool. mythpython --version returns local, external and schema information.
With no argument it just does: from MythTV import * and starts an interactive shell. It's more for
testing. In Python scripts, make sure the shebang is set to: #!/usr/bin/python2. Or if running on master,
soon to be MythTV v31, #!/usr/bin/python3 if at configure time the default or --python=python3 was
used.
wmorrison
Senior
Posts: 165
Joined: Sat Dec 01, 2018 12:05 am
United States of America

Re: mythpython documentation?

Post by wmorrison »

OK, so don't bother pointing shebang to mythpython, just python2 and import MythTV if needed. Thanks.
Post Reply