Merge remote-tracking branch 'origin/master' into philip/kale

This commit is contained in:
Philip Monk 2019-08-06 15:47:20 -07:00
commit b0dee239e7
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
10 changed files with 143 additions and 53 deletions

View File

@ -24,6 +24,7 @@ do
sleep 1
done
cp $ARVO/app/lens.hoon ./pier/home/app/
cp $ARVO/lib/pill.hoon ./pier/home/lib/
chmod -R u+rw ./pier/home/lib/

View File

@ -1,19 +1,25 @@
/- lens
/+ *server, base64
/- lens, *sole
/+ base64, *server
/= lens-mark /: /===/mar/lens/command
/!noun/
=, format
|%
:: +move: output effect
:: +lens-out: json or named octet-stream
::
+$ lens-out
$% [%json =json]
[%mime =mime]
==
:: +move: output effect
::
+$ move [bone card]
:: +card: output effect payload
:: +card: output effect payload
::
+$ card
$% [%connect wire binding:eyre term]
[%http-response =http-event:http]
[%peer wire dock path]
[%peel wire dock mark path]
[%peer wire dock path]
[%poke wire dock poke]
[%pull wire dock ~]
==
@ -80,16 +86,74 @@
[ost.bow %poke /import [our.bow app.source.com] %import c]~
::
:_ this(job.state (some [ost.bow com]))
[ost.bow %peel /sole [our.bow %dojo] %lens-json /sole]~
[ost.bow %peer /sole [our.bow %dojo] /sole]~
::
++ diff-lens-json
|= [=wire jon=json]
++ diff-sole-effect
|= [=wire fec=sole-effect]
^- (quip move _this)
?~ jon
=/ out
|- ^- (unit lens-out)
=* loop $
?+ -.fec
~
::
%tan
%- some
:- %json
%- wall:enjs:format
(turn (flop p.fec) |=(=tank ~(ram re tank)))
::
%txt
(some %json s+(crip p.fec))
::
%sag
%- some
[%mime p.fec (as-octs:mimes:html (jam q.fec))]
::
%sav
:: XX use +en:base64 or produce %mime a la %sag
::
%- some
:- %json
%- pairs:enjs:format
:~ file+s+(crip <`path`p.fec>)
data+s+(crip (en-base64:mimes:html q.fec))
==
::
%mor
=/ all `(list lens-out)`(murn p.fec |=(a=sole-effect loop(fec a)))
?~ all ~
~| [%multiple-effects all]
?> ?=(~ t.all)
(some i.all)
==
::
?~ out
[~ this]
?> ?=(^ job.state)
:_ this(job.state ~)
[bone.u.job.state %http-response (json-response:app (json-to-octs jon))]~
:_ ~
:+ bone.u.job.state
%http-response
?- -.u.out
%json
(json-response:app (json-to-octs json.u.out))
::
%mime
:* %start
:~ 200
['content-type' 'application/octet-stream']
?> ?=([@ @ ~] p.mime.u.out)
:- 'content-disposition'
^- @t
%^ cat 3
'attachment; filename='
(rap 3 '"' i.p.mime.u.out '.' i.t.p.mime.u.out '"' ~)
==
(some q.mime.u.out)
%.y
==
==
::
++ diff-export
|= [=wire data=*]
@ -132,6 +196,8 @@
?> ?=(^ job.state)
:_ this
:~ [ost.bow %poke /sole [our.bow %dojo] %lens-command com.u.job.state]
:: XX move to +diff-sole-effect?
::
[ost.bow %pull /sole [our.bow %dojo] ~]
==
::

View File

@ -1,12 +0,0 @@
::
:::: /hoon/json/lens/mar
::
/? 310
::
:::: ~fyr
::
|_ jon/json
++ grab |% ++ noun json
--
++ grow |% ++ json jon
-- --

View File

@ -50,27 +50,6 @@
++ grow
=, enjs
|%
++ lens-json :: json for cli client
^- ?(~ ^json) :: null = ignore
?+ -.sef ~
$tan (wall (turn (flop p.sef) |=(a/tank ~(ram re a))))
$txt s+(crip p.sef)
$sag
=/ =atom (jam q.sef)
=/ =octs [(met 3 atom) atom]
=/ enc (en:base64 octs)
(pairs file+s+(crip <`path`p.sef>) data+s+enc ~)
$sav
(pairs file+s+(crip <`path`p.sef>) data+s+(crip (en-base64:mimes:html q.sef)) ~)
::
$mor
=+ all=(turn p.sef |=(a/sole-effect lens-json(sef a)))
=. all (skip all |=(a/^json ?=(~ a)))
?~ all ~
?~ t.all i.all
~|(multiple-effects+`(list ^json)`all !!)
==
::
++ json
^- ^json
?+ -.sef

