Skip to content
Snippets Groups Projects
Commit 44e806a0 authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

Merge branch '34-rematch-function-and-endpoint' of...

Merge branch '34-rematch-function-and-endpoint' of https://git.gvk.idi.ntnu.no/HermanDyrkorn/salamander-api into 34-rematch-function-and-endpoint
parents c9f90962 19de9fec
No related branches found
No related tags found
1 merge request!37Resolve "rematch function and endpoint"
......@@ -121,29 +121,17 @@ class SalamanderClass(Resource):
else:
original_image_path = sorted(glob.glob(os.path.join(salamander_path, '*[!_str].*')))[-1]
original_id = int(os.path.basename(original_image_path).split(".")[0])
processed_image_path = sorted(glob.glob(os.path.join(salamander_path, '*_str.*')))[-1]
# processed_name = os.path.basename(processed_image_path).split(".")[0]
# original_name = os.path.basename(processed_image_path)
original_extension = os.path.splitext(original_image_path)[1]
processed_extension = os.path.splitext(processed_image_path)[1]
print("new logic: ")
print(original_image_path)
print(processed_image_path)
print(original_extension)
print(processed_extension)
print(original_id)
salamander_growth_row = db.session.query(SalamanderGrowth).filter_by(
salamander_id=salamander.id, image_id=original_id).first()
if salamander_growth_row:
salamander_growth_row.image_id = image_id
db.session.commit()
os.rename(processed_image_path, os.path.join(salamander_path, str(
image_id) + "_str" + processed_extension))
os.rename(original_image_path,
os.path.join(salamander_path, str(image_id) + original_extension))
os.rename(processed_image_path, os.path.join(salamander_path, str(image_id) + "_str" + processed_extension))
os.rename(original_image_path, os.path.join(salamander_path, str(image_id) + original_extension))
# Small note for future programmers by the guy who wrote this function:
# After a discussion we concluded that the file names were collapsed rather than moving
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment