spcd/spcd/cmd.py
Marc Beninca 6fbaf34915
Some checks failed
/ job (push) Failing after 2m7s
sync
2024-07-17 14:29:27 +02:00

64 lines
1.2 KiB
Python

import os
from pathlib import Path
import env
from rwx import ps
from rwx.log import stream as log
from spcd.ci import project, projects
from spcd.util import browse, split
def spcd_browse_workspace() -> None:
browse(project.root)
def spcd_build_project() -> None:
for extension in ["py", "sh"]:
path = Path(project.root) / f"build.{extension}"
if path.exists():
ps.run(path)
break
else:
pass
def spcd_clone_branch() -> None:
log.info(projects)
split()
log.info(project)
split()
log.info(f"""\
{project.url}
""")
ps.run(
"git",
"clone",
"--branch",
project.branch,
"--",
project.url,
project.root,
)
def spcd_list_environment() -> None:
for variable, value in sorted(projects.environment.items()):
log.info(f"{variable} = {value}")
def spcd_synchronize() -> None:
host = env.SPCD_PROJECT_PATH
source = "out"
user = "cd"
root = Path(os.sep) / user / project.branch / projects.group / project.name
target = f"{user}@{host}:{root}"
ps.run(
"rsync",
"--archive",
"--delete-before",
"--verbose",
f"{source}/",
f"{target}/",
)