Add smart cursor stuff

This commit is contained in:
iamBadgers
2026-04-04 16:48:34 -07:00
parent cb5c08b92c
commit d549f7d83d
5 changed files with 86 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
import docker
from game_tables import GameTable
from game_tables import GameTable
def build_container_routing_labels(prefix: str, strip_prefix=True):
@@ -18,29 +18,27 @@ def build_container_routing_labels(prefix: str, strip_prefix=True):
prefix=prefix
)
if strip_prefix:
labels[middleware_key] = "/{prefix}".format(prefix=prefix)
labels[middleware_router_key] = "{prefix}-stripprefix".format(
prefix=prefix
)
labels[middleware_key] = "/{prefix}".format(prefix=prefix)
labels[middleware_router_key] = "{prefix}-stripprefix".format(prefix=prefix)
return labels
def stop_container(docker_id):
try:
client = docker.from_env()
container = client.containers.get(docker_id)
container.kill()
return True
client = docker.from_env()
container = client.containers.get(docker_id)
container.kill()
return True
except docker.errors.NotFound, docker.errors.APIError:
return False
return False
def start_foundry_container(table: GameTable, version=12):
client = docker.from_env()
container = None
if table.docker_id != None and table.docker_id != 0 and table.docker_id != Null:
if table.docker_id != None and table.docker_id != 0:
try:
container = client.containers.get(table.docker_id)
except docker.errors.NotFound, docker.errors.NullResource:
@@ -64,12 +62,15 @@ def start_foundry_container(table: GameTable, version=12):
"FOUNDRY_ROUTE_PREFIX={prefix}".format(prefix=table.game_table_link)
]
ports = {
"30000": str(30000 + table.game_table_id)
}
ports = {"30000": str(30000 + table.game_table_id)}
container = client.containers.run(
image=image, labels=labels, volumes=volumes, environment=environment, ports=ports, detach=True
image=image,
labels=labels,
volumes=volumes,
environment=environment,
ports=ports,
detach=True,
)
return container.id