Add update option.

If rsstube was cloned with git, use -U flag to pull updates.
This commit is contained in:
0x80 2021-12-29 00:00:00 +00:00
parent 823af26ff7
commit f6fa8d652a
Signed by: 0x80
GPG Key ID: 68368BCBC000EF51
2 changed files with 32 additions and 7 deletions

View File

@ -16,6 +16,11 @@ rsstube is written in Python, an interpreted language. There's no need to compil
- python3 - python3
- python3-pycurl - python3-pycurl
### Optional Dependencies
- git (for updating via git)
- python3-GitPython (for updating via git)
### Sample Installation ### Sample Installation
`git clone https://negativezero.link/code/0x80/rsstube.git` `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 ### 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 ## Usage

View File

@ -20,16 +20,31 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
# 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): def options(params):
import sys,getopt,glob import sys,getopt,glob
from utils import debug,notify,warn,error 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 # general settings
network = True network = True
@ -115,6 +130,9 @@ def options(params):
d["tls_max"] = arg d["tls_max"] = arg
elif opt == "--tls13-ciphers": elif opt == "--tls13-ciphers":
d["tls13_ciphers"] = arg d["tls13_ciphers"] = arg
elif opt in ("-U", "--update"):
update()
sys.exit()
elif opt in ("-v", "--verbose"): elif opt in ("-v", "--verbose"):
verbosity = 4 verbosity = 4
elif opt == "--verbosity": elif opt == "--verbosity":