lxd-common 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2791cb10e6c595bb0ea3674e9f717b64e2bde62a2ec2a6b6ea905d9976e4ff7
4
- data.tar.gz: d2efd3d5654b988f06d69ec240d7cc004fe41e39a9b8148ddf24a9006ecdaa34
3
+ metadata.gz: 0990d505df86f297bad664ba623f35589b27e284ecd3081bd7a480aecf0a6ef7
4
+ data.tar.gz: 76b72c2361a6a6b6df857b579167a26a3b409e4619544b5bc06057e0c3701792
5
5
  SHA512:
6
- metadata.gz: 63425cb87c277705710101783d7b5e586e3dd016ecf1d3f54852aeadac6ed6cbaef46c5134fc848d059b36c270deeb81209099f6e872389bdd997b5373bf56c4
7
- data.tar.gz: 2fb79a8652b75e22f3fd3d4be59a41441b835da4744db2d1d6a349a1185317d94451377f1dc7868d9252ff575f0fe924a6c3718fc0db6cabcd40ef1af21ca156
6
+ metadata.gz: 1f33b89efc507c14f794d460fc36fbd0c62d1227257c36991d3279f9a51effa5311ec67a123a3eb37fa3e64899d05cebd1585d520b30e517b67df20581cb6507
7
+ data.tar.gz: 57f64e9e9c90402f8e682a5ee07d0545f537cddcfab049fb68b5a36de76110f9c75a5897dd73a30920221d0628bdc1a4d755b0d0b3e72adba5f026c76b4e4565
@@ -18,18 +18,29 @@ module NexusSW
18
18
  def execute_chunked(command, options, &block)
19
19
  NIO::WebSocket::Reactor.start
20
20
  LXD.with_timeout_and_retries options do
21
- Open3.popen3(command) do |stdin, stdout, stderr, th|
22
- if options[:capture] == :interactive
23
- # return immediately if interactive so that stdin may be used
24
- return Helpers::ExecuteMixin::InteractiveResult.new(command, options, stdin, th).tap do |active|
25
- chunk_callback(stdout, stderr) do |stdout_chunk, stderr_chunk|
26
- active.send_output stdout_chunk if stdout_chunk
27
- active.send_output stderr_chunk if stderr_chunk
21
+ if options[:capture] == :interactive
22
+ if options[:tty] == false
23
+ Open3.popen2e(command) do |stdin, stdout, th|
24
+ # return immediately if interactive so that stdin may be used
25
+ return Helpers::ExecuteMixin::InteractiveResult.new(command, options, stdin, th).tap do |active|
26
+ chunk_callback(stdout) do |stdout_chunk|
27
+ active.send_output stdout_chunk if stdout_chunk
28
+ end
29
+ yield active
30
+ active.exitstatus = th.value.exitstatus
28
31
  end
29
- yield active
30
- active.exitstatus = th.value.exitstatus
31
32
  end
32
33
  else
34
+ status = system command
35
+ status = case status
36
+ when nil then -1
37
+ when true then 0
38
+ when false then 1
39
+ end
40
+ return Helpers::ExecuteMixin::ExecuteResult.new(command, options, status)
41
+ end
42
+ else
43
+ Open3.popen3(command) do |_stdin, stdout, stderr, th|
33
44
  chunk_callback(stdout, stderr, &block) if block_given?
34
45
  th.join
35
46
  loop do
@@ -65,21 +76,21 @@ module NexusSW
65
76
  return nil
66
77
  end
67
78
 
68
- def chunk_callback(stdout, stderr)
79
+ def chunk_callback(stdout, stderr = nil)
69
80
  NIO::WebSocket::Reactor.queue_task do
70
81
  @mon_out = NIO::WebSocket::Reactor.selector.register(stdout, :r)
71
82
  @mon_out.value = proc do
72
83
  data = read(@mon_out) # read regardless of block_given? so that we don't spin out on :r availability
73
84
  yield(data) if data
74
85
  end
75
- end
86
+ end if stdout
76
87
  NIO::WebSocket::Reactor.queue_task do
77
88
  @mon_err = NIO::WebSocket::Reactor.selector.register(stderr, :r)
78
89
  @mon_err.value = proc do
79
90
  data = read(@mon_err) # read regardless of block_given? so that we don't spin out on :r availability
80
91
  yield(nil, data) if data
81
92
  end
82
- end
93
+ end if stderr
83
94
  end
84
95
  end
85
96
  end
@@ -1,5 +1,5 @@
1
1
  module NexusSW
2
2
  module LXD
3
- VERSION = '0.9.7'.freeze
3
+ VERSION = '0.9.8'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lxd-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Zachariasen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-11 00:00:00.000000000 Z
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday