Delivery in LibraryLoader - fixes for missing source files

Fix for double dot in file name
This commit is contained in:
Petr Kalis 2021-05-20 17:46:56 +02:00
parent 0afa78f0e0
commit be3b277c2d
2 changed files with 19 additions and 7 deletions

View file

@ -125,7 +125,7 @@ def check_destination_path(repre_id,
def process_single_file(
src_path, _repre, anatomy, template_name, anatomy_data, format_dict,
src_path, repre, anatomy, template_name, anatomy_data, format_dict,
report_items, log
):
"""Copy single file to calculated path based on template
@ -143,6 +143,12 @@ def process_single_file(
Returns:
(collections.defaultdict , int)
"""
if not os.path.exists(src_path):
msg = "{} doesn't exist for {}".format(src_path,
repre["_id"])
report_items["Source file was not found"].append(msg)
return report_items, 0
anatomy_filled = anatomy.format(anatomy_data)
if format_dict:
template_result = anatomy_filled["delivery"][template_name]
@ -150,6 +156,9 @@ def process_single_file(
else:
delivery_path = anatomy_filled["delivery"][template_name]
# context.representation could be .psd
delivery_path = delivery_path.replace("..", ".")
delivery_folder = os.path.dirname(delivery_path)
if not os.path.exists(delivery_folder):
os.makedirs(delivery_folder)
@ -186,6 +195,12 @@ def process_sequence(
Returns:
(collections.defaultdict , int)
"""
if not os.path.exists(src_path):
msg = "{} doesn't exist for {}".format(src_path,
repre["_id"])
report_items["Source file was not found"].append(msg)
return report_items, 0
dir_path, file_name = os.path.split(str(src_path))
context = repre["context"]
@ -198,6 +213,8 @@ def process_sequence(
return report_items, 0
ext = "." + ext
# context.representation could be .psd
ext = ext.replace("..", ".")
src_collections, remainder = clique.assemble(os.listdir(dir_path))
src_collection = None

View file

@ -28,7 +28,7 @@ class Delivery(api.SubsetLoader):
representations = ["*"]
families = ["*"]
# tool_names = ["library_loader"]
tool_names = ["library_loader"]
label = "Deliver Versions"
order = 35
@ -173,11 +173,6 @@ class DeliveryOptionsDialog(QtWidgets.QDialog):
continue
repre_path = path_from_represenation(repre, anatomy)
if not os.path.exists(repre_path):
msg = "{} doesn't exist for {}".format(repre_path,
repre["_id"])
report_items["Source file was not found"].append(msg)
continue
anatomy_data = copy.deepcopy(repre["context"])
new_report_items = check_destination_path(str(repre["_id"]),