From 8559c02d0a757521427691335b0d7f505dbb0d7e Mon Sep 17 00:00:00 2001 From: Mike Enriquez Date: Sat, 31 Aug 2013 17:50:45 -0400 Subject: [PATCH] Fix compatability with 1.8.7 - Use ChildProcess gem and hard coded tty/pty pair - Switch to non-interactive input to force asking for Name/Password through GUI. --- lib/uiauto/instruments.rb | 17 +++++++++++------ uiauto.gemspec | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/uiauto/instruments.rb b/lib/uiauto/instruments.rb index 2d43559..1d78c60 100644 --- a/lib/uiauto/instruments.rb +++ b/lib/uiauto/instruments.rb @@ -1,4 +1,4 @@ -require 'pty' +require 'childprocess' require 'fileutils' require 'cfpropertylist' @@ -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 @@ -46,7 +51,7 @@ def execute end rescue EOFError ensure - read.close + slave.close end exit_status diff --git a/uiauto.gemspec b/uiauto.gemspec index afb8e9a..53548c6 100644 --- a/uiauto.gemspec +++ b/uiauto.gemspec @@ -23,4 +23,5 @@ Gem::Specification.new do |spec| spec.add_dependency "CFPropertyList" spec.add_dependency "thor" + spec.add_dependency "childprocess" end