six-updater-web 0.23.2 → 0.23.3

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.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/testtask'
7
7
 
8
8
  spec = Gem::Specification.new do |s|
9
9
  s.name = 'six-updater-web'
10
- s.version = '0.23.2'
10
+ s.version = '0.23.3'
11
11
  s.has_rdoc = false
12
12
  #s.extra_rdoc_files = ['README', 'LICENSE']
13
13
  s.summary = 'Your summary here'
@@ -354,6 +354,10 @@ class MainController < ApplicationController
354
354
  @msg << "Saved six-updater.yml!"
355
355
  @msg << "<b>A window should open displaying the update process progress</b>"
356
356
 
357
+ when "speedtest"
358
+ @system_setting.speedtest
359
+ @msg << "<b>A window should open displaying the speedtest progress</b>"
360
+
357
361
  when "stop game"
358
362
  setting.kill!.each { |entry| @msg << "Process killed: #{entry}" }
359
363
  sleep 1
@@ -20,6 +20,8 @@ class Mod < ActiveRecord::Base
20
20
  mods += mod.all_dependentmods(mods)
21
21
  mods << mod
22
22
  end
23
+ mods -= [self]
24
+ mods += [self]
23
25
  mods.uniq
24
26
  end
25
27
 
@@ -73,14 +75,21 @@ class Mod < ActiveRecord::Base
73
75
  self.version_local && !self.version_local.empty?
74
76
  end
75
77
 
78
+ def my_path(setting)
79
+ return nil unless setting.real_modpath && self.real_name
80
+ File.join(self.real_path(setting), self.real_name).gsub("\\", "/")
81
+ end
82
+
76
83
  def exists?(setting)
77
- return false unless setting.real_modpath && self.real_name
78
- File.exists?(File.join(setting.real_modpath, self.real_name))
84
+ path = self.my_path(setting)
85
+ return false unless path
86
+ File.exists?(path)
79
87
  end
80
88
 
81
89
  def has_rsync?(setting)
82
- return false unless setting.real_modpath && self.real_name
83
- File.exists?(File.join(setting.real_modpath, self.real_name, ".rsync"))
90
+ path = self.my_path(setting)
91
+ return false unless path
92
+ File.exists?(File.join(path, ".rsync"))
84
93
  end
85
94
 
86
95
  def remote
@@ -94,20 +103,10 @@ class Mod < ActiveRecord::Base
94
103
  def read_version(path)
95
104
  return unless path && self.real_name
96
105
  cfg = File.join(path, self.real_name, '.rsync', '.repository.yml')
97
- if File.exists?(cfg)
98
- conf = YAML::load_file(cfg)
99
- if conf
100
- begin
101
- conf[:version]
102
- rescue
103
- nil
104
- end
105
- else
106
- nil
107
- end
108
- else
109
- nil
110
- end
106
+ return nil unless File.exists?(cfg)
107
+ conf = YAML::load_file(cfg)
108
+ return nil unless conf
109
+ begin; conf[:version]; rescue; nil; end
111
110
  end
112
111
 
113
112
  def update_version(path)
@@ -120,21 +119,20 @@ class Mod < ActiveRecord::Base
120
119
  end
121
120
 
122
121
  def real_path(appsetting)
123
- if self.path
124
- self.path
125
- else
126
- appsetting.real_modpath
127
- end
122
+ self.path ? self.path : appsetting.real_modpath
128
123
  end
129
124
 
130
125
  def all_repositories
131
- if self.networks.empty?
126
+ rep = if self.networks.empty?
132
127
  Repository.find(:all)
133
128
  else
134
129
  repos = []
135
130
  self.networks.each { |net| repos += net.repositories unless net.disabled }
136
131
  repos
137
132
  end
133
+ prio = nil
134
+ rep.each {|e| unless e.priority.nil?; prio = true; break; end }
135
+ prio ? rep.sort{|a, b| a.priority <=> b.priority} : rep.shuffle
138
136
  end
139
137
 
140
138
  def update_skip
@@ -12,7 +12,6 @@ class Queryserver < ActiveRecord::Base
12
12
  has_and_belongs_to_many :mods
