Fix arguments passing when reincarnating.
This commit is contained in:
parent
9164c02a3e
commit
2e005bd48e
2 changed files with 19 additions and 6 deletions
|
|
@ -94,7 +94,7 @@ def setup(args: cli.Args):
|
||||||
model.Project.ensure()
|
model.Project.ensure()
|
||||||
print(f"Reincarnating into pod '{pod[len(podPrefix) :]}'...")
|
print(f"Reincarnating into pod '{pod[len(podPrefix) :]}'...")
|
||||||
try:
|
try:
|
||||||
strippedArgsV = list(sys.argv[1])
|
strippedArgsV = list(sys.argv[1:])
|
||||||
strippedArgsV = [arg for arg in strippedArgsV if not arg.startswith("--pod=")]
|
strippedArgsV = [arg for arg in strippedArgsV if not arg.startswith("--pod=")]
|
||||||
|
|
||||||
shell.exec(
|
shell.exec(
|
||||||
|
|
@ -148,7 +148,7 @@ def _(args: cli.Args):
|
||||||
except docker.errors.NotFound:
|
except docker.errors.NotFound:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
print(f"Staring pod '{name[len(podPrefix) :]}'...")
|
print(f"Starting pod '{name[len(podPrefix) :]}'...")
|
||||||
|
|
||||||
container = client.containers.run(
|
container = client.containers.run(
|
||||||
image.image,
|
image.image,
|
||||||
|
|
@ -180,10 +180,20 @@ def _(args: cli.Args):
|
||||||
def _(args: cli.Args):
|
def _(args: cli.Args):
|
||||||
client = docker.from_env()
|
client = docker.from_env()
|
||||||
name = str(args.consumeOpt("name", defaultPodName))
|
name = str(args.consumeOpt("name", defaultPodName))
|
||||||
|
all = args.consumeOpt("all", False) is True
|
||||||
if not name.startswith(podPrefix):
|
if not name.startswith(podPrefix):
|
||||||
name = f"{podPrefix}{name}"
|
name = f"{podPrefix}{name}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if all:
|
||||||
|
for container in client.containers.list(all=True):
|
||||||
|
if not container.name.startswith(podPrefix):
|
||||||
|
continue
|
||||||
|
container.stop()
|
||||||
|
container.remove()
|
||||||
|
print(f"Pod '{container.name[len(podPrefix) :]}' killed")
|
||||||
|
return
|
||||||
|
|
||||||
container = client.containers.get(name)
|
container = client.containers.get(name)
|
||||||
container.stop()
|
container.stop()
|
||||||
container.remove()
|
container.remove()
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,15 @@ class Uname:
|
||||||
|
|
||||||
def uname() -> Uname:
|
def uname() -> Uname:
|
||||||
un = platform.uname()
|
un = platform.uname()
|
||||||
|
|
||||||
if hasattr(platform, "freedesktop_os_release"):
|
if hasattr(platform, "freedesktop_os_release"):
|
||||||
distrib = platform.freedesktop_os_release()
|
distrib = platform.freedesktop_os_release()
|
||||||
else:
|
else:
|
||||||
distrib = {"NAME": "Unknown"}
|
distrib = {"NAME": "Unknown"}
|
||||||
|
|
||||||
result = Uname(un.system, distrib['NAME'], un.node, un.release, un.version, un.machine)
|
result = Uname(
|
||||||
|
un.system, distrib["NAME"], un.node, un.release, un.version, un.machine
|
||||||
|
)
|
||||||
|
|
||||||
match result.machine:
|
match result.machine:
|
||||||
case "aarch64":
|
case "aarch64":
|
||||||
|
|
@ -65,7 +67,7 @@ def find(
|
||||||
if isinstance(path, list):
|
if isinstance(path, list):
|
||||||
for p in path:
|
for p in path:
|
||||||
result += find(p, wildcards, recusive)
|
result += find(p, wildcards, recusive)
|
||||||
return result
|
return sorted(result)
|
||||||
|
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
return []
|
return []
|
||||||
|
|
@ -90,7 +92,8 @@ def find(
|
||||||
result.append(os.path.join(path, f))
|
result.append(os.path.join(path, f))
|
||||||
break
|
break
|
||||||
|
|
||||||
return result
|
# sort for reproducibility
|
||||||
|
return sorted(result)
|
||||||
|
|
||||||
|
|
||||||
def mkdir(path: str) -> str:
|
def mkdir(path: str) -> str:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue