[mythtvnz] Python and tv_grab_nz-py for Ubuntu 20.04

Stephen Worthington stephen_agent at jsw.gen.nz
Thu Jul 16 11:53:47 BST 2020


I am preparing for the upcoming upgrade of my MythTV boxes from Ubuntu
18.04 to 20.04.1, which is due for release in early August.  Before
that I will be upgrading MythTV from v30 to v31.  So I have set up a
virtual machine with 20.04 and installed v31-fixes there to try things
out.  One big change is that Ubuntu 20.04 does not install Python 2 by
default, although you can still manually install it.  But as MythTV
wants to be compatible with the current Ubuntu version, it has
converted all its Python support to Python 3 as of v31, including
things like find_orphans.py.  The result of that is that if you
upgrade an older system such as 18.04 to 20.04, you will already have
Python 2 installed and Python 2 code will still work as long as it
does not use the MythTV Python libraries.  All Python code that does
use the MythTV Python support will need to be converted to Python 3
when you upgrade to v31 - just download the Python 3 versions for
things on the MythTV web site.

I use Python 2 code that falls into both categories - some uses the
MythTV libraries (eg gaps and mythsgu that I wrote), and some does not
use the MythTV libraries and would work in my 20.04 virtual machine if
I installed Python 2.  For example, tv_grab_nz-py and my modified
versions of it.  But my preference is to convert everything to Python
3 if possible, as Python 2 is fully deprecated and will go away
eventually.

So far, I had already converted my gaps program - version 1.5 runs
under Python 2 or Python 3.  It has a "#!/usr/bin/python" shebang line
so if you run it on a system where the default python is set up, it
will just run.  But if your system, like Ubuntu 20.04, only has
/usr/bin/python3 then you will need to adjust the first line by adding
the "3".

http://www.jsw.gen.nz/mythtv/gaps

I have also just now done a conversion of tv_grab_nz-py:

http://www.jsw.gen.nz/mythtv/tv_grab_nz-py

This is a straight conversion using the 2to3 tool and then I have
fixed the problem that StringIO needed to be changed to ByteIO.  I
have run it and it seems to work, but it needs wider testing before we
can be happy with the conversion.  I am just learning Python 3 and I
may easily have missed something.  If you have been playing with
Ubuntu 20.04, you may have tried setting up EPG and if you use the
Python 2 version of tv_grab_nz-py, mythtv-setup will not see it as a
grabber and list it as an option to use.  That is because all the
XMLTV code is now Python 3 and runs without Python 2 installed.
Without a Python 2 interpreter, tv_grab_nz-py fails to run and is not
identified as a grabber.

There are probably quite a few more Python tools for MythTV that will
need converting - I will need to have my mythsgu program working
before I can upgrade to v31, so I will be working on that next.  But
is there anything else that is needed?  Please let me know if I can
help.



More information about the mythtvnz mailing list