mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-22 04:31:13 +01:00
Catched error if no local images exist
This commit is contained in:
parent
f0e5c2caa4
commit
f237cf140c
@ -34,11 +34,17 @@ def git_pull(directory):
|
|||||||
|
|
||||||
def get_image_digests(directory):
|
def get_image_digests(directory):
|
||||||
compose_project = os.path.basename(directory)
|
compose_project = os.path.basename(directory)
|
||||||
images_output = subprocess.check_output(
|
try:
|
||||||
f'docker images --format "{{{{.Repository}}}}:{{{{.Tag}}}}@{{{{.Digest}}}}" | grep {compose_project}',
|
images_output = subprocess.check_output(
|
||||||
shell=True
|
f'docker images --format "{{{{.Repository}}}}:{{{{.Tag}}}}@{{{{.Digest}}}}" | grep {compose_project}',
|
||||||
).decode().strip()
|
shell=True
|
||||||
return dict(line.split('@') for line in images_output.splitlines() if line)
|
).decode().strip()
|
||||||
|
return dict(line.split('@') for line in images_output.splitlines() if line)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
if e.returncode == 1: # grep no match found
|
||||||
|
return {}
|
||||||
|
else:
|
||||||
|
raise # Other errors are still raised
|
||||||
|
|
||||||
def update_docker(directory):
|
def update_docker(directory):
|
||||||
print(f"Checking for updates to Docker images in {directory}.")
|
print(f"Checking for updates to Docker images in {directory}.")
|
||||||
|
Loading…
Reference in New Issue
Block a user