This commit is contained in:
Marc Beninca 2025-02-22 20:56:41 +01:00
parent 77e12933fd
commit 6a985e0b89
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

20
sync.py
View file

@ -1,10 +1,13 @@
#! /usr/bin/env python3
"""Synchronize to remote pubnixes."""
import os
import subprocess
from __future__ import annotations
from logging import log
from os import sep
from pathlib import Path
from pubnix import PubNix
import subprocess
ARGS = [
{
@ -41,7 +44,7 @@ ARGS = [
PUBNIXES = [PubNix(**args) for args in ARGS]
def sync(root: str, pubnix: PubNix, exclude: list[str] | None = None) -> None:
def sync(root: Path, pubnix: PubNix, exclude: list[str] | None = None) -> None:
"""Synchronize local root directory with pubnix."""
args = [
"rsync",
@ -53,17 +56,18 @@ def sync(root: str, pubnix: PubNix, exclude: list[str] | None = None) -> None:
"--partial",
"--progress",
"--verbose",
os.path.join(root, ""),
f"{root}{sep}",
]
for item in exclude:
args.extend(["--exclude", os.path.join("", item)])
args.append(os.path.join(pubnix.target, ""))
if exclude:
for item in exclude:
args.extend(["--exclude", f"{sep}{item}"])
args.append(f"{pubnix.target}{sep}")
subprocess.call(args, stdout=subprocess.DEVNULL)
def main() -> None:
"""Synchronize content on remote pubnixes."""
root = Path(os.path.realpath(__file__)).parent / "out" / "web"
root = Path(__file__).resolve().parent / "out" / "web"
for pn in PUBNIXES:
log()
log(pn)