5332b07b5cac4e0cd06ec51fb6770e35d985aab6
Hanno Böck add update script

Hanno Böck authored 4 years ago

1) #!/usr/bin/python3
2) 
3) import os
4) import pathlib
5) import sys
6) import urllib.request
7) import io
8) import tarfile
9) 
10) 
11) DBURL = "https://freewvsdb.schokokeks.org/"
12) dbpaths = ['/var/lib/freewvs/', str(pathlib.Path.home()) + "/.cache/freewvs/"]
13) 
14) target = False
15) for dbpath in dbpaths:
16)     if not os.path.isdir(dbpath):
17)         try:
18)             os.makedirs(dbpath)
19)         except PermissionError:
20)             continue
21)     if os.access(dbpath, os.W_OK):
22)         target = dbpath
23)         break
24) 
25) if not target:
26)     sys.exit("Can't write to " + " or ".join(dbpaths))
27) 
28) old = 0
29) if os.path.isfile(target + "timestamp"):
Hanno Böck use curly set syntax and re...

Hanno Böck authored 3 years ago

30)     with open(target + "timestamp") as f: