Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ruby_pybridge/hola.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
while cmd = STDIN.gets
cmd.chop!
if cmd == "exit"
break
else
print eval(cmd),"\n"
print "[end]\n"
STDOUT.flush
end
end
19 changes: 19 additions & 0 deletions ruby_pybridge/holaback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from subprocess import Popen, PIPE, STDOUT

print 'launching hola process...'
hola = Popen(['ruby', 'hola.rb'], stdin=PIPE, stdout=PIPE, stderr=STDOUT)

while True:
line = raw_input('Enter expression or exit:')
hola.stdin.write(line+'\n')
result = []
while True:
if hola.poll() is not None:
print 'hola has terminated.'
exit()
line = hola.stdout.readline().rstrip()
if line == '[end]':
break
result.append(line)
print 'result:'
print '\n'.join(result)