Updated recovery logic to fall back on older version if no image-hash is valid

This commit is contained in:
Martin Schett
2021-01-09 21:47:03 +01:00
parent cd707226f6
commit 1ed0627853
7 changed files with 111 additions and 15 deletions
+23 -1
View File
@@ -73,11 +73,13 @@ def update_image(identifier, image_path, metadata_payload):
return True
def get_image(identifier):
def get_image(identifier, version=None):
print("Getting image with identifier " + identifier)
baseurl = "http://127.0.0.1:8000"
get_url = "/image/get/" + identifier
if version is not None:
get_url = get_url + "/version/"+str(version)
try:
response = requests.get(baseurl + get_url)
@@ -248,6 +250,7 @@ while (command.lower() not in ["exit", "quit", "end"]):
print("trigger - next image in line is sent to backend")
print("update - next image in line is updated in backend")
print("fetch - gets the next image from database if exists")
print("fetchversion - gets the next image with specified version from database if exists")
print("fetchall - get all images")
print("delete - delets the next image from db if exists")
print("deleteall - delets all images from the service")
@@ -354,6 +357,25 @@ while (command.lower() not in ["exit", "quit", "end"]):
get_image(filename[:-4])
print_cursor()
if command.lower() == "fetchversion":
if (len(attributes) < 1):
print("Error: No version supplied")
continue
if not attributes[0].isnumeric():
print("Version is no number")
continue
version = int(attributes[0])
if metadata is None:
print("No metadata loaded")
continue
if image_folder is None:
print("No image folder selected")
continue
meta_payload = metadata[index]
filename = meta_payload['filename']
get_image(filename[:-4], version)
print_cursor()
if command.lower() == "fetchall":
if metadata is None:
print("No metadata loaded")