mixlib-shellout 1.4.0-x86-mingw32 → 1.6.0.rc.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17ffe5dde98939ad9bbb4c4eaf85c19c4b335443
4
- data.tar.gz: 9b2222b06f357b6398f38ff41f6e8f7b0a43a1a9
3
+ metadata.gz: 090582646d44022c8d0f06d29b2a6bea06875aad
4
+ data.tar.gz: b9d6684c7b751462d6e4c2cea479f39474e3ee6d
5
5
  SHA512:
6
- metadata.gz: 0ba9c4a0aa2797a54b6784eefb6c1b5ca6e656bbf09a88a5fc66728211eb02c64a09cf4f7bb6927fd4ddad5b2740e34e2dc0e2c9459eab3124436c41fdab7720
7
- data.tar.gz: 9bd47e4270aa24b760dd43a8c61f6d6d3f553d82cfb29adc6ad2d711d6ba71ae12c226f7bf1c42d4ef8a5db7be4d62fba1462845aee1de17dae398e4eb9b5e5c
6
+ metadata.gz: 54b79dc8fa8a509cadf3e6738931b586819ba254d9d76c23cf8bad4492dde20dbca7975f57f91e7fe5f68c600d81640564044fd1cc1df3d6c8837857fa593c80
7
+ data.tar.gz: 674076ca9e875c2b2b55d604f6ce3279c99e87014002429e51e1d1eeaac245947dbbbddd3811d32df5ca17e97910687ffaed91f9de7e41950b961be7cfcc27dd
data/README.md CHANGED
@@ -37,7 +37,7 @@ Invoke crontab to edit user cron:
37
37
  crontab.run_command
38
38
 
39
39
  ## Windows Impersonation Example
40
- Invoke crontab to edit user cron:
40
+ Invoke "whoami.exe" to demonstrate running a command as another user:
41
41
 
42
42
  whomai = Mixlib::ShellOut.new("whoami.exe", :user => "username", :domain => "DOMAIN", :password => "password")
43
43
  whoami.run_command
@@ -51,4 +51,4 @@ Apache 2 Licensed. See LICENSE for full details.
51
51
 
52
52
  ## See Also
53
53
  * `Process.spawn` in Ruby 1.9
