implement mongodb post and getall todo: get single

This commit is contained in:
Manuel Hude
2020-11-28 20:30:13 +01:00
parent c52f031845
commit 39f0beb87e
7 changed files with 132 additions and 11 deletions
+53
View File
@@ -38,6 +38,34 @@ def send_image(identifier, image_path, metadata_payload):
return True
def get_image(identifier):
print("Getting image with identifier "+identifier)
baseurl = "http://127.0.0.1:8000"
get_url = "/image/get?id="+identifier
try:
response = requests.get(baseurl + get_url)
print_response(response)
except os.error:
print("Error sending request")
return True
def get_all():
print("Getting all images")
baseurl = "http://127.0.0.1:8000"
get_url = "/image/get"
try:
response = requests.get(baseurl + get_url)
print_response(response)
except os.error:
print("Error sending request")
return True
metadata = None
index = 0
metadata_folder = "." + os.path.sep
@@ -85,6 +113,8 @@ while (command.lower() not in ["exit", "quit", "end"]):
print("imagefolder <path> - selected new image folder")
print("show - opens image next in line in default os program")
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("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")
@@ -157,6 +187,29 @@ while (command.lower() not in ["exit", "quit", "end"]):
send_image(filename[:-4], image_folder + os.path.sep + filename, meta_payload)
index = index + 1
if command.lower() == "fetch":
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])
index = index + 1
if command.lower() == "fetchall":
if metadata is None:
print("No metadata loaded")
continue
if image_folder is None:
print("No image folder selected")
continue
get_all()
index = index + 1
if command.lower() == "rapid":
if metadata is None:
print("No metadata loaded")