six-updater 0.21.3-x86-mingw32 → 0.22.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ require 'rake/testtask'
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.platform = "x86-mingw32"
15
15
  s.name = 'six-updater'
16
- s.version = '0.21.3'
16
+ s.version = '0.22.0'
17
17
  s.has_rdoc = true
18
18
  s.extra_rdoc_files = ['README', 'LICENSE']
19
19
  s.summary = 'Your summary here'
@@ -36,7 +36,7 @@ end
36
36
  spec3 = Gem::Specification.new do |s|
37
37
  s.platform = "x86-mswin32"
38
38
  s.name = 'six-updater'
39
- s.version = '0.21.3'
39
+ s.version = '0.22.0'
40
40
  s.has_rdoc = true
41
41
  s.extra_rdoc_files = ['README', 'LICENSE']
42
42
  s.summary = 'Your summary here'
@@ -58,7 +58,7 @@ end
58
58
 
59
59
  spec2 = Gem::Specification.new do |s|
60
60
  s.name = 'six-updater'
61
- s.version = '0.21.3'
61
+ s.version = '0.22.0'
62
62
  s.has_rdoc = true
63
63
  s.extra_rdoc_files = ['README', 'LICENSE']
64
64
  s.summary = 'Your summary here'
@@ -55,6 +55,11 @@ module Six
55
55
  File.open(PID_FILE, 'w') {|f| f.puts Process.pid}
56
56
 
57
57
  initialize
58
+
59
+ puts
60
+ log.info "Preprocessing:"
61
+ @pre_todo.each { |t| Six::Updater.send t }
62
+
58
63
  mods = []
59
64
  puts
60
65
  log.info "Processing:"
@@ -39,7 +39,7 @@ end
39
39
  module Six
40
40
  # TODO: Evaluate if this module should be a class instead?
41
41
  module Updater
42
- VERSION = '0.21.3'
42
+ VERSION = '0.22.0'
43
43
  COMPONENT = 'six-updater'
44
44
  LOG_LIMIT = 9999
45
45
 
@@ -321,9 +321,9 @@ module Six
321
321
  end
322
322
  log.debug "@config #{@config}"
323
323
 
324
- procs = find_process(process_name)
325
- unless procs.empty?
326
- log.warn "WARNING: Found open arma processes! #{@config[:app_exe]}, PIDs: #{procs}, you might want to abort and close them!"
324
+ @procs = find_process(process_name, @config[:app_path])
325
+ unless @procs.empty?
326
+ log.warn "WARNING: Found open arma processes! #{@config[:app_exe]}, PIDs: #{@procs}, you might want to abort and close them!"
327
327
  end
328
328
 
329
329
  # PreProcess the config data
@@ -401,13 +401,42 @@ module Six
401
401
  STDIN.gets
402
402
  end
403
403
 
404
- def find_process(name)
404
+ def find_process(name, path)
405
405
  # TODO: Filter for process's folder.
406
406
 
407
407
  pids = []
408
408
  begin
409
409
  case RUBY_PLATFORM
410
410
  when /-mingw32$/, /-mswin32$/
411
+ %x[WMIC PROCESS get Caption,ExecutablePath,ProcessId].each_line do |l| #Commandline
412
+ line = l.clone
413
+ line.chomp!
414
+ line.strip!
415
+ reg = /([0-9]*)$/
416
+ line[reg]
417
+ pid = $1
418
+ line.sub!(reg, "")
419
+ line.strip!
420
+ line[/^([\w ]*\.\w*)[ ]*(.*)/]
421
+ image, full = $1, $2
422
+ next if image.nil?
423
+
424
+ case image.downcase
425
+ when name.downcase
426
+ unless path && !full.nil?
427
+ pid = pid.to_i
428
+ next unless pid > 0
429
+ pids << pid
430
+ next
431
+ end
432
+ if File.join(path, name).sub("/", "\\").downcase == full.downcase
433
+ pid = pid.to_i
434
+ next unless pid > 0
435
+ pids << pid
436
+ end
437
+ end
438
+ end
439
+ =begin
411
440
  out = %x[tasklist]
