From a6669962dfa74952072b92f8df375ad957a6195c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 17 Oct 2022 03:35:54 +0300 Subject: [PATCH] Uninstall previous plextraktsync pr if already installed --- plextraktsync/commands/self_update.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plextraktsync/commands/self_update.py b/plextraktsync/commands/self_update.py index 7746c3a2ab2..763dfee937e 100644 --- a/plextraktsync/commands/self_update.py +++ b/plextraktsync/commands/self_update.py @@ -36,8 +36,24 @@ def enable_self_update(): return package is not None +def has_previous_pr(pr: int): + try: + from plextraktsync.util.execx import execx + execx(f"plextraktsync@{pr} --help") + except FileNotFoundError: + return False + + return True + + def self_update(pr: int): if pr: + if has_previous_pr(pr): + # Uninstall because pipx doesn't update otherwise: + # - https://github.com/pypa/pipx/issues/902 + click.echo(f"Uninstalling previous plextraktsync@{pr}") + system(f"pipx uninstall plextraktsync@{pr}") + click.echo(f"Updating PlexTraktSync to the pull request #{pr} version using pipx") system(f"pipx install --suffix=@{pr} --force git+https://github.com/Taxel/PlexTraktSync@refs/pull/{pr}/head") return