Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
EnTerr
Roku Guru

How to parse the result from side-loading?

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...
0 Kudos
2 REPLIES 2
belltown
Roku Guru

Re: How to parse the result from side-loading?

It sucks that you can't use PCRE in OXS. Instead, can you change the line endings to something else (a space, for example) to get the string in a single line, e.g. curl xxxx | tr '\n' ' ' | grep yyyy ?
0 Kudos
TheEndless
Channel Surfer

Re: How to parse the result from side-loading?

My makefile uses the following... seems it ignores the end tag entirely...
curl --anyauth -u $(ROKU_DEV_USERNAME):$(ROKU_DEV_PASSWORD) -s -S -F "mysubmit=Install" -F "archive=@$(ZIPRELUNESCAPED)/$(PACKAGENAME).zip" -F "passwd=" http://$(ROKU_DEV_TARGET)/plugin_install | grep "<font color" | sed "s/<font color=\"red\">//"
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.