Devops 0.0.3 → 0.0.4

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.
@@ -82,41 +82,54 @@ module Host
82
82
  end
83
83
  end
84
84
 
85
- def shell_exec! command
85
+ def shell_exec!( command, opts = {} )
86
86
  ssh_pem
87
87
 
88
88
  options = { :keys => ssh_pem }
89
89
 
90
90
  color = Color.random_color
91
91
 
92
- Net::SSH.start( host_name, user, options ) do | s |
93
-
94
- channel = s.open_channel do |ch|
95
- ch.exec( command ) do | ch, success |
96
- raise( IOError,
97
- "#{ host_name } > could not execute command" ) unless
98
- success
92
+ begin
93
+ Net::SSH.start( host_name, user, options ) do | s |
94
+
95
+ channel = s.open_channel do |ch|
96
+ channel.request_pty do |ch, success|
97
+ if success
98
+ puts "pty successfully obtained"
99
+ else
100
+ puts "could not obtain pty"
101
+ end
102
+ end if opts.has_key? :pty
103
+
104
+ ch.exec( command ) do | ch, success |
105
+ raise( IOError,
106
+ "#{ host_name } > could not execute command" ) unless
107
+ success
108
+
109
+ ch.on_data do | c, data |
110
+ data.split("\n").each do | line |
111
+ puts "#{ Color.print(
112
+ self.alias, [ :bold, color ] ) } > #{ line }"
113
+ end
114
+ end
99
115
 
100
- ch.on_data do | c, data |
101
- data.split("\n").each do | line |
102
- puts "#{ Color.print(
103
- self.alias, [ :bold, color ] ) } > #{ line }"
116
+ ch.on_extended_data do |c, type, data|
117
+ data.split("\n").each do | line |
118
+ puts "#{ Color.print(
119
+ self.alias, [ :bold, color ] ) } > #{ line }"
120
+ end
104
121
  end
105
- end
106
122
 
107
- ch.on_extended_data do |c, type, data|
108
- data.split("\n").each do | line |
123
+ ch.on_close do
109
124
  puts "#{ Color.print(
110
- self.alias, [ :bold, color ] ) } > #{ line }"
125
+ self.alias, [ :bold, color ] ) } > COMMAND finished"
111
126
  end
112
- end
113
127
 
114
- ch.on_close do
115
- puts "#{ Color.print(
116
- self.alias, [ :bold, color ] ) } > COMMAND finished"
117
128
  end
118
129
  end
119
130
  end
131
+ rescue => e
132
+ puts "Error: #{ self.alias } > #{ e.message }".error
120
133
  end
121
134
  end
122
135
  end
@@ -43,3 +43,11 @@ end
43
43
  class Color
44
44
  extend Ops::Console
45
45
  end
46
+
47
+ class String
48
+ extend Ops::Console
49
+
50
+ def error
51
+ replace Color.print( self , [ :bold, :red ] )
52
+ end
53
+ end
@@ -1,6 +1,6 @@
1
1
  module Ops
2
2
 
3
3
  def self.version
4
- "0.0.3"
4
+ "0.0.4"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Devops
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hardeep Shoker
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-03-25 00:00:00 Z
19
+ date: 2013-04-03 00:00:00 Z
20
20
  dependencies: []
21
21
 
22
22
  description: Ops tool for remote servers