dtk-action-agent 0.0.4 → 0.0.5

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: f72bc2bfeacdd56a05dcd6b9ca7b881b6fa20ba4
4
- data.tar.gz: f943dcd2ff324eeff690445d8bac30d3f26049af
3
+ metadata.gz: 8ceb9bc809895890686ccd58e4783db04dd98607
4
+ data.tar.gz: dd303a2fe410acaaa1e1bebb2b5c37d2be231658
5
5
  SHA512:
6
- metadata.gz: 778beb33c855def060cfbae12933cec49fea2e0e40e503725cf83e5c7a4c49caca7db439176ef1b7326e787af955c8944520dd1e78793c6d0c1c469f89bc19f5
7
- data.tar.gz: e1957688595c4e0b340841591aa177226f6f7737fae9b778e64050ce90d19420f3e019e97a5e30299edc8ae9e26ef48f2638a084a820cc8b27b78be4a42c8119
6
+ metadata.gz: 8b9d0492fbb95fa778718c900bb7accc860b795a2ae53609a6aea453223a5153a7c851f5c0a1775877dc42ad2d2fd9f8d338918df0befd4dd12bd89b69962c49
7
+ data.tar.gz: 80e42e95161fd18359a5d0988180a6d27e405371d5835de83b2bf7f79a0b5c97c6dee84ecfca4afac784ca6cedd4ded3a3370db5c2c0d5df5d78b059f4fd1a03
data/lib/command.rb CHANGED
@@ -9,19 +9,24 @@ module DTK
9
9
  attr_accessor :command_type, :command, :if_success, :if_fail, :process, :child_task
10
10
 
11
11
  ##
12
- # command - string to be run on system, e.g. ifconfig
13
- # type - type of command e.g. syscall, ruby
14
- # if - callback to be run if exit status is = 0
15
- # unless - callback to be run if exit status is != 0
16
- # child_task - if it is spawned by another main task
12
+ # command - string to be run on system, e.g. ifconfig
13
+ # type - type of command e.g. syscall, ruby
14
+ # if - callback to be run if exit status is = 0
15
+ # unless - callback to be run if exit status is != 0
16
+ # stdout_redirect - redirect all output to stdout
17
+ # child_task - if it is spawned by another main task
17
18
  #
19
+
20
+ STDOUT_REDIRECT = ' 2>&1'
21
+
18
22
  def initialize(value_hash)
19
- @command_type = value_hash['type']
20
- @command = value_hash['command']
21
- @if_success = value_hash['if']
22
- @if_fail = value_hash['unless']
23
- @spawned = false
24
- @child_task = value_hash['child_task'] || false
23
+ @command_type = value_hash['type']
24
+ @command = value_hash['command']
25
+ @stdout_redirect = !!value_hash['stdout_redirect']
26
+ @if_success = value_hash['if']
27
+ @if_fail = value_hash['unless']
28
+ @spawned = false
29
+ @child_task = value_hash['child_task'] || false
25
30
 
26
31
  if @if_success && @if_fail
27
32
  Log.warn "Unexpected case, both if/unless conditions have been set for command #{@command}(#{@command_type})"
@@ -33,7 +38,7 @@ module DTK
33
38
  #
34
39
  def start_task
35
40
  begin
36
- @process = POSIX::Spawn::Child.new(@command)
41
+ @process = POSIX::Spawn::Child.new(formulate_command)
37
42
  Log.debug("Command started: '#{self.to_s}'")
38
43
  rescue Exception => e
39
44
  @error_message = e.message
@@ -86,7 +91,16 @@ module DTK
86
91
  end
87
92
 
88
93
  def to_s
89
- "#{@command} (#{command_type})"
94
+ "#{formulate_command} (#{command_type})"
95
+ end
96
+
97
+ private
98
+
99
+ #
100
+ # Based on stdout-redirect flag
101
+ #
102
+ def formulate_command
103
+ @stdout_redirect ? "#{@command} #{STDOUT_REDIRECT}" : @command
90
104
  end
91
105
 
92
106
  end
@@ -1,5 +1,5 @@
1
1
  module DTK
2
2
  module ActionAgent
3
- VERSION="0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-action-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: posix-spawn