Skip to content

Commit

Permalink
added SystemCall runAndReturnOutput method
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedekorte committed Aug 24, 2010
1 parent 259b83c commit bded894
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addons/Oauth/io/OauthRequest.io
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ OauthRequest := Object clone do(

debugWriteln("curl ", args join(" "))
sc setArguments(args)
sc run
//System exit
output := sc runAndReturnOutput
//output := sc stdout readLines join("\n")
debugWriteln("curl exited")

OauthResponse clone setData(sc stdout readLines join("\n")) parseData
OauthResponse clone setData(output) parseData
)

setupOauthParams := method(
Expand Down
26 changes: 26 additions & 0 deletions addons/SystemCall/io/SystemCall.io
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ SystemCall do(
setReturnCode(s)
self
)

runAndReturnOutput := method(aBlock,
buffer := Sequence clone
err := self asyncRun(command, arguments, environment)
if(err == -1, Exception raise("unable to run command"))

// replace this with something to watch the file streams?
isRunning := true
//writeln("self status = ", self status)
wait(.00001)
s := self status
while(isRunning == true and s > 255 and s != -1,
//writeln("self status = ", s)
if(aBlock, if(aBlock call == false, return false))
wait(.02)
s := self status
//buffer appendSeq(stdout readToEnd)
buffer appendSeq(stdout readLines join("\n"))
)
//writeln("self status = ", s)
if(aBlock, aBlock call)

isRunning := false
setReturnCode(s)
self
)

runWith := method(
run(Block clone setMessage(call argAt(0)) setScope(self))
Expand Down

0 comments on commit bded894

Please sign in to comment.