add new constants

to make things clearer
This commit is contained in:
stev 2023-09-04 22:41:22 +02:00
parent ffc3c7cdcf
commit a727afe705
2 changed files with 18 additions and 13 deletions

View file

@ -14,4 +14,6 @@ DIR_HELPER = WORKDIR / config["dir_helper"]
DIR_O_HTML = WORKDIR / config["dir_o_html"] DIR_O_HTML = WORKDIR / config["dir_o_html"]
GMI_FOOTER = WORKDIR / "footer.gmi" GMI_FOOTER = WORKDIR / "footer.gmi"
REM_HTML = config["rem_html"]
REM_GMI = config["rem_gmi"]
RPORT = config["port"] RPORT = config["port"]

View file

@ -1,26 +1,29 @@
import typer import typer
import subprocess import subprocess
import shlex 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 = typer.Typer(help="syncs your files with configured remote")
@app.command("gmi") @app.command("gmi")
def sync_gmi(): def sync_gmi():
print("Synchronising GMI content with remote...") print("Synchronising GMI content with remote...")
LGMI = WORKDIR / "content" print(f'rsync -aP -e "ssh -p {RPORT}" {DIR_SOURCE} {REM_GMI}')
RGMI = config["rem_gmi"]
subprocess.call( 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!") print("Done!")
@app.command("html") @app.command("html")
def sync_html(): def sync_html():
print("Synchronising HTML content with remote...") print("Synchronising HTML content with remote...")
LHTML = WORKDIR / config["dir_o_html"]
RHTML = config["rem_html"]
subprocess.call( 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!") print("Done!")