I was looking at my build scripts and was reminded by the remnants of my attempts to properly parse the result from uploading a bundle to a Roku. As a reminder, not much thinking about automatic that has been done, so after CURL POST-ing the zip (das ist gut!), one gets back a messy HTML (nicht sehr gut...). One stares at HTML for a while and says "oh i know, all the relevant parts are bracketed inside <font color="red"/>:
<font color="red">Application Received: 576220 bytes stored.
</font>
<font color="red">Install Success.</font>
Years ago i used
grep to fetch that - and i lived happily ever after... until i upgraded my old OSX and discovered Apple have replaced
grep with another version that does not support PCRE (no "grep -P"). But you see, i needed that extended mode because sometimes the <font> tags bracket on the same line but sometimes is multi-line. So a double-whammy (%#^@&*#@^& credit goes both to RokuCo and Apple).
Thus i had to look for a new way to do it - and here is what i use now - i still wince a little that i had to summon python to do such a trivial job:
curl -f -sS --user rokudev:nuisance --anyauth -F "mysubmit=Install" -F "archive=@bundle.zip" -F "passwd=" http://$ROKU_DEV_TARGET/plugin_install \
| python -c 'import sys, re; print "\n".join(re.findall("<font color=\"red\">(.*?)</font>", sys.stdin.read(), re.DOTALL))'
#| python -c 'import sys; print "\n".join(x.split("</font>")[0] for x in sys.stdin.read().split("<font color=\"red\">")[1:])'
#| awk '/<font color="red">(.*)<\/font>/ {print $1}'
#| sed -n '/<font color="red">/,/<\/font>/p'
#| sed '/<\/font>/,/<font color="red">/d'
#| sed '1,/<font color="red">/d;/<\/font>/,/<font color="red">/d;/<\/font>/,$d'
#| sed -n 's/<font color="red">\(.*\)<\/font>/\1/'
#| sed -e '/<font color="red">/,/<\/font>/!d'
#| sed -n '/<font color="red">/,/<\/font>/p'
#| sed -n '/<font color="red">/,/</font>/p'
#| sed 's/<\/font>//'
For public amusement, I left beneath commented out my previous tEtanic efforts to accomplish the job with SED or AWK. The twist - where sometimes the pattern is on one line and sometimes on multiple - turned out a major tripping point. Seriously though? I know there are people around that know sed/awk - no trivial way to do that, is there?
What do you guys use?
Also, wasn't there some file/folder where the result is available in plain text? I seem to vaguely remember there was a place one could http-peek at...