54
- * [https://github.com/rtomayko/posix-spawn](posix-spawn)
54
+ * [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn)
@@ -53,10 +53,13 @@ module Mixlib
53
53
  # to determine if the command was successful. Normally set via options to new
54
54
  attr_accessor :valid_exit_codes
55
55
 
56
- # When live_stream is set, stdout of the subprocess will be copied to it as
57
- # the subprocess is running. For example, if live_stream is set to STDOUT,
58
- # the command's output will be echoed to STDOUT.
59
- attr_accessor :live_stream
56
+ # When live_stdout is set, the stdout of the subprocess will be copied to it
57
+ # as the subprocess is running.
58
+ attr_accessor :live_stdout
59
+
60
+ # When live_stderr is set, the stderr of the subprocess will be copied to it
61
+ # as the subprocess is running.
62
+ attr_accessor :live_stderr
60
63
 
61
64
  # ShellOut will push data from :input down the stdin of the subprocss.
62
65
  # Normally set via options passed to new.
@@ -147,7 +150,7 @@ module Mixlib
147
150
  # cmd.run_command # etc.
148
151
  def initialize(*command_args)
149
152
  @stdout, @stderr = '', ''
150
- @live_stream = nil
153
+ @live_stdout = @live_stderr = nil
151
154
  @input = nil
152
155
  @log_level = :debug
153
156
  @log_tag = nil
@@ -163,6 +166,18 @@ module Mixlib
163
166
  @command = command_args.size == 1 ? command_args.first : command_args
164
167
  end
165
168
 
169
+ # Returns the stream that both is being used by both live_stdout and live_stderr, or nil
170
+ def live_stream
171
+ live_stdout == live_stderr ? live_stdout : nil
172
+ end
173
+
174
+ # A shortcut for setting both live_stdout and live_stderr, so that both the
175
+ # stdout and stderr from the subprocess will be copied to the same stream as
176
+ # the subprocess is running.
177
+ def live_stream=(stream)
178
+ @live_stdout = @live_stderr = stream
179
+ end
180
+
166
181
  # Set the umask that the subprocess will have. If given as a string, it
167
182
  # will be converted to an integer by String#oct.
168
183
  def umask=(new_umask)
@@ -286,7 +301,11 @@ module Mixlib
286
301
  when 'returns'
287
302
  self.valid_exit_codes = Array(setting)
288
303
  when 'live_stream'
289
- self.live_stream = setting
304
+ self.live_stdout = self.live_stderr = setting
305
+ when 'live_stdout'
306
+ self.live_stdout = setting
307
+ when 'live_stderr'
308
+ self.live_stderr = setting
290
309
  when 'input'
291
310
  self.input = setting
292
311
  when 'logger'
@@ -115,7 +115,7 @@ module Mixlib
115
115
  # If the child dies very quickly, @child_pid may be a zombie, so handle
116
116
  # ESRCH here.
117
117
  @child_pgid = -Process.getpgid(@child_pid)
118
- rescue Errno::ESRCH
118
+ rescue Errno::ESRCH, Errno::EPERM
119
119
  @child_pgid = nil
120
120
  end
121
121
 
@@ -278,7 +278,7 @@ module Mixlib
278
278
  def read_stdout_to_buffer
279
279
  while chunk = child_stdout.read_nonblock(READ_SIZE)
280
280
  @stdout << chunk
281
- @live_stream << chunk if @live_stream
281
+ @live_stdout << chunk if @live_stdout
282
282
  end
283
283
  rescue Errno::EAGAIN
284
284
  rescue EOFError
@@ -288,6 +288,7 @@ module Mixlib
288
288
  def read_stderr_to_buffer
289
289
  while chunk = child_stderr.read_nonblock(READ_SIZE)
290
290
  @stderr << chunk
291
+ @live_stderr << chunk if @live_stderr
291
292
  end
292
293
  rescue Errno::EAGAIN
293
294
  rescue EOFError
@@ -345,12 +346,12 @@ module Mixlib
345
346
 
346
347
  def reap_errant_child
347
348
  return if attempt_reap
348
- @terminate_reason = "Command execeded allowed execution time, process terminated"
349
- logger.error("Command execeded allowed execution time, sending TERM") if logger
349
+ @terminate_reason = "Command exceeded allowed execution time, process terminated"
350
+ logger.error("Command exceeded allowed execution time, sending TERM") if logger
350
351
  Process.kill(:TERM, child_pgid)
351
352
  sleep 3
352
353
  attempt_reap
353
- logger.error("Command execeded allowed execution time, sending KILL") if logger
354
+ logger.error("Command exceeded allowed execution time, sending KILL") if logger
354
355
  Process.kill(:KILL, child_pgid)
355
356
  reap
356
357
 
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class ShellOut
3
- VERSION = "1.4.0"
3
+ VERSION = "1.6.0.rc.0"
4
4
  end
5
5
  end
@@ -165,7 +165,9 @@ module Mixlib
165
165
 
166
166
  if ready.first.include?(stderr_read)
167
167
  begin
168
- @stderr << stderr_read.readpartial(READ_SIZE)
168
+ next_chunk = stderr_read.readpartial(READ_SIZE)
169
+ @stderr << next_chunk
170
+ @live_stderr << next_chunk if @live_stderr
169
171
  rescue EOFError
170
172
  stderr_read.close
171
173
  open_streams.delete(stderr_read)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-shellout
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0.rc.0
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Opscode
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-08 00:00:00.000000000 Z
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -82,9 +82,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ">="
85
+ - - ">"
86
86
  - !ruby/object:Gem::Version
87
- version: '0'
87
+ version: 1.3.1
88
88
  requirements: []
89
89
  rubyforge_project:
90
90
  rubygems_version: 2.2.2