pytivo ported to python3

Discussion in 'Developers Corner' started by itsayellow, Jan 15, 2020 at 1:44 AM.

  1. itsayellow

    itsayellow New Member

    5
    2
    Jan 14, 2020
    Over thanksgiving break I decided to port pytivo (wmcbrine's version) completely to python3. In the process I also tried to clean up some of the code.

    If you're interested, here it is:
    itsayellow/pytivo

    It is installable as a python package via pip or pipx, which makes installation a little nicer and a little more portable.

    For some help text, execute:
    pytivo --help

    I may not be super available for supporting end users, but the code is pretty solid and I've been using it for some months now without problem.

    The main difference from the original pytivo is probably where it searches for pyTivo.conf. Here are the new locations:
    • /etc/pyTivo.conf
    • In your home directory: .config/pytivo/pyTivo.conf
    • In the directory you started pytivo from: pyTivo.conf
    • You can also specify the full path to your desired pyTivo.conf using the -c option.
    For developers, it may be of note that the entire code is also statically typed with python type hints and can be verified using mypy.

    Since python 2 is EOL this year, hopefully this is also useful going forward for other developers.
     
    Allanon and davidblackledge like this.
  2. Allanon

    Allanon Active Member

    837
    114
    Nov 2, 2005
    I can finally remove python 2 from my computer, this was the only thing holding me back!
     
  3. Allanon

    Allanon Active Member

    837
    114
    Nov 2, 2005
    Am I missing something, where is the pyTivo.py file?
     
  4. itsayellow

    itsayellow New Member

    5
    2
    Jan 14, 2020
    That's another change from the old pytivo I guess.

    The best way of running this is to install this using pipx. Once you do that, you should have a command on your path called 'pytivo' executable from anywhere.

    Installation example if you downloaded pytivo to directory <Some_Directory>/pytivo (replace <Some_Directory> with whatever directory is the parent of your pytivo directory.)
    1. python -m pip install --user pipx
    2. pipx install <Some_Directory>/pytivo
    pipx will install pytivo (or pytivo.exe on Windows) in your home directory to: .local/bin/ . If this is in your PATH, then pytivo will be executable anywhere. You can also run it explicitly from that path.


    The more technical answer is, there are a number of python packages that need to be installed to make this new pytivo work. The installation method above handles this automatically. If you know what you're doing and install all the python packages needed yourself, then to run pytivo you can also execute:
    python src/pytivo/main.py​
     
  5. itsayellow

    itsayellow New Member

    5
    2
    Jan 14, 2020
    I just updated the install directions on the main page for my fork of pytivo:
    itsayellow/pytivo

    I tried to find the right balance of enough information but not too much! But that balance is a little tricky. Hopefully those instructions are complete enough without being overwhelming.
     
  6. Allanon

    Allanon Active Member

    837
    114
    Nov 2, 2005
    Got it working, thanks.
     
    itsayellow likes this.
  7. eherberg

    eherberg Active Member

    358
    200
    Feb 16, 2011
    Forum user @mlippert also did this a couple of years ago, I think (ported to python 3). Just an FYI in case the 2 of you want to compare notes. :)
     
    itsayellow likes this.
  8. itsayellow

    itsayellow New Member

    5
    2
    Jan 14, 2020
    Thanks for the note, that's good to know! I looked, but I couldn't find any python3 pytivo ports on my own...might have saved me some work :D
     

Share This Page