Update project, add verbosity option to podlaunch

Use /infra as base directory instead of /docker
This commit is contained in:
Ben 2023-09-23 00:36:58 +02:00
parent 03dbe75cf1
commit 2971420a3c
Signed by: ben
GPG Key ID: 0F54A7ED232D3319
6 changed files with 16 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" />
</component>

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -10,7 +10,7 @@ Type=oneshot
Environment=PODMAN_SYSTEMD_UNIT=%n
LogExtraFields=IMAGE=%i
ExecCondition=/usr/bin/bash -c '[[ $(podman images --format json localhost/%i | jq .\\[0\\]) == "null" ]]'
Environment="IMAGE_TAG=localhost/%i" "BUILD_SOURCE=/docker/containers/%i"
Environment="IMAGE_TAG=localhost/%i" "BUILD_SOURCE=/infra/containers/%i"
ExecStart=/usr/bin/podman build --tag ${IMAGE_TAG} $EXTRAOPTS ${BUILD_SOURCE}
Restart=no
RemainAfterExit=no
@ -18,4 +18,3 @@ TimeoutStartSec=1h
SendSIGKILL=no
LogRateLimitIntervalSec=15min
LogRateLimitBurst=1500

View File

@ -11,7 +11,7 @@ import sh
from sh import podman
from sh import systemctl
SERVICES_BASE_PATH = "/docker/services/"
SERVICES_BASE_PATH = "/infra/services/"
def resolve_image_units():
@ -91,11 +91,8 @@ def resolve_image_units():
@click.option("--verbose", is_flag=True, default=False, help="Enable INFO logging")
def main(verbose):
if verbose:
loglevel = logging.INFO
else:
loglevel = logging.CRITICAL
logging.root.setLevel(logging.INFO)
logging.basicConfig(level=loglevel)
image_units = resolve_image_units()
image_tags: Set[str] = set()
@ -172,4 +169,5 @@ def main(verbose):
if __name__ == "__main__":
logging.basicConfig(level=logging.ERROR)
main()

11
main.py
View File

@ -13,7 +13,7 @@ import click
import sh
from sh import podman
SERVICES_BASE_PATH = "/docker/services/"
SERVICES_BASE_PATH = "/infra/services/"
# noinspection PyCallingNonCallable
shlog = sh(_out=sys.stdout, _err=sys.stderr)
@ -157,9 +157,13 @@ class PodKeeper:
@click.option("--replace/--no-replace", default=True, help="Controls replacement of previously running pod with the "
"same name")
@click.option("--remove/--keep", default=True, help="Controls removal of pod after stopping")
@click.option("--verbose", is_flag=True, default=False, help="Enable DEBUG logging")
@click.argument("identifier")
def main(network, log_driver, log_level, replace, remove, identifier):
logging.basicConfig(level=logging.INFO)
def main(network, log_driver, log_level, replace, remove, verbose, identifier):
if verbose:
logging.root.setLevel(logging.DEBUG)
else:
logging.root.setLevel(logging.INFO)
keeper = PodKeeper(
network=network,
@ -182,4 +186,5 @@ def main(network, log_driver, log_level, replace, remove, identifier):
if __name__ == '__main__':
logging.basicConfig()
main()

View File

@ -1,2 +1,2 @@
click~=8.0.1
sh~=1.14.2
click~=8.1.7
sh~=1.14.3