aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgretchen <gretchen@gnar.cool>2019-11-18 17:05:16 -0800
committergretchen <gretchen@gnar.cool>2019-11-18 17:05:16 -0800
commit4564ac3a85f45b7c2f4978702bd61a1cba4d3358 (patch)
tree1db13120d5af689881558baadc3a942ff19565af
parentf40f6e25fe294df19bf09c1e7afbb73bea95a896 (diff)
downloadnorns-etc-4564ac3a85f45b7c2f4978702bd61a1cba4d3358.tar.gz
norns-etc-4564ac3a85f45b7c2f4978702bd61a1cba4d3358.zip
Handle errors in upload.
-rw-r--r--README.org2
-rwxr-xr-xnorns_upload9
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