mirror of
https://github.com/aclist/dztui.git
synced 2026-10-29 22:22:52 +01:00
feat: setup wizard (WIP)
This commit is contained in:
1 parent
f0e51fa758
commit
07ea73ef2e
17 files changed
+839
-61
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from pathlib import Path
|
||||
from dzgui.const.constants import LEGACY_CONFIG_PATH, LEGACY_COLS_PATH, LEGACY_IPS_PATH
|
||||
@@ -7,16 +6,11 @@ from dzgui.config.convert import rc2json
|
||||
from dzgui.util._json import read_json, write_json
|
||||
|
||||
|
||||
# TODO: move to setup wizard
|
||||
def migrate_legacy_conf(config: Path) -> None:
|
||||
old_conf = Path.home() / LEGACY_CONFIG_PATH
|
||||
if old_conf.is_file():
|
||||
j = rc2json(old_conf)
|
||||
config.parent.mkdir(parents=True, exist_ok=True)
|
||||
config.write_text(j)
|
||||
else:
|
||||
print("Unimplemented. You must have a working dztuirc.")
|
||||
sys.exit(1)
|
||||
j = rc2json(old_conf)
|
||||
config.parent.mkdir(parents=True, exist_ok=True)
|
||||
config.write_text(j)
|
||||
|
||||
|
||||
def has_new_config(config: Path) -> bool:
|
||||
|
||||
+3
-20
@@ -20,6 +20,7 @@ def get_latest_release() -> str | None:
|
||||
try:
|
||||
res = requests.get(url, timeout=REQUEST_TIMEOUT)
|
||||
if res.status_code == 200:
|
||||
print(res.json())
|
||||
tag = res.json()["tag_name"]
|
||||
break
|
||||
except Exception as e:
|
||||
@@ -28,31 +29,13 @@ def get_latest_release() -> str | None:
|
||||
return tag
|
||||
|
||||
|
||||
def allow_updates(allow: bool) -> bool:
|
||||
if allow is False:
|
||||
return False
|
||||
if allow is True:
|
||||
return is_prefix_writeable()
|
||||
|
||||
|
||||
def check_updates(version: str) -> None:
|
||||
def check_updates(version: str) -> str | None:
|
||||
try:
|
||||
latest = get_latest_release()
|
||||
prefix = sys.prefix
|
||||
if latest is None:
|
||||
return
|
||||
if Version(version) >= Version(latest):
|
||||
return
|
||||
|
||||
# TODO: test update logic
|
||||
print("UNIMPLEMENTED: fetches in-app updates")
|
||||
return
|
||||
|
||||
with resources.path(APP_NAME_LOWER, "scripts/update.sh") as path:
|
||||
proc = subprocess.Popen(["/usr/bin/env", "bash", path, latest, prefix])
|
||||
if proc != 0:
|
||||
# TODO: pop a dialog
|
||||
pass
|
||||
sys.exit(proc)
|
||||
return latest
|
||||
except Exception:
|
||||
return
|
||||
Reference in new issue
Block a user