51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Delete one channel's {channel_name}/ tree; leave shared details/ and lab_seeds.json intact."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import shutil
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import build as xxbb_build
|
|
|
|
RESULT_MARKER = "CORUNA_BUILD_RESULT "
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="Remove {channel_name}/ from artifact root")
|
|
parser.add_argument("--channel-name", required=True)
|
|
parser.add_argument(
|
|
"--artifact-root",
|
|
type=Path,
|
|
default=xxbb_build.PROJECT_ROOT / "public",
|
|
help="shared artifact root (default: coruna-lab/public)",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
channel_name = xxbb_build.validate_channel_name(args.channel_name)
|
|
artifact_root = args.artifact_root.resolve()
|
|
channel_dir = artifact_root / xxbb_build.CHANNEL_ROOT / channel_name
|
|
removed = False
|
|
if channel_dir.is_dir():
|
|
shutil.rmtree(channel_dir)
|
|
removed = True
|
|
print(f"removed {channel_dir}")
|
|
else:
|
|
print(f"missing {channel_dir} (noop)")
|
|
|
|
result = {
|
|
"status": "deleted" if removed else "absent",
|
|
"channel_name": channel_name,
|
|
"artifact_root": str(artifact_root),
|
|
"removed": removed,
|
|
}
|
|
print(RESULT_MARKER + json.dumps(result, separators=(",", ":")), flush=True)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|