dev 1.0.159 → 1.0.160
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dev/SystemCall.rb +19 -11
- data/lib/dev/cmd/Clean.rb +5 -5
- metadata +1 -1
data/lib/dev/SystemCall.rb
CHANGED
@@ -110,22 +110,22 @@ class SystemCall
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def system2(working_dir,command,capture_output,capture_error)
|
113
|
-
#puts_debug "begin SystemCall.system2"
|
114
113
|
capture_output=true if capture_output.nil?
|
115
114
|
capture_output=false if capture_output == "false"
|
116
115
|
capture_error=true if capture_error.nil?
|
117
116
|
capture_error=false unless capture_output
|
118
117
|
capture_error=false if capture_error == "false"
|
119
118
|
|
120
|
-
#puts_debug "system2(" + working_dir.to_s + "," + command + ") capture_output(" + capture_output.to_s + ") capture_error(" + capture_error.to_s + ")"
|
121
119
|
filename=Dir.tmpdir + "/" + (0...8).map{65.+(rand(25)).chr}.join
|
122
|
-
|
120
|
+
filename=Dir.tmpdir + "/" + (0...8).map{65.+(rand(25)).chr}.join if File.exist? "#{filename}.out"
|
123
121
|
working_dir = Dir.pwd if working_dir.nil? || working_dir.empty?
|
124
|
-
#puts_debug " working_dir=#{working_dir}"
|
125
122
|
status=0
|
126
123
|
output=""
|
127
124
|
error=""
|
128
|
-
|
125
|
+
|
126
|
+
FileUtils.delete("#{filename}.out") if File.exist? "#{filename}.out"
|
127
|
+
FileUtils.delete("#{filename}.err") if File.exist? "#{filename}.err"
|
128
|
+
|
129
129
|
Dir.chdir(working_dir) do
|
130
130
|
if(capture_output)
|
131
131
|
if(capture_error)
|
@@ -147,27 +147,35 @@ class SystemCall
|
|
147
147
|
output = f.read
|
148
148
|
f.close
|
149
149
|
}
|
150
|
-
|
150
|
+
begin
|
151
|
+
FileUtils.rm("#{filename}.out")
|
152
|
+
rescue
|
153
|
+
warn "unable to remove file #{filename}.out"
|
154
|
+
end
|
151
155
|
end
|
152
156
|
if(File.exist?("#{filename}.err"))
|
153
157
|
File.open("#{filename}.err",'r') {|f|
|
154
158
|
error = f.read
|
155
159
|
f.close
|
156
160
|
}
|
157
|
-
|
161
|
+
begin
|
162
|
+
FileUtils.rm("#{filename}.err")
|
163
|
+
rescue
|
164
|
+
warn "unable to remove file #{filename}.err"
|
165
|
+
end
|
158
166
|
end
|
167
|
+
|
159
168
|
status=$?.exitstatus
|
160
|
-
|
161
|
-
#puts_debug "status = " + status.to_s
|
162
169
|
return status,output,error
|
163
170
|
end
|
164
171
|
|
172
|
+
|
165
173
|
def puts_summary
|
166
174
|
if(@status != 0)
|
167
175
|
summary = " [".foreground(:cyan) + "X".foreground(:red).bright + "]".foreground(:cyan) + " " + @command.foreground(:green) + " has exit status of " + @status.to_s
|
168
176
|
summary += " dir: " + @dir unless @dir.nil?
|
169
177
|
summary += " cache: true" unless @cache.nil?
|
170
|
-
summary += " capture_output: false" unless @capture_output.nil?
|
178
|
+
summary += " capture_output: false" unless @capture_output.nil? || @capture_output
|
171
179
|
puts summary
|
172
180
|
puts @output if !@output.nil?
|
173
181
|
warn @error if !@error.nil?
|
@@ -177,7 +185,7 @@ class SystemCall
|
|
177
185
|
summary = " [".foreground(:cyan) + "+".foreground(:green) + "]".foreground(:cyan) + " " + @command.foreground(:green) + " " + elapsed_str.foreground(:cyan)
|
178
186
|
summary += " dir: " + @dir unless @dir.nil?
|
179
187
|
summary += " cache: true" unless @cache.nil?
|
180
|
-
summary += " capture_output: false" unless @capture_output.nil?
|
188
|
+
summary += " capture_output: false" unless @capture_output.nil? || @capture_output
|
181
189
|
puts summary
|
182
190
|
end
|
183
191
|
end
|
data/lib/dev/cmd/Clean.rb
CHANGED
@@ -10,11 +10,11 @@ class Clean
|
|
10
10
|
status=Timeout::timeout(30){
|
11
11
|
puts_debug "tmp dir=#{Dir.tmpdir}"
|
12
12
|
if File.exists?(Dir.tmpdir)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
if RUBY_PLATFORM.include?("w32")
|
14
|
+
cmd="del /Q #{Dir.tmpdir.gsub('/','\\')}"
|
15
|
+
puts_debug cmd
|
16
|
+
`#{cmd}` if RUBY_PLATFORM.include?("w32")
|
17
|
+
end
|
18
18
|
end
|
19
19
|
}
|
20
20
|
rescue
|