#!/bin/bash

STORAGEDIR=${var_nomad_dir}/storage/plugins/print3d
CACHEDIR=${STORAGEDIR}/cache
PCONFIG=${STORAGEDIR}/printers/${field_printer}
# FILE=${STORAGEDIR}/files/${field_file}
FILE="${field_url##*/}"
echo ${FILE}

echo "submitting job..."

source ${var_nomad_dir}/plugins/print3d/venv/bin/activate && python3 ${var_nomad_dir}/plugins/print3d/fetcher/fetcher.py ${field_url} ${STORAGEDIR}/cache >/dev/null 2>&1

${var_nomad_dir}/plugins/print3d/prusatool --printer-config ${PCONFIG} load ${STORAGEDIR}/cache/${FILE} --print-immediately

echo "...job submitted successfully"