412
441
  out.split("\n").each do |line|
413
442
  if line =~ /\A#{name}[\t| ]*([0-9]*)/
@@ -418,6 +447,7 @@ module Six
418
447
  end
419
448
  end
420
449
  end
450
+ =end
421
451
  else
422
452
  %x[ps -A | grep #{name}].split("\n").each do |line|
423
453
  unless line[/grep/]
@@ -496,13 +526,17 @@ module Six
496
526
  mods2.gsub!('/', '\\')
497
527
  end
498
528
  name = "Play ArmA2 with #{mods}.lnk"
499
- Win32::Shortcut.new(name) do |shortcut|
500
- shortcut.description = "Start Arma2 with #{mods2}"
501
- shortcut.path = File.join(@config[:app_path], @config[:app_exe])
502
- shortcut.working_directory = @config[:app_path]
503
- shortcut.arguments = "#{@config[:app_params]} -mod=#{mods2}"
529
+ begin
530
+ Win32::Shortcut.new(name) do |shortcut|
531
+ shortcut.description = "Start Arma2 with #{mods2}"
532
+ shortcut.path = File.join(@config[:app_path], @config[:app_exe])
533
+ shortcut.working_directory = @config[:app_path]
534
+ shortcut.arguments = "#{@config[:app_params]} -mod=#{mods2}"
535
+ end
536
+ log.info "Created shortcut (in #{path}): #{name}"
537
+ rescue => e
538
+ log.warn "WARNING: Problem while creating shortcut! ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
504
539
  end
505
- log.info "Created shortcut (in #{path}): #{name}"
506
540
  Dir.chdir cwd
507
541
  else
508
542
  log.warn "Unsupported on current Platform: #{RUBY_PLATFORM}"
@@ -513,6 +547,14 @@ module Six
513
547
  shortcut @config[:app_path]
514
548
  end
515
549
 
550
+ def kill
551
+ @procs.each do |p|
552
+ Process.kill(9, p).each do |kill| #.ProcessId
553
+ log.debug "Killed: #{kill}"
554
+ end
555
+ end
556
+ end
557
+
516
558
  def createdesktopshortcut
517
559
  case RUBY_PLATFORM
518
560
  when /-mingw32$/, /-mswin32$/
@@ -7,7 +7,7 @@ module Six
7
7
  module Updater
8
8
  module_function
9
9
  def parse_options
10
- todo, general_todo, second_todo = [], [], []
10
+ todo, general_todo, second_todo, pre_todo = [], [], [], []
11
11
 
12
12
  options = Hash.new
13
13
  OptionParser.new do |opts|
@@ -78,6 +78,10 @@ module Six
78
78
  options[:force] = bool
79
79
  end
80
80
 
81
+ opts.on("-q", "--kill", "Kills the open processes") do |bool|
82
+ pre_todo << :kill if bool
83
+ end
84
+
81
85
  opts.on("--mods S", String, "Additional Mods") do |s|
82
86
  options[:mods] = s
83
87
  end
@@ -87,7 +91,7 @@ module Six
87
91
  end
88
92
  end.parse!
89
93
 
90
- default = if (todo + second_todo + general_todo).size > 0
94
+ default = if (todo + second_todo + general_todo + pre_todo).size > 0
91
95
  false
92
96
  else
93
97
  true
@@ -105,6 +109,8 @@ module Six
105
109
  []
106
110
  end
107
111
  end
112
+
113
+ @pre_todo = pre_todo
108
114
  @general_todo = if general_todo.size > 0
109
115
  general_todo
110
116
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: six-updater
3
3
  version: !ruby/object:Gem::Version
4
- hash: 77
4
+ hash: 71
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 21
9
- - 3
10
- version: 0.21.3
8
+ - 22
9
+ - 0
10
+ version: 0.22.0
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - Sickboy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-15 00:00:00 +02:00
18
+ date: 2010-07-20 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency