From a727afe705c8c5dc21478d74d382108620974bcc Mon Sep 17 00:00:00 2001 From: stev Date: Mon, 4 Sep 2023 22:41:22 +0200 Subject: [PATCH] add new constants to make things clearer --- gmirator/__init__.py | 14 ++++++++------ gmirator/synchronise.py | 17 ++++++++++------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/gmirator/__init__.py b/gmirator/__init__.py index 42b6130..7a67d4a 100644 --- a/gmirator/__init__.py +++ b/gmirator/__init__.py @@ -8,10 +8,12 @@ with open(cfg_file) as f: config = json.load(f) WORKDIR = Path(config["workdir"]) -DIR_ASSETS = WORKDIR / config["dir_assets"] -DIR_SOURCE = WORKDIR / config["dir_source"] -DIR_HELPER = WORKDIR / config["dir_helper"] -DIR_O_HTML = WORKDIR / config["dir_o_html"] -GMI_FOOTER = WORKDIR / "footer.gmi" +DIR_ASSETS = WORKDIR / config["dir_assets"] +DIR_SOURCE = WORKDIR / config["dir_source"] +DIR_HELPER = WORKDIR / config["dir_helper"] +DIR_O_HTML = WORKDIR / config["dir_o_html"] +GMI_FOOTER = WORKDIR / "footer.gmi" -RPORT = config["port"] +REM_HTML = config["rem_html"] +REM_GMI = config["rem_gmi"] +RPORT = config["port"] diff --git a/gmirator/synchronise.py b/gmirator/synchronise.py index c29b07e..2dbf4ec 100644 --- a/gmirator/synchronise.py +++ b/gmirator/synchronise.py @@ -1,26 +1,29 @@ import typer import subprocess import shlex -from gmirator import WORKDIR, RPORT +from gmirator import ( + DIR_SOURCE, + DIR_O_HTML, + REM_HTML, + REM_GMI, + RPORT +) app = typer.Typer(help="syncs your files with configured remote") @app.command("gmi") def sync_gmi(): print("Synchronising GMI content with remote...") - LGMI = WORKDIR / "content" - RGMI = config["rem_gmi"] + print(f'rsync -aP -e "ssh -p {RPORT}" {DIR_SOURCE} {REM_GMI}') subprocess.call( - shlex.split(f'rsync -aP -e "ssh -p {RPORT}" {LGMI} {RGMI}') + shlex.split(f'rsync -aP -e "ssh -p {RPORT}" {DIR_SOURCE} {REM_GMI}') ) print("Done!") @app.command("html") def sync_html(): print("Synchronising HTML content with remote...") - LHTML = WORKDIR / config["dir_o_html"] - RHTML = config["rem_html"] subprocess.call( - shlex.split(f'rsync -aP -e "ssh -p {RPORT}" {LHTML} {RHTML}') + shlex.split(f'rsync -aP -e "ssh -p {RPORT}" {DIR_O_HTML} {REM_HTML}') ) print("Done!")