Skip to content

Commit

Permalink
Fix compatability with 1.8.7
Browse files Browse the repository at this point in the history
- Use ChildProcess gem and hard coded tty/pty pair
- Switch to non-interactive input to force asking for Name/Password
  through GUI.
  • Loading branch information
enriquez committed Aug 31, 2013
1 parent 784acdf commit 8559c02
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/uiauto/instruments.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'pty'
require 'childprocess'
require 'fileutils'
require 'cfpropertylist'

Expand Down Expand Up @@ -30,13 +30,18 @@ def command

def execute
exit_status = 0
read, write = PTY.open
pid = spawn(command, :in => STDIN, :out => write, :err => write)
write.close
instruments = ChildProcess.build(*command.split(" "))
master = File.new("/dev/ptyuf", "w")
slave = File.open("/dev/ttyuf", "r")
instruments.io.stdout = master
instruments.io.stderr = master
instruments.duplex = true
instruments.start
master.close

begin
loop do
buffer = read.readpartial(8192)
buffer = slave.readpartial(8192)
lines = buffer.split("\n")
lines.each do |line|
puts line
Expand All @@ -46,7 +51,7 @@ def execute
end
rescue EOFError
ensure
read.close
slave.close
end

exit_status
Expand Down
1 change: 1 addition & 0 deletions uiauto.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ Gem::Specification.new do |spec|

spec.add_dependency "CFPropertyList"
spec.add_dependency "thor"
spec.add_dependency "childprocess"
end

0 comments on commit 8559c02

Please sign in to comment.