mutx 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: 19f6e7d0eb47b0ee32ffdb142e5dc33c86c6f7d0
4
- data.tar.gz: 941938ef3a9e3dd9ea2bbf96e8aa3b786542a3e0
3
+ metadata.gz: 958d98af1ba4b215f6cda04cadf33cfd24974561
4
+ data.tar.gz: 034c06aa3c75aa46b72897f0359113f934159d6e
5
5
  SHA512:
6
- metadata.gz: a46f7a2224a197531f00718a204fe2f295ccbfb01d8968caef7a4b3987952fa6b9c8bc0d0beeb822546a57b3238e14b7d48a95336667fb7ed48b2b23963414a9
7
- data.tar.gz: 2ae2115ea7647dd42cf28bf7b0284618cb0ac5971a250b89b095e9d0556643fc6552f4affc8fde368ec3ffd629f817b205dc7dff049522b1ee023f8b79cbedd8
6
+ metadata.gz: 71e645ed8c32dad2436fa76115fa88e4ea2e2a18e063728fcdfb9fccc8e2592f08572b0988100c56b8166005f457609587b976ebb2cfcf688f9c0953f66d7b42
7
+ data.tar.gz: 21dd0240615e318df78f8a71de74c39eddfcd3365f576cdcf48960f98fb92a7b8a3f4408bf2244a8c201f02e281f2d7e1d1fae97d7ba157cc6ffbdd6f2793b67
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mutx (0.2.0)
4
+ mutx (0.2.1)
5
5
  basica
6
6
  bson_ext
7
7
  byebug
@@ -19,31 +19,13 @@ module Mutx
19
19
  Mutx::Support::Configuration.get
20
20
  Mutx::Database::MongoConnector.new Mutx::Support::Configuration.db_connection_data
21
21
 
22
- Mutx::Support::ChangeInspector.is_there_a_change?
23
-
24
22
  result = Mutx::Results::Result.get(result_id)
25
23
  puts "[#{result.id}] Execution created"
26
24
  task = Mutx::Tasks::Task.get(result.task_id)
27
25
 
28
26
  result.mutx_report_file_name= "mutx_report_#{result_id}.html"
29
27
 
30
- if result.is_ruby_platform?
31
- if Mutx::Platforms::Ruby.using_bundler?
32
- bundle_output = Mutx::Support::Console.execute "bundle update"
33
- puts "[#{result.id}] bundle: #{bundle_output}"
34
- bundle_output.slice! "fatal: Not a git repository (or any of the parent directories): .git"
35
- end
36
- if bundle_output
37
- result.append_output! bundle_output if bundle_output.include? "Installing"
38
- if bundle_output.include? "Could not find"
39
- puts "[#{result.id}] Finished because of Could not find gem"
40
- result.finish!
41
- raise "An error ocurred installing gem while executing bundler"
42
- else
43
- result.append_output! "All GEMS are installed and running!\nEXECUTION OUTPUT:\n\n--"
44
- end
45
- end
46
- end
28
+ Mutx::Support::Bundle.new.bundle_update(result) if Mutx::Support::ChangeInspector.is_there_a_change?
47
29
 
48
30
  Dir.mkdir "#{Dir.pwd}/mutx/temp" unless Dir.exist? "#{Dir.pwd}/mutx/temp"
49
31
 
@@ -54,66 +36,48 @@ module Mutx
54
36
  efective_command << result.custom_params_values
55
37
  efective_command << "_id=#{result.id}" # to use inside execution the possibility to add information to the result
56
38
  puts "[#{result.id}] Command: #{efective_command.join(" ")}"
57
- result.mutx_command= efective_command.join(" ")
39
+ result.mutx_command = efective_command.join(" ")
58
40
 
59
41
  attach_folder = "#{Dir.pwd}/mutx/out/#{result.id}/attachment"
60
42
 
61
43
  result.running!
62
44
  puts "[#{result.id}] setted as running"
63
45
 
64
- @output = ""
65
-
66
- @count = 0
67
-
68
46
  if !Mutx::Support::Configuration.proxys.empty?
69
47
  Mutx::Support::Configuration.proxys.detect{|proxy| Mutx::Support::Console.execute proxy}
70
48
  end
71
49
 
72
50
  Mutx::Support::TimeHelper.start # Sets timestamp before start process
73
51
 
74
- @start_time = Time.now
75
52
  begin