View File

@ -425,7 +425,12 @@ url = "http://localhost:%s" % PORT
r = requests.post(url, data=json.dumps(payload))
if r.text[0] == '"':
if r.headers.get('content-type') == 'application/octet-stream':
name = r.headers.get('content-disposition').split('filename=',1)[1][1:-1]
with open(name, 'wb') as f:
for block in r.iter_content(1024):
f.write(block)
elif r.text[0] == '"':
print r.text[1:-1].encode('utf-8').decode('string_escape')
elif r.text[0] == '{':
# print r.text

View File

@ -38,10 +38,14 @@ _cue_push(c3_ys mov,
// (off==0 means we're on a north road)
//
if ( 0 == off ) {
c3_assert(u3R->cap_p > u3R->hat_p);
if( !(u3R->cap_p > u3R->hat_p) ) {
u3m_bail(c3__meme);
}
}
else {
c3_assert(u3R->cap_p < u3R->hat_p);
if( !(u3R->cap_p < u3R->hat_p) ) {
u3m_bail(c3__meme);
}
}
cueframe* fam_u = u3to(cueframe, u3R->cap_p + off);

View File

@ -138,8 +138,25 @@ _jam_buf_atom(_jam_buf* buf_u, u3_noun a)
else {
_jam_buf_chop(&buf_u, 2, 1);
*top = u3t(a);
u3R->cap_p += mov;
// XX disabled for performance
// may be unnecessary, u3h_put calls u3r_mug,
// which uses and checks the stack
//
#if 0
if ( 0 == off ) {
if( !(u3R->cap_p > u3R->hat_p) ) {
u3m_bail(c3__meme);
}
}
else {
if( !(u3R->cap_p < u3R->hat_p) ) {
u3m_bail(c3__meme);
}
}
#endif
top = u3to(u3_noun, u3R->cap_p + off);
*top = u3h(a);
}

View File

@ -586,8 +586,13 @@ u3a_push(c3_w len_w)
top -= len_w;
cur = top;
u3p(void) cap_p = u3R->cap_p = u3of(void, top);
c3_assert(cap_p < u3R->mat_p);
c3_assert(cap_p > u3R->hat_p);
if( !( cap_p < u3R->mat_p &&
cap_p > u3R->hat_p ) )
{
u3m_bail(c3__meme);
}
return cur;
}
else {
@ -595,8 +600,13 @@ u3a_push(c3_w len_w)
top += len_w;
u3R->cap_p = u3of(void, top);
u3p(void) cap_p = u3R->cap_p = u3of(void, top);
c3_assert(cap_p > u3R->mat_p);
c3_assert(cap_p < u3R->hat_p);
if( !( cap_p > u3R->mat_p &&
cap_p < u3R->hat_p ) )
{
u3m_bail(c3__meme);
}
return cur;
}
}

View File

@ -1345,6 +1345,22 @@ static inline void
_n_push(c3_ys mov, c3_ys off, u3_noun a)
{
u3R->cap_p += mov;
// XX stack sanity-check disabled for performance
//
#if 0
if ( 0 == off ) {
if( !(u3R->cap_p > u3R->hat_p) ) {
u3m_bail(c3__meme);
}
}
else {
if( !(u3R->cap_p < u3R->hat_p) ) {
u3m_bail(c3__meme);
}
}
#endif
u3_noun* p = u3to(u3_noun, u3R->cap_p + off);
*p = a;
}

View File

@ -1597,10 +1597,14 @@ _mug_push(c3_ys mov,
// (off==0 means we're on a north road)
//
if ( 0 == off ) {
c3_assert(u3R->cap_p > u3R->hat_p);
if( !(u3R->cap_p > u3R->hat_p) ) {
u3m_bail(c3__meme);
}
}
else {
c3_assert(u3R->cap_p < u3R->hat_p);
if( !(u3R->cap_p < u3R->hat_p) ) {
u3m_bail(c3__meme);
}
}
mugframe* fam_u = u3to(mugframe, u3R->cap_p + off);