diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2d9c8a9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "fetcher"] + path = fetcher + url = https://git.glyphs.tech/sigil-03/nomadnet-file-fetcher.git diff --git a/fetcher b/fetcher new file mode 160000 index 0000000..742a4a7 --- /dev/null +++ b/fetcher @@ -0,0 +1 @@ +Subproject commit 742a4a70047e748a25bd5407ad14ae85d9603079 diff --git a/install.sh b/install.sh index c5d43e7..fc25cbf 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,12 @@ #!/bin/sh +git submodule update --init --recursive mkdir -p ${HOME}/.nomadnetwork/storage/plugins/print3d/files/ mkdir -p ${HOME}/.nomadnetwork/storage/plugins/print3d/printers/ +mkdir -p ${HOME}/.nomadnetwork/storage/plugins/print3d/cache/ mkdir -p ${HOME}/.nomadnetwork/storage/pages/print3d/ yes | cp -rf ./pages/* ${HOME}/.nomadnetwork/storage/pages/print3d + +python3 -m venv venv && source venv/bin/activate && pip install -r fetcher/requirements.txt + echo "print3d installed, make sure to make pages/print3d/index.mu accessible!" +echo "remote print3d installed, make sure to make pages/print3d/remote_print.mu accessible!" diff --git a/pages/remote_print.mu b/pages/remote_print.mu new file mode 100755 index 0000000..4dc2432 --- /dev/null +++ b/pages/remote_print.mu @@ -0,0 +1,27 @@ +#!/bin/python + +import os +from os import listdir +from os.path import isfile, join + +userdir = os.path.expanduser("~") +nomaddir = userdir+"/.nomadnetwork" + + +print("> PRINTERS") +printers = [f for f in listdir(nomaddir+'/storage/plugins/print3d/printers')] +if len(printers) == 0: + print("no printer config files available :(") + print("add printer config files to: ~/.nomadnetwork/storage/plugins/print3d/printers/") + +else: + for p in printers: + print("""`<^|printer|{p}`>`b {p}""".format(p=p)) + +print("\n") +print("> FILE") +print("print file URL: `B444``b") +print("\n") +print("> SUBMIT") +print("""`!`[>SUBMIT<`:/page/print3d/submit_remote.mu`printer|url|nomad_dir={ndir}]`!""".format(ndir=nomaddir)) + diff --git a/pages/submit_remote.mu b/pages/submit_remote.mu new file mode 100755 index 0000000..02bd63e --- /dev/null +++ b/pages/submit_remote.mu @@ -0,0 +1,16 @@ +#!/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"