From f6fa8d652a97e7c93e4681805a3652e515e02764 Mon Sep 17 00:00:00 2001 From: 0x80 <0x80@negativezero.link> Date: Wed, 29 Dec 2021 00:00:00 +0000 Subject: [PATCH] Add update option. If rsstube was cloned with git, use -U flag to pull updates. --- README.md | 9 ++++++++- scripts/options.py | 30 ++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0d9a649..46d9f28 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,11 @@ rsstube is written in Python, an interpreted language. There's no need to compil - python3 - python3-pycurl +### Optional Dependencies + +- git (for updating via git) +- python3-GitPython (for updating via git) + ### Sample Installation `git clone https://negativezero.link/code/0x80/rsstube.git` @@ -24,7 +29,9 @@ rsstube is written in Python, an interpreted language. There's no need to compil ### Updating -If you installed with git, just `cd` into the directory and `git pull`. +If you installed rsstube with git, and you have python3-GitPython installed, use `rsstube -U` or `rsstube --update`. + +If you installed rsstube another way (manual download, package manager), update rsstube that same way. ## Usage diff --git a/scripts/options.py b/scripts/options.py index 1981ddd..7ed750b 100644 --- a/scripts/options.py +++ b/scripts/options.py @@ -20,16 +20,31 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ +# get installation path +import os.path +path = os.path.realpath(os.path.abspath(__file__)) +path = path[0:path.rfind("/")] +path = path[0:path.rfind("/")] + +def update(): + if os.path.isdir(path + "/.git"): + print("rsstube appears to have been downloaded with git.") + try: + import git + print("Attempting to update rsstube...") + g = git.cmd.Git(path) + output = g.pull() + print(output) + except ImportError: + print("python3-GitPython must be installed to update rsstube this way.") + print("If you don't want to install python3-GitPython, you can run `git pull` in the directory where rsstube was installed.") + else: + print("rsstube appears to have been manually downloaded or installed with a package manager. Use that same method to update.") + def options(params): import sys,getopt,glob from utils import debug,notify,warn,error - # get installation path - import os.path - path = os.path.realpath(os.path.abspath(__file__)) - path = path[0:path.rfind("/")] - path = path[0:path.rfind("/")] - # general settings network = True @@ -115,6 +130,9 @@ def options(params): d["tls_max"] = arg elif opt == "--tls13-ciphers": d["tls13_ciphers"] = arg + elif opt in ("-U", "--update"): + update() + sys.exit() elif opt in ("-v", "--verbose"): verbosity = 4 elif opt == "--verbosity":