o3d3xx 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3e804f71d991a18d5325afd25f8b471f4165ec1
4
+ data.tar.gz: a84a0976da191208fa5e9585807718eae17af43d
5
+ SHA512:
6
+ metadata.gz: f41041646dcd4358db60003a778b9b58a5f1cde18cc2bb52e455897137bcb5ef675ab5e1051ee87776fdd953dfc11a4be7a845ba94ab15fbc36410f4217d5117
7
+ data.tar.gz: d814d3c3a76d1d70f74ec0f4a53d2c3ff37bdcfaff8856d34451a6ee2e0de323c59c51483ec29db3b0c39f590ffdf81a7c7f4da32a9e7d8821f3596ebb337bff
@@ -97,8 +97,10 @@ rv = 0
97
97
 
98
98
  if options[:file]
99
99
  if swupdate.read_status_empty()
100
- print "Uploading swu image #{options[:file]} ..."
101
- swupdate.upload_file(options[:file])
100
+ print "Uploading swu image #{options[:file]} ... "
101
+ exit(1) unless swupdate.upload_file(options[:file])
102
+ puts ' OK'
103
+ print "Installing image ... "
102
104
  if swupdate.wait_for_status(O3D3XX::Swupdate::UPLOAD_SUCCESS, 60)
103
105
  puts ' OK'
104
106
  rv = 0
@@ -45,6 +45,11 @@ module O3D3XX
45
45
  @base_uri = "http://#{@config[:host]}:#{@config[:port]}"
46
46
  end
47
47
 
48
+ # Print out an error message when an error was raised
49
+ def not_in_swupdate?()
50
+ puts 'FAILED'
51
+ puts 'Device not in SWUPDATE mode?'
52
+ end
48
53
  # Uploads a file to swupdate system. So far this file has
49
54
  # to be a swu image file.
50
55
  # This call is asynchronous to the following installation
@@ -54,15 +59,28 @@ module O3D3XX
54
59
  # @param filename filename of swu image to install on target
55
60
  #
56
61
  def upload_file(filename)
62
+ res = false
57
63
  raise 'Invalid file name given !' unless File.exist?(filename)
58
64
  uri = URI.parse("#{@base_uri}/handle_post_request")
59
65
  http = Net::HTTP.new(uri.host, uri.port)
60
- request = Net::HTTP::Post.new(uri.request_uri)
66
+ header = {
67
+ 'Content-Type'=> 'application/octet-stream',
68
+ 'X_FILENAME'=> "#{File.basename(filename)}",
69
+ }
70
+ request = Net::HTTP::Post.new(uri.request_uri,header)
61
71
  request.body = File.read(filename)
62
- request['Content-Type'] = 'application/octet-stream'
63
- request['Connection'] = 'keep-alive'
64
- request['X_FILENAME'] = "#{File.basename(filename)}"
65
- http.request(request)
72
+ begin
73
+ http.request(request) { |response|
74
+ break if response.code == 200
75
+ }
76
+ res = true
77
+ rescue Errno::ECONNRESET
78
+ not_in_swupdate?
79
+ rescue Errno::ECONNREFUSED
80
+ not_in_swupdate?
81
+ end
82
+
83
+ res
66
84
  end
67
85
 
68
86
  # Reads status queue empty on http server, i.e.
@@ -11,5 +11,5 @@
11
11
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
12
 
13
13
  module O3D3XX
14
- VERSION = "0.0.3"
14
+ VERSION = "0.0.4"
15
15
  end
data/o3d3xx.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = O3D3XX::VERSION
9
9
  spec.authors = ["Christian Ege"]
10
10
  spec.email = ["k4230r6@gmail.com"]
11
- spec.description = "Ruby interface for ifm efector O3d3xx"
11
+ spec.description = "Ruby interface for ifm efector O3d3xx is a combination of the access libraries and some executables"
12
12
  spec.summary = "Ruby interface for ifm efector O3d3xx"
13
13
  spec.homepage = "https://github.com/graugans/ruby-o3d3xx"
14
14
  spec.license = "MIT"
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rake", "~> 10"
23
23
  spec.required_ruby_version = ">= 1.9.3"
24
24
  end
metadata CHANGED
@@ -1,49 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: o3d3xx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christian Ege
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-03-22 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '10'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
46
- description: Ruby interface for ifm efector O3d3xx
40
+ version: '10'
41
+ description: Ruby interface for ifm efector O3d3xx is a combination of the access
42
+ libraries and some executables
47
43
  email:
48
44
  - k4230r6@gmail.com
49
45
  executables:
@@ -51,7 +47,7 @@ executables:
51
47
  extensions: []
52
48
  extra_rdoc_files: []
53
49
  files:
54
- - .gitignore
50
+ - ".gitignore"
55
51
  - Gemfile
56
52
  - LICENSE.txt
57
53
  - README.md
@@ -67,26 +63,25 @@ files:
67
63
  homepage: https://github.com/graugans/ruby-o3d3xx
68
64
  licenses:
69
65
  - MIT
66
+ metadata: {}
70
67
  post_install_message:
71
68
  rdoc_options: []
72
69
  require_paths:
73
70
  - lib
74
71
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
72
  requirements:
77
- - - ! '>='
73
+ - - ">="
78
74
  - !ruby/object:Gem::Version
79
75
  version: 1.9.3
80
76
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
77
  requirements:
83
- - - ! '>='
78
+ - - ">="
84
79
  - !ruby/object:Gem::Version
85
80
  version: '0'
86
81
  requirements: []
87
82
  rubyforge_project:
88
- rubygems_version: 1.8.23
83
+ rubygems_version: 2.4.5.1
89
84
  signing_key:
90
- specification_version: 3
85
+ specification_version: 4
91
86
  summary: Ruby interface for ifm efector O3d3xx
92
87
  test_files: []