76
-
77
-
78
-
79
- PTY.spawn("#{result.mutx_command}") do |stdout, stdin, pid|
53
+ PTY.spawn( "#{result.mutx_command}" ) do |stdout, stdin, pid|
80
54
  begin
81
- if result.pid.nil?
82
- puts "[#{result.id}] pid #{pid}"
83
- result.pid = pid
84
- result.save!
85
- end
86
55
  stdout.each { |line|
87
- @output = line
88
- @output.slice! "fatal: Not a git repository (or any of the parent directories): .git"
89
- result.append_output! @output.gsub(/(\[\d{1,2}\m)/, "")
56
+ @output = line
57
+ @output.slice! "fatal: Not a git repository (or any of the parent directories): .git"
58
+ result.append_output! @output.gsub(/(\[\d{1,2}\m)/, "")
90
59
 
91
- if result.time_to_live_reached?
92
- result.finished_by_timeout! and break
93
- end
60
+ if result.time_to_live_reached?
61
+ result.finished_by_timeout! and break
62
+ end
94
63
  }
95
- result.append_output! @output unless @output.empty?
96
- rescue Errno::EIO, Errno::ENOENT => e
97
- puts "[#{result_id}] Errno::EIO, Errno::ENOENT => e"
98
- rescue PTY::ChildExited, Errno::ENOENT => e
99
- cmd = result.mutx_command.match(/(\D*)\_/)[0].delete"_"
100
- exception_message = "EXCEPTION: #{e.message} for the command requested for you: #{cmd.upcase}"
101
- puts "[#{result.id}] exception_message: #{exception_message}"
102
- @output = exception_message
64
+ Process.wait pid
103
65
  result.append_output! @output unless @output.empty?
104
- rescue => e
105
- puts "[#{result_id}] Unknown exception"
66
+ rescue Errno::EIO
106
67
  end
107
-
108
68
  end
109
-
110
- rescue => e
111
- puts "#######################}WTF #{e} #{e.backtrace}"
112
- # result.reset!
113
- puts "[#{result.id}] Reseted"
69
+ rescue PTY::ChildExited => e
70
+ puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
71
+ puts "The child process exited!, #{e.message}"
72
+ puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
73
+ rescue Errno::ENOENT => e
74
+ cmd = result.mutx_command.match(/(\D*)\_/)[0].delete"_"
75
+ exception_message = "EXCEPTION: #{e.message} for the command requested for you: #{cmd.upcase}"
76
+ puts "[#{result.id}] exception_message: #{exception_message}"
77
+ @output = exception_message
78
+ result.append_output! @output unless @output.empty?
114
79
  end
115
-
116
- result = Mutx::Results::Result.get(result_id)
80
+
117
81
  puts "[#{result.id}] Status before ensure finish => #{result.status}"
118
82
  result.ensure_finished!
119
83
  result.eval_regex!
@@ -140,17 +104,21 @@ module Mutx
140
104
  if ( (task["notifications"].eql? "on") && (!task["stop_bots"].eql? "on") && (!task["stop_bots"].eql? "off") && (!result.regex.empty?) && (result.console_output.to_s.include? "#{result.regex.to_s}") )
141
105
  Mutx::Database::MongoConnector.mark_notified (result_id)
142
106
  Mutx::Workers::EmailSender.perform_async(result_id, subject, email, name, id, type, cucumber, notify_on, attach_folder) if ((task[:notifications].eql? "on") && (!email.empty?))
107
+
143
108
  elsif ( (task["notifications"].eql? "on") && (!task["stop_bots"].eql? "on") && (!task["stop_bots"].eql? "off") && (result.regex.empty?) )
144
109
  Mutx::Database::MongoConnector.mark_notified (result_id)
145
110
  Mutx::Workers::EmailSender.perform_async(result_id, subject, email, name, id, type, cucumber, notify_on, attach_folder) if ((task[:notifications].eql? "on") && (!email.empty?))
111
+
146
112
  elsif ( (task["notifications"].eql? "on") && (task["stop_bots"].eql? "on") && (!result.regex.empty?) && (result.console_output.to_s.include? "#{result.regex.to_s}") )
147
113
  Mutx::Database::MongoConnector.mark_notified (result_id)
148
114
  Mutx::Workers::EmailSender.perform_async(result_id, subject, email, name, id, type, cucumber, notify_on, attach_folder) if ((task[:notifications].eql? "on") && (!email.empty?))
149
115
  Mutx::Database::MongoConnector.update_stop_bots_off (id) #silence notifications
150
116
  Mutx::Support::MailSender.new.sender(nil, "#{name} Comenzo a notificar, se le informara cuando vuelva a la normalidad", "#{email}", name, nil, nil, nil, nil, nil)
117
+
151
118
  elsif ( (task["notifications"].eql? "on") && (task["stop_bots"].eql? "off") && (!result.regex.empty?) && (!result.console_output.to_s.include? "#{result.regex.to_s}") )
152
119
  Mutx::Database::MongoConnector.update_stop_bots_on (id) #on notifications
153
120
  Mutx::Support::MailSender.new.sender(nil, "#{name} Volvio a funcionar con normalidad", "#{email}", name, nil, nil, nil, nil, nil)
121
+
154
122
  elsif ( (task["notifications"].eql? "on") && (!result.regex.empty?) && (!result.console_output.to_s.include? "#{result.regex.to_s}") )
155
123
  puts "****Result not to being notified, because regex #{result.regex.to_s} not included on output****"
156
124
  end
@@ -399,7 +399,7 @@ module Mutx
399
399
  #
400
400
  #
401
401
  def self.all_repos
402
- res = $repos.find({})
402
+ res = $repos.find({}).sort({"repo_name" => 1})
403
403
  res.to_a if res.respond_to? :to_a
404
404
  res
405
405
  end
@@ -539,7 +539,7 @@ module Mutx
539
539
  end
540
540
 
541
541
  def stopped?
542
- @status =~ /stopped/i
542
+ @status =~ /(reset|stopped)/i
543
543
  end
544
544
 
545
545
  def reset! reason=nil
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ module Mutx
3
+ module Support
4
+ class Bundle
5
+
6
+ def initialize
7
+ end
8
+
9
+ def bundle_update(result)
10
+ if ( (result.is_ruby_platform?.to_s.eql? "ruby") && (Mutx::Platforms::Ruby.using_bundler?) )
11
+ bundle_output = Mutx::Support::Console.execute "bundle update"
12
+ puts "[#{result.id}] bundle: #{bundle_output}"
13
+ bundle_output.slice! "fatal: Not a git repository (or any of the parent directories): .git"
14
+
15
+ result.append_output! bundle_output if bundle_output.include? "Installing"
16
+ if bundle_output.include? "Could not find"
17
+ puts "[#{result.id}] Finished because of Could not find gem"
18
+ result.finish!
19
+ raise "An error ocurred installing gem while executing bundler"
20
+ else
21
+ result.append_output! "All GEMS are installed and running!\nEXECUTION OUTPUT:\n\n--"
22
+ end
23
+ end
24
+ return result
25
+ end# bundle_update
26
+
27
+ end
28
+ end
29
+ end
data/lib/mutx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mutx
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -2,6 +2,14 @@
2
2
  <a href="#" onclick="goClean('{{ path_for(:repositories_show, repository_id: repository['_id']) }}');" >{{ repository["repo_name"] }}</a>
3
3
  </th>
4
4
 
5
+ <th>
6
+ % unless repository["value"].nil?
7
+ {{ Mutx::View.icon_for("hasvalue")}}
8
+ % else
9
+ <div style="color:gray">null</div>
10
+ % end
11
+ </th>
12
+
5
13
  <th>
6
14
  {{ repository["last_update"] }}
7
- </th>
15
+ </th>
@@ -117,6 +117,12 @@ module Mutx
117
117
 
118
118
  when /(?:book|doc|help)/
119
119
  ["book",nil,nil,"#{what}"]
120
+
121
+ when /(?:ok|passed|hasvalue)/
122
+ ["ok","green",nil,"#{what}"]
123
+
124
+ when /(?:empty|failed)/
125
+ ["remove","red",nil,"#{what}"]
120
126
 
121
127
  when /(?:admin|conf|setup)/
122
128
  ["cog",nil,nil,"#{what}"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Rodriguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-21 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -472,6 +472,7 @@ files:
472
472
  - lib/mutx/routes/task_results_routes.rb
473
473
  - lib/mutx/routes/tasks_routes.rb
474
474
  - lib/mutx/routes/tests_routes.rb
475
+ - lib/mutx/support/bundle.rb
475
476
  - lib/mutx/support/change_inspector.rb
476
477
  - lib/mutx/support/clean.rb
477
478
  - lib/mutx/support/configuration.rb