From d9eed14b7a8fc65d49e1ec450a9e740c253915dd Mon Sep 17 00:00:00 2001 From: Marcello Franco Date: Tue, 14 Jul 2020 17:05:50 +0200 Subject: [PATCH 01/12] Initial commit --- .editorconfig | 17 +++++++++++++++++ .gitignore | 13 +++++++++++++ snap/snapcraft.yaml | 28 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 .editorconfig create mode 100644 snap/snapcraft.yaml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1749b2d4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false + +[*.yaml] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/.gitignore b/.gitignore index e55fd0af..c868b447 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,16 @@ _ReSharper*/ #Ignore files generated by pyinstaller /build /dist + +#snapcraft specifics +/parts/ +/stage/ +/prime/ + +*.snap + +.snapcraft +__pycache__ +*.pyc +*_source.tar.bz2 +snap/.snapcraft \ No newline at end of file diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000..94e7c119 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,28 @@ +name: tautulli +version: 'git' +summary: A Python based monitoring and tracking tool for Plex Media Server. # 79 char long summary +description: | + Tautulli is a 3rd party application that you can run alongside your Plex Media Server to monitor activity and track various statistics. + Most importantly, these statistics include what has been watched, who watched it, when and where they watched it, and how it was watched. + The only thing missing is "why they watched it", but who am I to question your 42 plays of Frozen. + All statistics are presented in a nice and clean interface with many tables and graphs, which makes it easy to brag about your server to everyone else. +confinement: strict +grade: stable +base: core18 + +parts: + tautulli: + plugin: dump + source: . + stage-packages: [python3, python3-setuptools] + override-build: | + snapcraftctl build + sed -i "s|'CHECK_GITHUB': (int, 'General', 1),|'CHECK_GITHUB': (int, 'General', 0),|g" $SNAPCRAFT_PART_INSTALL/plexpy/config.py + sed -i "s|'CHECK_GITHUB_ON_STARTUP': (int, 'General', 1),|'CHECK_GITHUB_ON_STARTUP': (int, 'General', 0),|g" $SNAPCRAFT_PART_INSTALL/plexpy/config.py + sed -i 's|||g' $SNAPCRAFT_PART_INSTALL/data/interfaces/default/welcome.html + sed -i 's|name="plexpy_auto_update" value="1"|name="plexpy_auto_update" value="0"|g' $SNAPCRAFT_PART_INSTALL/data/interfaces/default/settings.html +apps: + tautulli: + command: python3 $SNAP/Tautulli.py --datadir $SNAP_COMMON/Tautulli --config $SNAP_COMMON/Tautulli/config.ini --quiet --nolaunch + daemon: simple + plugs: [network, network-bind] \ No newline at end of file From 2fdf619582acf1eefa87fbebc3d53b3a089237b4 Mon Sep 17 00:00:00 2001 From: capruro <64908287+capruro@users.noreply.github.com> Date: Thu, 16 Jul 2020 12:59:19 +0200 Subject: [PATCH 02/12] Delete .editorconfig NOT required to be implemented :) --- .editorconfig | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 1749b2d4..00000000 --- a/.editorconfig +++ /dev/null @@ -1,17 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 4 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = false -insert_final_newline = false - -[*.yaml] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true \ No newline at end of file From e426b5dd359c8538310dcc8439afb1daea106f82 Mon Sep 17 00:00:00 2001 From: capruro <64908287+capruro@users.noreply.github.com> Date: Wed, 26 Aug 2020 16:25:47 +0200 Subject: [PATCH 03/12] add PyOpenSSL package --- snap/snapcraft.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 94e7c119..a895a478 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -14,15 +14,21 @@ parts: tautulli: plugin: dump source: . - stage-packages: [python3, python3-setuptools] + stage-packages: + - python3 + - python3-setuptools + - python3-openssl override-build: | snapcraftctl build sed -i "s|'CHECK_GITHUB': (int, 'General', 1),|'CHECK_GITHUB': (int, 'General', 0),|g" $SNAPCRAFT_PART_INSTALL/plexpy/config.py sed -i "s|'CHECK_GITHUB_ON_STARTUP': (int, 'General', 1),|'CHECK_GITHUB_ON_STARTUP': (int, 'General', 0),|g" $SNAPCRAFT_PART_INSTALL/plexpy/config.py sed -i 's|||g' $SNAPCRAFT_PART_INSTALL/data/interfaces/default/welcome.html sed -i 's|name="plexpy_auto_update" value="1"|name="plexpy_auto_update" value="0"|g' $SNAPCRAFT_PART_INSTALL/data/interfaces/default/settings.html + apps: tautulli: command: python3 $SNAP/Tautulli.py --datadir $SNAP_COMMON/Tautulli --config $SNAP_COMMON/Tautulli/config.ini --quiet --nolaunch daemon: simple - plugs: [network, network-bind] \ No newline at end of file + plugs: + - network + - network-bind From 7c08b07ef54fccb083e4a54ebdead58423dd61fd Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:48:55 -0800 Subject: [PATCH 04/12] Update snapcraft.yaml --- snap/snapcraft.yaml | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index a895a478..edaecd16 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,34 +1,48 @@ name: tautulli -version: 'git' -summary: A Python based monitoring and tracking tool for Plex Media Server. # 79 char long summary -description: | +adopt-info: tautulli +summary: A Python based monitoring and tracking tool for Plex Media Server. +description: > Tautulli is a 3rd party application that you can run alongside your Plex Media Server to monitor activity and track various statistics. Most importantly, these statistics include what has been watched, who watched it, when and where they watched it, and how it was watched. The only thing missing is "why they watched it", but who am I to question your 42 plays of Frozen. All statistics are presented in a nice and clean interface with many tables and graphs, which makes it easy to brag about your server to everyone else. -confinement: strict -grade: stable + base: core18 +confinement: strict parts: tautulli: plugin: dump source: . - stage-packages: + stage-packages: - python3 - python3-setuptools - python3-openssl - override-build: | - snapcraftctl build - sed -i "s|'CHECK_GITHUB': (int, 'General', 1),|'CHECK_GITHUB': (int, 'General', 0),|g" $SNAPCRAFT_PART_INSTALL/plexpy/config.py - sed -i "s|'CHECK_GITHUB_ON_STARTUP': (int, 'General', 1),|'CHECK_GITHUB_ON_STARTUP': (int, 'General', 0),|g" $SNAPCRAFT_PART_INSTALL/plexpy/config.py - sed -i 's|||g' $SNAPCRAFT_PART_INSTALL/data/interfaces/default/welcome.html - sed -i 's|name="plexpy_auto_update" value="1"|name="plexpy_auto_update" value="0"|g' $SNAPCRAFT_PART_INSTALL/data/interfaces/default/settings.html + build-packages: + - git + override-pull: | + snapcraftctl pull + TAG_FULL=$(git describe --tag) + TAG=$(echo $TAG_FULL | grep -oP '(v\d+\.\d+\.\d+(?>-beta)?)') + COMMIT_HASH=$(git rev-parse --short=7 HEAD) + [ "$TAG" = "$TAG_FULL" ] && VERSION=$TAG || VERSION=$COMMIT_HASH + [ "$VERSION" = ${VERSION#v} ] || [ ! "$VERSION" = ${VERSION%-beta} ] && GRADE=devel || GRADE=stable + snapcraftctl set-version "$VERSION" + snapcraftctl set-grade "$GRADE" apps: tautulli: - command: python3 $SNAP/Tautulli.py --datadir $SNAP_COMMON/Tautulli --config $SNAP_COMMON/Tautulli/config.ini --quiet --nolaunch + command: > + usr/bin/python3 $SNAP/Tautulli.py + --datadir $SNAP_USER_COMMON/Tautulli + --config $SNAP_USER_COMMON/Tautulli/config.ini + --quiet + --nolaunch daemon: simple - plugs: + restart-condition: on-abnormal + restart-delay: 5s + plugs: - network - network-bind + environment: + TAUTULLI_SNAP: "True" From c70d5d4398d0f93ab4d07cadf3fae66f79dc885f Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:45:47 -0800 Subject: [PATCH 05/12] Add Publish Snap GitHub workflow --- .github/workflows/publish-snap.yml | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/publish-snap.yml diff --git a/.github/workflows/publish-snap.yml b/.github/workflows/publish-snap.yml new file mode 100644 index 00000000..75c32f6f --- /dev/null +++ b/.github/workflows/publish-snap.yml @@ -0,0 +1,53 @@ +name: Publish Snap + +on: + push: + branches: [master, beta, nightly] + tags: [v*] + +jobs: + build-docker: + name: Build Snap Package + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Prepare + id: prepare + run: | + git fetch --prune --unshallow --tags + if [[ $GITHUB_REF == refs/tags/*-beta ]]; then + echo ::set-output name=RELEASE::beta + elif [[ $GITHUB_REF == refs/tags/* ]]; then + echo ::set-output name=RELEASE::stable + else + echo ::set-output name=RELEASE::edge + fi + + - name: Build Snap Package + uses: snapcore/action-build@v1 + id: build + + - name: Upload Snap Package + uses: actions/upload-artifact@v2 + with: + name: Tautulli-snap-package + path: ${{ steps.build.outputs.snap }} + + - name: Publish Snap Package + if: startsWith(github.ref, 'refs/tags/') + uses: snapcore/action-publish@v1 + with: + store_login: ${{ secrets.SNAP_LOGIN }} + snap: ${{ steps.build.outputs.snap }} + release: ${{ steps.prepare.outputs.RELEASE }} + + - name: Post Status to Discord + uses: sarisia/actions-status-discord@v1 + if: always() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + status: ${{ job.status }} + title: ${{ github.workflow }} + nofail: true From a4d5d9157b9e225357cc631a30b0a297a5a4f915 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:45:59 -0800 Subject: [PATCH 06/12] Add snap to .dockerignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 87b5c14b..8f266283 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,6 +5,7 @@ contrib init-scripts package pylintrc +snap *.md !CHANGELOG*.md start.bat From 0dddc4d58f7af8b24e5c3bff60e9412975639358 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:56:39 -0800 Subject: [PATCH 07/12] Fix typo in Publish Snap workflow --- .github/workflows/publish-snap.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-snap.yml b/.github/workflows/publish-snap.yml index 75c32f6f..983c46a0 100644 --- a/.github/workflows/publish-snap.yml +++ b/.github/workflows/publish-snap.yml @@ -6,7 +6,7 @@ on: tags: [v*] jobs: - build-docker: + build-snap: name: Build Snap Package runs-on: ubuntu-latest steps: From da3bc127dc453600fcf369f6ea5006d2a95b92ff Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Thu, 17 Dec 2020 12:48:12 -0800 Subject: [PATCH 08/12] Add TAUTULLI_SNAP environment variable --- Tautulli.py | 2 ++ plexpy/__init__.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Tautulli.py b/Tautulli.py index 0a15f2c6..4fa83243 100755 --- a/Tautulli.py +++ b/Tautulli.py @@ -124,6 +124,8 @@ def main(): if helpers.bool_true(os.getenv('TAUTULLI_DOCKER', False)): plexpy.DOCKER = True + if helpers.bool_true(os.getenv('TAUTULLI_SNAP', False)): + plexpy.SNAP = True if args.dev: plexpy.DEV = True diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 61c88eb6..d5ba9319 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -98,6 +98,7 @@ CREATEPID = False PIDFILE = None NOFORK = False DOCKER = False +SNAP = False FROZEN = False SCHED = None @@ -194,6 +195,8 @@ def initialize(config_file): if DOCKER: build = '[Docker] ' + elif SNAP: + build = '[Snap] ' elif FROZEN: build = '[Bundle] ' else: From a73c99fc64d6bdcd38b3acbe6898c09b5fc6bf30 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Thu, 17 Dec 2020 17:47:10 -0800 Subject: [PATCH 09/12] Disable updated for Snap package --- data/interfaces/default/base.html | 4 ++++ data/interfaces/default/settings.html | 2 +- plexpy/config.py | 8 +++++++- plexpy/versioncheck.py | 20 +++++++++++++++----- plexpy/webserve.py | 6 +++--- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/data/interfaces/default/base.html b/data/interfaces/default/base.html index d466536f..14bfcd6a 100644 --- a/data/interfaces/default/base.html +++ b/data/interfaces/default/base.html @@ -59,6 +59,8 @@ % endif % if plexpy.INSTALL_TYPE == 'docker': Update your Docker container or Dismiss + % elif plexpy.INSTALL_TYPE == 'snap': + Update your Snap package or Dismiss % elif plexpy.INSTALL_TYPE in ('windows', 'macos'): Download and install the latest version or Dismiss % else: @@ -337,6 +339,8 @@ ${next.modalIncludes()} } if (result.install_type === 'docker') { msg += 'Update your Docker container or Dismiss'; + } else if (result.install_type === 'snap') { + msg += 'Update your Snap package or Dismiss'; } else if (result.install_type === 'windows' || result.install_type === 'macos') { msg += 'Download and install the latest version or Dismiss' } else { diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index 6aaebc9c..b0cd9170 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -220,7 +220,7 @@

Check for Tautulli updates periodically.

- % if not plexpy.FROZEN: + % if not plexpy.SNAP and not plexpy.FROZEN: