tem_multi_updater 0.2 → 0.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/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.3. Added tem_multi_reset_fw which forces the update, resetting the TEM cards.
2
+
1
3
  v0.2. Complete test coverage.
2
4
 
3
5
  v0.1. Initial release.
data/Manifest CHANGED
@@ -3,6 +3,7 @@ LICENSE
3
3
  Manifest
4
4
  README
5
5
  Rakefile
6
+ bin/tem_multi_reset_fw
6
7
  bin/tem_multi_update_fw
7
8
  lib/tem_multi_updater.rb
8
9
  lib/tem_multi_updater/updater.rb
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Launcher for the multi-updater code with forced updating.
4
+ #
5
+ # Author:: Victor Costan
6
+ # Copyright:: Copyright (C) 2009 Massachusetts Institute of Technology
7
+ # License:: MIT
8
+ #
9
+ # Usage: tem_multi_reset_fw [host[:port]]
10
+ # The host:port should point to the RPC port of the tem_multi_proxy server.
11
+ # The default host is localhost, and the default port is 9000.
12
+
13
+ require 'logger'
14
+ require 'rubygems'
15
+ require 'tem_multi_proxy'
16
+ require 'tem_multi_updater'
17
+
18
+ server_addr = ARGV[0] || 'localhost'
19
+ logger = Logger.new STDERR
20
+ logger.level = Logger::INFO
21
+ updater = Tem::MultiUpdater::Updater.new logger, server_addr, :force => true
22
+ updater.run
@@ -18,9 +18,10 @@ class Updater
18
18
  # logger:: receives update progress notifications
19
19
  # multiproxy_server_addr:: the address (host or host:port) of the
20
20
  # tem_multi_proxy RPC port
21
- def initialize(logger, multiproxy_server_addr)
21
+ def initialize(logger, multiproxy_server_addr, options = {})
22
22
  @logger = logger
23
23
  @server_addr = multiproxy_server_addr
24
+ @options = options
24
25
  @pending = nil
25
26
  @pending_mx, @pending_cv = Mutex.new, ConditionVariable.new
26
27
  end
@@ -124,7 +125,9 @@ class Updater
124
125
  #
125
126
  # Args:
126
127
  # transport_config:: smart-card transport connecting to the TEM card
127
- def needs_update?(transport)
128
+ def needs_update?(transport)
129
+ return true if @options[:force]
130
+
128
131
  begin
129
132
  tem = Tem::Session.new transport
130
133
  tem_version = tem.fw_version
@@ -2,17 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{tem_multi_updater}
5
- s.version = "0.2"
5
+ s.version = "0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Victor Costan"]
9
9
  s.date = %q{2009-11-10}
10
- s.default_executable = %q{tem_multi_update_fw}
11
10
  s.description = %q{Updates the firmware on all TEMs connected to a tem_multi_proxy.}
12
11
  s.email = %q{victor@costan.us}
13
- s.executables = ["tem_multi_update_fw"]
14
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/tem_multi_update_fw", "lib/tem_multi_updater.rb", "lib/tem_multi_updater/updater.rb"]
15
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/tem_multi_update_fw", "lib/tem_multi_updater.rb", "lib/tem_multi_updater/updater.rb", "test/integration_test.rb", "test/updater_test.rb", "tem_multi_updater.gemspec"]
12
+ s.executables = ["tem_multi_reset_fw", "tem_multi_update_fw"]
13
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/tem_multi_reset_fw", "bin/tem_multi_update_fw", "lib/tem_multi_updater.rb", "lib/tem_multi_updater/updater.rb"]
14
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/tem_multi_reset_fw", "bin/tem_multi_update_fw", "lib/tem_multi_updater.rb", "lib/tem_multi_updater/updater.rb", "test/integration_test.rb", "test/updater_test.rb", "tem_multi_updater.gemspec"]
16
15
  s.homepage = %q{http://tem.rubyforge.org}
17
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Tem_multi_updater", "--main", "README"]
18
17
  s.require_paths = ["lib"]
data/test/updater_test.rb CHANGED
@@ -26,6 +26,13 @@ class UpdaterTest < Test::Unit::TestCase
26
26
  super
27
27
  end
28
28
 
29
+ def test_reset_switch
30
+ updater = Tem::MultiUpdater::Updater.new Logger.new(StringIO.new),
31
+ @server_addr, :force => true
32
+ flexmock(Tem::Session).should_receive(:new).never
33
+ assert_equal true, updater.needs_update?(:bogus_transport)
34
+ end
35
+
29
36
  def test_dead_proxy
30
37
  flexmock(Tem::MultiProxy::Client).should_receive(:query_tems).
31
38
  with(@server_addr).and_return(nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tem_multi_updater
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.2"
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
@@ -65,6 +65,7 @@ dependencies:
65
65
  description: Updates the firmware on all TEMs connected to a tem_multi_proxy.
66
66
  email: victor@costan.us
67
67
  executables:
68
+ - tem_multi_reset_fw
68
69
  - tem_multi_update_fw
69
70
  extensions: []
70
71
 
@@ -72,6 +73,7 @@ extra_rdoc_files:
72
73
  - CHANGELOG
73
74
  - LICENSE
74
75
  - README
76
+ - bin/tem_multi_reset_fw
75
77
  - bin/tem_multi_update_fw
76
78
  - lib/tem_multi_updater.rb
77
79
  - lib/tem_multi_updater/updater.rb
@@ -81,6 +83,7 @@ files:
81
83
  - Manifest
82
84
  - README
83
85
  - Rakefile
86
+ - bin/tem_multi_reset_fw
84
87
  - bin/tem_multi_update_fw
85
88
  - lib/tem_multi_updater.rb
86
89
  - lib/tem_multi_updater/updater.rb