13
13
  has_many :sixconfigs
14
14
 
15
-
16
15
  def export
17
16
 
18
17
  end
@@ -2,6 +2,40 @@ class Repository < ActiveRecord::Base
2
2
  belongs_to :network
3
3
  six_guid
4
4
 
5
+ attr_accessor :ping_value
6
+
7
+ def self.rank(pr = false)
8
+ repos = self.find(:all)
9
+ repos.each do |rep|
10
+ puts "Processing #{rep.url}" if pr
11
+ rep.ping_value = rep.ping!
12
+ sleep 1
13
+ end
14
+ repos.sort!{|a, b| a.ping_value <=> b.ping_value }
15
+ repos.each_with_index do |rep,index|
16
+ rep.priority = index
17
+ rep.save
18
+ end
19
+ repos
20
+ end
21
+
22
+
23
+ def ping!
24
+ logger.info "Handling #{self.address}"
25
+ out = %x[ping -n 10 #{self.address}]
26
+ vals = []
27
+ out.each_line do |l|
28
+ l[/=([0-9]*)ms/]
29
+ if $1
30
+ vals << $1.to_i
31
+ end
32
+ end
33
+ logger.debug "Out: #{out}, Vals: #{vals}"
34
+ bla = 0
35
+ vals.each {|v| bla += v }
36
+ bla == 0 ? 9999 : bla / vals.size
37
+ end
38
+
5
39
  def ping
6
40
  SixUpdaterWeb.run_program("ping", SixUpdaterWeb::BASE_PATH, "-r 9 -n 30 -t #{self.address}")
7
41
  end
@@ -14,6 +14,12 @@ class SystemSetting < ActiveRecord::Base
14
14
  "rake" # .bat on Windows
15
15
  end
16
16
 
17
+ def speedtest
18
+ cl = "sync:priority RAILS_ENV=#{ENV['RAILS_ENV']}" # + cl
19
+ cl += " BASE_PATH=\'#{SixUpdaterWeb::BASE_PATH}\'" if defined?(SixUpdaterWeb::OLDLOCATION)
20
+ SixUpdaterWeb.run_program(exec, RAILS_ROOT, cl)
21
+ end
22
+
17
23
  def update_gamespy(internal = false)
18
24
  self.gamespied_at = Time.now
19
25
  self.save
@@ -60,6 +60,8 @@
60
60
  = submit_tag "Show status"
61
61
  &nbsp;
62
62
  = submit_tag "Server Mod check"
63
+ %p
64
+ = submit_tag "Speedtest"
63
65
  %strong Logs
64
66
  - form_tag :action => :fetch do
65
67
  %p
@@ -22,7 +22,7 @@ case RUBY_VERSION
22
22
  end
23
23
 
24
24
  module SixUpdaterWeb
25
- VERSION = "0.23.2"
25
+ VERSION = "0.23.3"
26
26
  COMPONENT = "six-updater-web"
27
27
 
28
28
  DEFAULT_IP = "127.0.0.1" unless defined?(DEFAULT_IP)
@@ -207,6 +207,15 @@ module SixUpdaterWeb
207
207
  puts "Done!"
208
208
  end
209
209
 
210
+ def mirror_priority
211
+ puts "Checking mirror latencies, please be patient..."
212
+ repos = Repository.rank(true)
213
+ puts
214
+ repos.each do |rep|
215
+ puts "#{rep.priority} - #{rep.ping_value} - #{rep.url}"
216
+ end
217
+ end
218
+
210
219
  def logger
211
220
  ActiveRecord::Base.logger
212
221
  end
@@ -9,6 +9,11 @@ namespace :sync do
9
9
  sleep 3
10
10
  end
11
11
 
12
+ task :priority => :environment do
13
+ SixUpdaterWeb.mirror_priority
14
+ sleep 3
15
+ end
16
+
12
17
  task :system => :environment do
13
18
  Six::Dbmanager.reload_system
14
19
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 23
8
- - 2
9
- version: 0.23.2
8
+ - 3
9
+ version: 0.23.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sickboy
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-25 00:00:00 +02:00
17
+ date: 2010-07-26 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency