hive-runner-android 1.2.9 → 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3f9abd6596eb7a64374be57d2f8b2d3bb853dbf
4
- data.tar.gz: 8dd1e096d59981911a9e5a78ef82a9d4dea73119
3
+ metadata.gz: bf1f2542f542b5b0ed152c23d60a44f134c5dcdd
4
+ data.tar.gz: 246810545eb824b4be5a053ce55eeca54b438964
5
5
  SHA512:
6
- metadata.gz: 4bd38d437bd66bdd0cdee951e193a5ff0aee6c3f14adc8e2580c9ce6d73272724685edb0443d20c31d370915788917a28a58ef18ede74972096993dbf68560af
7
- data.tar.gz: 392357e6c5e51badb0eec571bd5d3372bc2f375d75772b6eb913552e9a058f0972e7d750a3f83590cc3df2f6f2e00e178b361ad590b15853b0e3fb44e85c5a1e
6
+ metadata.gz: 383167bb0c08cc36b32749fdfdd888c811481993603ce1339b8d7aef3b08a1c7b2181dc833b492fe8c416f5f6d8a785e3881df701fcad95a9290b5f452ae6ebc
7
+ data.tar.gz: 02f6df58f2af851153d24da588cc63ebba1026a2d8a021854416f4fe3f338bf7d1400e2702a513df298351f9c07b6d084fb46e36157d6ca100e7126c035ebcf3
@@ -42,9 +42,21 @@ module Hive
42
42
  Hive.logger.debug("A previously registered device has disappeared: #{device}")
43
43
  else
44
44
  # A previously registered device is attached, poll it
45
- Hive.logger.debug("Setting #{device} to be polled")
45
+
46
+ Hive.logger.debug("Setting #{device['name']} to be polled")
46
47
  Hive.logger.debug("Device: #{registered_device.inspect}")
47
48
  begin
49
+ Hive.logger.debug("#{device['name']} OS version: #{registered_device[0].version}")
50
+ # Check OS version and update if necessary
51
+ if device['operating_system_version'] != registered_device[0].version
52
+ Hive.logger.info("Updating OS version of #{device['name']} from #{device['operating_system_version']} to #{registered_device[0].version}")
53
+ Hive.hive_mind.register(
54
+ id: device['id'],
55
+ operating_system_name: 'android',
56
+ operating_system_version: registered_device[0].version
57
+ )
58
+ end
59
+
48
60
  attached_devices << self.create_device(device.merge('os_version' => registered_device[0].version))
49
61
  to_poll << device['id']
50
62
  rescue DeviceAPI::DeviceNotFound => e
@@ -7,31 +7,41 @@ module Hive
7
7
  def battery
8
8
  self.device_api.battery_info
9
9
  end
10
+
11
+ def units
12
+ {
13
+ :temperature => "K",
14
+ :voltage => "mV"
15
+ }
16
+ end
10
17
 
11
18
  def diagnose
12
- result = nil
19
+ data = {}
13
20
  battery_info = battery
14
- begin
15
- if config != nil && config.keys.count != 0
16
- temperature = battery_info['temperature']
17
- if temperature.to_i < config['temperature'].to_i
18
- result = self.pass("Temperature: #{temperature}\n Battery status: OK", "battery")
19
- else
20
- result = self.fail("Battery temperature above threshold. Temperature: #{temperature} ", "battery")
21
- end
22
- else
23
- result = self.pass("No parameter specified for battery", "battery")
21
+ result = "pass"
22
+ config.keys.each do |c|
23
+ raise InvalidParameterError.new("Battery Parameter should be any of #{battery_info.keys}") if !battery_info.has_key? c
24
+ begin
25
+ data[:"#{c}"] = { :value => battery_info[c], :unit => units[:"#{c}"] }
26
+ result = "fail" if battery_info[c].to_i > config[c].to_i
27
+ rescue => e
28
+ Hive.logger.error "Incorrect battery parameter => #{e}"
29
+ return self.fail("Incorrect parameter #{c} specified. Battery Parameter can be any of #{battery_info.keys}", "Battery")
24
30
  end
25
- rescue
26
- Hive.logger.error("Invalid Battery Parameter")
27
- raise InvalidParameterError.new("Invalid Parameter for battery") if !result
28
31
  end
29
- result
32
+
33
+ if result != "fail"
34
+ self.pass("Battery", data)
35
+ else
36
+ self.fail("Battery", data)
37
+ end
38
+
30
39
  end
31
40
 
32
41
  def repair(result)
33
- result = self.fail("Battery temperature above threshold.", "battery")
42
+ self.fail("Unplug device from hive", "Battery")
34
43
  end
44
+
35
45
  end
36
46
  end
37
47
  end
@@ -7,33 +7,27 @@ module Hive
7
7
  def memory
8
8
  @memory = self.device_api.memory unless @memory
9
9
  mem = @memory.mem_info
10
- return {:free => mem.free.split(' ')[0],
11
- :total => mem.total.split(' ')[0],
12
- :used => mem.used.split(' ')[0], }
10
+ return {:free => mem.free.split(' ').first,
11
+ :total => mem.total.split(' ').first,
12
+ :used => mem.used.split(' ').first, }
13
13
  end
14
14
 
15
15
  def diagnose
16
- result = nil
16
+ data = {}
17
+ result = "pass"
17
18
  operator = {:free => :>=, :used => :<= , :total => :==}
18
19
  memory_status = memory
19
- if config != nil && config.keys.count != 0
20
- config.each do |key, value|
21
- begin
22
- if memory_status[:"#{key}"].to_i.send(operator[:"#{key}"], value.to_i)
23
- result = self.pass("#{key.capitalize} Memory (#{memory_status[:"#{key}"]}) #{operator[:"#{key}"]} #{value}", "memory" )
24
- else
25
- result = self.fail("Error: #{key.capitalize} Memory (#{memory_status[:"#{key}"]}) is not #{operator[:"#{key}"]} #{value}", "memory")
26
- break
27
- end
28
- rescue
29
- Hive.logger.error("Invalid Memory Parameter")
30
- raise InvalidParameterError.new("Invalid Parameter for memory") if !result
31
- end
32
- end
33
- else
34
- result = self.pass("No parameter specified", "memory")
20
+ config.each do |key, value|
21
+ raise InvalidParameterError.new("Battery Parameter should be any of ':free', ':used', ':total'") if !memory_status.has_key? key
22
+ data[:"#{key}_memory"] = {:value => value, :unit => "kB"}
23
+ result = "fail" if !memory_status[:"#{key}"].to_i.send(operator[:"#{key}"], value.to_i)
24
+ end
25
+
26
+ if result != "pass"
27
+ self.fail("Memory", data)
28
+ else
29
+ self.pass("Memory", data)
35
30
  end
36
- result
37
31
  end
38
32
 
39
33
  def repair(result)
@@ -44,4 +38,4 @@ module Hive
44
38
  end
45
39
  end
46
40
  end
47
- end
41
+ end
@@ -4,27 +4,31 @@ module Hive
4
4
  class Android
5
5
  class Uptime < Diagnostic
6
6
 
7
- def diagnose
7
+ def diagnose(data={})
8
8
  if config.has_key?(:reboot_timeout)
9
9
  uptime = self.device_api.uptime
10
10
  if uptime < config[:reboot_timeout]
11
- self.pass("Time for next reboot: #{config[:reboot_timeout] - uptime}s", "Reboot")
11
+ data[:next_reboot_in] = {:value => "#{config[:reboot_timeout] - uptime}", :unit => "s"}
12
+ self.pass("Time for next reboot: #{config[:reboot_timeout] - uptime}s", data)
12
13
  else
13
- self.fail("Reboot required", "Reboot")
14
+ self.fail("Reboot required", data)
14
15
  end
15
16
  else
16
- self.pass("Not configured for reboot", "Reboot")
17
+ data[:reboot] = {:value => "Not configured for reboot. Set in config {:reboot_timeout => '2400'}"}
18
+ self.pass("Not configured for reboot", data)
17
19
  end
18
20
  end
19
21
 
20
22
  def repair(result)
23
+ data = {}
21
24
  Hive.logger.info("Rebooting the device")
22
25
  begin
23
26
  self.device_api.reboot
27
+ data[:last_rebooted] = {:value => Time.now}
24
28
  rescue
25
29
  Hive.logger.error("Device not found")
26
30
  end
27
- diagnose
31
+ diagnose(data)
28
32
  end
29
33
 
30
34
  end
metadata CHANGED
@@ -1,89 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hive-runner-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Wilson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-31 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: device_api-android
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
- - - '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.2.9
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.0'
30
- - - '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.2.9
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: hive-runner
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 2.1.1
39
+ version: 2.1.18
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ~>
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 2.1.1
46
+ version: 2.1.18
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: terminal-table
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.4'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - '>='
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.4'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ~>
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '3.5'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ~>
72
+ - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '3.5'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: webmock
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ~>
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
81
  version: '1.22'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ~>
86
+ - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '1.22'
89
89
  description: The Android controller module for Hive Runner
@@ -112,17 +112,17 @@ require_paths:
112
112
  - lib
113
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.0.14
125
+ rubygems_version: 2.5.1
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Hive Runner Android