parent
3891e7d58a
commit
96c3313ddf
3 changed files with 14 additions and 15 deletions
|
@ -12,14 +12,9 @@ from rwx.log import stream as log
|
||||||
|
|
||||||
import spcd
|
import spcd
|
||||||
from spcd import cmd
|
from spcd import cmd
|
||||||
from spcd.project import Project
|
|
||||||
from spcd.projects import Projects
|
|
||||||
|
|
||||||
COMMANDS_PREFIX = "spcd-"
|
COMMANDS_PREFIX = "spcd-"
|
||||||
|
|
||||||
projects = Projects()
|
|
||||||
project = Project(projects)
|
|
||||||
|
|
||||||
|
|
||||||
def browse(root: str) -> None:
|
def browse(root: str) -> None:
|
||||||
paths = []
|
paths = []
|
||||||
|
@ -67,27 +62,27 @@ def main(main: str) -> None:
|
||||||
|
|
||||||
def set_ssh(*arguments: list[str]) -> None:
|
def set_ssh(*arguments: list[str]) -> None:
|
||||||
step("Set SSH")
|
step("Set SSH")
|
||||||
#
|
# get variables
|
||||||
ssh_key, ssh_hosts = arguments
|
ssh_key, ssh_hosts = arguments
|
||||||
#
|
# set key type
|
||||||
ssh_type = "ed25519"
|
ssh_type = "ed25519"
|
||||||
#
|
# set home directory
|
||||||
home = Path("~").expanduser()
|
home = Path("~").expanduser()
|
||||||
#
|
# make home directory
|
||||||
ssh = home / ".ssh"
|
ssh = home / ".ssh"
|
||||||
ssh.mkdir(exist_ok=True, parents=True)
|
ssh.mkdir(exist_ok=True, parents=True)
|
||||||
ssh.chmod(0o700)
|
ssh.chmod(0o700)
|
||||||
#
|
# write private key
|
||||||
key = ssh / f"id_{ssh_type}"
|
key = ssh / f"id_{ssh_type}"
|
||||||
if ssh_key:
|
if ssh_key:
|
||||||
fs.write(key, ssh_key)
|
fs.write(key, ssh_key)
|
||||||
key.chmod(0o400)
|
key.chmod(0o400)
|
||||||
#
|
# write known hosts
|
||||||
known = ssh / "known_hosts"
|
known = ssh / "known_hosts"
|
||||||
if ssh_hosts:
|
if ssh_hosts:
|
||||||
fs.write(known, ssh_hosts)
|
fs.write(known, ssh_hosts)
|
||||||
known.chmod(0o400)
|
known.chmod(0o400)
|
||||||
#
|
# display
|
||||||
browse(ssh)
|
browse(ssh)
|
||||||
cat(known)
|
cat(known)
|
||||||
|
|
||||||
|
|
5
spcd/ci.py
Normal file
5
spcd/ci.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from spcd.project import Project
|
||||||
|
from spcd.projects import Projects
|
||||||
|
|
||||||
|
projects = Projects()
|
||||||
|
project = Project(projects)
|
|
@ -1,10 +1,11 @@
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from ci import project, projects
|
||||||
from rwx import ps
|
from rwx import ps
|
||||||
from rwx.log import stream as log
|
from rwx.log import stream as log
|
||||||
|
|
||||||
from spcd import browse, project, projects, split
|
from spcd import browse, split
|
||||||
|
|
||||||
|
|
||||||
def spcd_browse_workspace() -> None:
|
def spcd_browse_workspace() -> None:
|
||||||
|
@ -50,9 +51,7 @@ def spcd_synchronize() -> None:
|
||||||
host = "rwx.work"
|
host = "rwx.work"
|
||||||
source = "out"
|
source = "out"
|
||||||
user = "cd"
|
user = "cd"
|
||||||
#
|
|
||||||
root = Path(os.sep) / user / project.branch / projects.group / project.name
|
root = Path(os.sep) / user / project.branch / projects.group / project.name
|
||||||
#
|
|
||||||
target = f"{user}@{host}:{root}"
|
target = f"{user}@{host}:{root}"
|
||||||
ps.run(
|
ps.run(
|
||||||
"rsync",
|
"rsync",
|
||||||
|
|
Loading…
Reference in a new issue