reformat code;
This commit is contained in:
parent
8748611fa6
commit
4b6052f502
@ -5,12 +5,15 @@ import json
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def print_response(response):
|
||||
print("Code: " + str(response.status_code) + "; Body: " + str(response.json()))
|
||||
|
||||
|
||||
def unwrap_file(file_str: str) -> bytes:
|
||||
return base64.b64decode(file_str)
|
||||
|
||||
|
||||
def send_image(identifier, image_path, metadata_payload):
|
||||
print("Sending image with identifier " + identifier)
|
||||
if not os.path.isfile(image_path):
|
||||
@ -55,7 +58,8 @@ def get_image(identifier):
|
||||
goal_folder_name = "images_fetch"
|
||||
path = "../../" + goal_folder_name + "/" + payload['metadata']['filename']
|
||||
|
||||
goal_folder_path = os.path.sep.join(os.path.abspath(__file__).split(os.path.sep)[:-3]) + os.path.sep + goal_folder_name
|
||||
goal_folder_path = os.path.sep.join(
|
||||
os.path.abspath(__file__).split(os.path.sep)[:-3]) + os.path.sep + goal_folder_name
|
||||
|
||||
if not os.path.isdir(goal_folder_path):
|
||||
os.mkdir(goal_folder_path)
|
||||
@ -84,7 +88,6 @@ def delete_image(identifier):
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def get_all():
|
||||
print("Getting all images")
|
||||
|
||||
@ -98,6 +101,7 @@ def get_all():
|
||||
print("Error sending request")
|
||||
return True
|
||||
|
||||
|
||||
metadata = None
|
||||
index = 0
|
||||
metadata_folder = "." + os.path.sep
|
||||
@ -106,10 +110,10 @@ metadata_path = metadata_folder + os.path.sep + metadata_file
|
||||
|
||||
image_folder = "." + os.path.sep + "images"
|
||||
|
||||
|
||||
if (os.path.isfile(metadata_path)):
|
||||
print("Loading metadata to memory from " + metadata_path)
|
||||
metadata = sorted(json.load(open(metadata_file, "r")), key=lambda k: datetime.strptime(k['datetime'], '%d-%b-%Y (%H:%M:%S.%f)'))
|
||||
metadata = sorted(json.load(open(metadata_file, "r")),
|
||||
key=lambda k: datetime.strptime(k['datetime'], '%d-%b-%Y (%H:%M:%S.%f)'))
|
||||
else:
|
||||
print("Default metadata_file not found.")
|
||||
|
||||
@ -184,7 +188,8 @@ while (command.lower() not in ["exit", "quit", "end"]):
|
||||
print("Error: No file on path " + path)
|
||||
continue
|
||||
print("Loading metadata to memory from " + path)
|
||||
metadata = sorted(json.load(open(metadata_file, "r")), key=lambda k: datetime.strptime(k['datetime'], '%d-%b-%Y (%H:%M:%S.%f)'))
|
||||
metadata = sorted(json.load(open(metadata_file, "r")),
|
||||
key=lambda k: datetime.strptime(k['datetime'], '%d-%b-%Y (%H:%M:%S.%f)'))
|
||||
index = 0
|
||||
|
||||
if command.lower() == "imagefolder":
|
||||
@ -232,7 +237,6 @@ while (command.lower() not in ["exit", "quit", "end"]):
|
||||
get_image(filename[:-4])
|
||||
index = index + 1
|
||||
|
||||
|
||||
if command.lower() == "fetchall":
|
||||
if metadata is None:
|
||||
print("No metadata loaded")
|
||||
@ -310,7 +314,6 @@ while (command.lower() not in ["exit", "quit", "end"]):
|
||||
continue
|
||||
index = ind
|
||||
|
||||
|
||||
if command.lower() == "select":
|
||||
if metadata is None:
|
||||
print("Please first select metadata")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user