From 4edd2001b38a2af28bec0ad547bea81e1e250455 Mon Sep 17 00:00:00 2001 From: Landon Abney Date: Sat, 28 Mar 2020 16:31:14 -0700 Subject: [PATCH] Make init scripts Python version agnostic Now that the Tautulli will run on both major versions of Python we can remove the specificity in the init scripts and make them simpler, with the added advantage that some OS's will now run Tautulli through Python 3 instead of Python 2. --- CONTRIBUTING.md | 4 ++-- PlexPy.py | 6 +----- init-scripts/init.fedora.centos.service | 8 ++++---- init-scripts/init.freebsd | 2 +- init-scripts/init.freenas | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b36103b1..e687432e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ All pull requests should be based on the `nightly` branch, to minimize cross mer ### Python Code #### Compatibility -The code should work with Python 2.7. Note that Tautulli runs on many different platforms. +The code should work with Python 2.7.17 or Python 3.6+. Note that Tautulli runs on many different platforms. Re-use existing code. Do not hesitate to add logging in your code. You can the logger module `plexpy.logger.*` for this. Web requests are invoked via `plexpy.request.*` and derived ones. Use these methods to automatically add proper and meaningful error handling. @@ -38,4 +38,4 @@ HTML5 compatible browsers are targeted. * 4 space indentation * `methodName` * `variableName` -* `ClassName` \ No newline at end of file +* `ClassName` diff --git a/PlexPy.py b/PlexPy.py index c583df6c..eb9ceea4 100755 --- a/PlexPy.py +++ b/PlexPy.py @@ -1,8 +1,4 @@ -#!/bin/sh -''''which python >/dev/null 2>&1 && exec python "$0" "$@" # ''' -''''which python2 >/dev/null 2>&1 && exec python2 "$0" "$@" # ''' -''''which python2.7 >/dev/null 2>&1 && exec python2.7 "$0" "$@" # ''' -''''exec echo "Error: Python not found!" # ''' +#!/usr/bin/env python # -*- coding: utf-8 -*- diff --git a/init-scripts/init.fedora.centos.service b/init-scripts/init.fedora.centos.service index fd6b78e8..a9f1d8d2 100755 --- a/init-scripts/init.fedora.centos.service +++ b/init-scripts/init.fedora.centos.service @@ -21,8 +21,8 @@ datadir=/opt/Tautulli configfile=/opt/Tautulli/config.ini pidfile=/var/run/tautulli.pid nice= -# The following line must point to your Python 2.7 install -python27=/usr/src/Python-2.7.11/python +# The following line must point to your Python installation +python=/usr/bin/python ## options=" --daemon --config $configfile --pidfile $pidfile --datadir $datadir --nolaunch --quiet" @@ -30,7 +30,7 @@ options=" --daemon --config $configfile --pidfile $pidfile --datadir $datadir -- start() { # Start daemon. echo -n $"Starting $prog: " - daemon --pidfile=$pidfile $nice $python27 $homedir/Tautulli.py $options + daemon --pidfile=$pidfile $nice $python $homedir/Tautulli.py $options RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile @@ -39,7 +39,7 @@ start() { stop() { echo -n $"Shutting down $prog: " - killproc -p $pidfile $python27 + killproc -p $pidfile $python RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $lockfile diff --git a/init-scripts/init.freebsd b/init-scripts/init.freebsd index 6a3a1045..75b6160e 100755 --- a/init-scripts/init.freebsd +++ b/init-scripts/init.freebsd @@ -51,7 +51,7 @@ verify_tautulli_pid() { # Make sure the pid corresponds to the Tautulli process. if [ -f ${tautulli_pid} ]; then pid=`cat ${tautulli_pid} 2>/dev/null` - ps -p ${pid} | grep -q "python2 ${tautulli_dir}/Tautulli.py" + ps -p ${pid} | grep -q "python ${tautulli_dir}/Tautulli.py" return $? else return 0 diff --git a/init-scripts/init.freenas b/init-scripts/init.freenas index 5010d233..a000ea7c 100755 --- a/init-scripts/init.freenas +++ b/init-scripts/init.freenas @@ -51,7 +51,7 @@ verify_tautulli_pid() { # Make sure the pid corresponds to the Tautulli process. if [ -f ${tautulli_pid} ]; then pid=`cat ${tautulli_pid} 2>/dev/null` - ps -p ${pid} | grep -q "python2 ${tautulli_dir}/Tautulli.py" + ps -p ${pid} | grep -q "python ${tautulli_dir}/Tautulli.py" return $? else return 0