delete functionality for metadata

This commit is contained in:
Manuel Hude
2020-11-30 14:23:32 +01:00
parent 2e58c64ced
commit d7e2bf651b
3 changed files with 47 additions and 0 deletions
+28
View File
@@ -69,6 +69,21 @@ def get_image(identifier):
return True
def delete_image(identifier):
print("Deleting image with identifier "+identifier)
baseurl = "http://127.0.0.1:8000"
get_url = "/image/delete/"+identifier
try:
response = requests.delete(baseurl + get_url)
payload = response.json()
print(payload)
except os.error:
print("Error deleting request")
return True
def get_all():
print("Getting all images")
@@ -132,6 +147,7 @@ while (command.lower() not in ["exit", "quit", "end"]):
print("trigger - next image in line is sent to backend")
print("fetch - gets the next image from database if exists")
print("fetchall - get all images")
print("delete - delets the next image from db if exists")
print("rapid <#amount> - next <amound> images in line are sent to backend in 2 second intervals")
print("skip [<#amount>] - skips the next <amount> number of images in line or 1 if no <amount> is given")
print("set <#index> - sets image on given <index> as next in line")
@@ -227,6 +243,18 @@ while (command.lower() not in ["exit", "quit", "end"]):
get_all()
index = index + 1
if command.lower() == "delete":
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']
delete_image(filename[:-4])
index = index + 1
if command.lower() == "rapid":
if metadata is None:
print("No metadata loaded")