From 4564ac3a85f45b7c2f4978702bd61a1cba4d3358 Mon Sep 17 00:00:00 2001 From: gretchen Date: Mon, 18 Nov 2019 17:05:16 -0800 Subject: Handle errors in upload. --- README.org | 2 +- norns_upload | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 0d50bef..11fdd6f 100644 --- a/README.org +++ b/README.org @@ -13,7 +13,7 @@ Three scripts useful for local development on norns (i.e., outside of the ~maide + ~norns_upload~: Upload a file to norns over http, just like how ~maiden~ does it. + ~norns_load~: Activate a norns script already on the device with ~norns.script.load(...)~ on the lua interface. -~norns_shell~ requires nanomsg. Install everything with ~sudo make install~. +~norns_shell~ requires nanomsg. ~norns_upload~ requires jq and curl. Install everything with ~sudo make install~. There's an example in ~example/~ of a project with a Makefile that uploads and loads when ~M-x compile~'d in emacs. This piece of emacs lisp may be helpful if you'd like to ~C-c C-c~ instead. diff --git a/norns_upload b/norns_upload index c67ea6c..73f34ee 100755 --- a/norns_upload +++ b/norns_upload @@ -38,6 +38,9 @@ echo $'\r\n'"--$BOUNDARY--"$'\r\n' >> $TEMP # thanks monome >:) curl -XPUT "$DIR_URL" --silent > /dev/null -# TODO this should exit 1 if this doesn't work -# looks like we need to parse this. -curl "$URL" -X PUT -H "Content-Type: multipart/form-data; boundary=$BOUNDARY" --data-binary @$TEMP --compressed --silent > /dev/null +# all we get is an error message in json if this fails +RESULT="$(curl "$URL" -X PUT -H "Content-Type: multipart/form-data; boundary=$BOUNDARY" --data-binary @$TEMP --compressed --silent)" +if jq -e ".error"<<<"$RESULT" >/dev/null; then + jq -r ".error" <<<"$RESULT" + exit 1 +fi -- cgit v1.2.1