hive-runner-android 1.1.5 → 1.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf5ea608ebe487e9909148bdfdb250e8811b5b0d
4
- data.tar.gz: 78a693e1b523daab61ab4ff5663d7fe2c8f142e2
3
+ metadata.gz: 2aae14ef832b9ea895f4bb1029c0b923e65614f8
4
+ data.tar.gz: 4ba623a934d783c2ea3d54e04e6f9098ccfc2921
5
5
  SHA512:
6
- metadata.gz: dc33457203d224959ce1fa945bcbf6ab29b727cdfaa97297e5c38ae419d06ee3eae7e20914ed9248ee88f1d52026d5d275dbbba7b9ae8d605f520fce88b94505
7
- data.tar.gz: e060cbd2d68c675f24fb9b8c4be1a812584c73d3f4759a005d2b48ce54c9e5a518bbe3cc305330287518f64832f6b6ead214772c6c9d485d7c16d32ec5421684
6
+ metadata.gz: f50c6fe8a8b917f156e71b3571dafaa657085b27559a46c15d628441523333d3dbc066a69c6dc1d1a7a14567db4b08b21732a45313061152214c3012d5e1d46e
7
+ data.tar.gz: 2ce15dc130d09fa7242c5ef590fc24b10a99fee4a2332ed0d669895cc7d70bd7dddaa7de35da79b30f1d5154b090d11df32d64555e5234280592817a507222e8
@@ -24,11 +24,10 @@ module Hive
24
24
  attached_devices = []
25
25
  connected_devices.each do |device|
26
26
  Hive.logger.debug("HM) Device details: #{device.inspect}")
27
- registered_device = devices.select { |a| a.serial == device['serial'] && a.status != :unauthorized }
27
+ registered_device = devices.select { |a| a.serial == device['serial'] && a.status != :unauthorized && a.status != :no_permissions}
28
28
  if registered_device.empty?
29
29
  # A previously registered device isn't attached
30
- Hive.logger.debug("HM) Removing previously registered device - #{device}")
31
- Hive.hive_mind.disconnect(device['id'])
30
+ Hive.logger.debug("HM) A previously registered device has disappeared: #{device}")
32
31
  else
33
32
  # A previously registered device is attached, poll it
34
33
  Hive.logger.debug("HM) Setting #{device} to be polled")
@@ -51,7 +50,7 @@ module Hive
51
50
  Hive.hive_mind.poll(*to_poll)
52
51
 
53
52
  # Register new devices
54
- devices.select{|a| a.status != :unauthorized}.each do |device|
53
+ devices.select{|a| a.status != :unauthorized && a.status != :no_permissions}.each do |device|
55
54
  begin
56
55
  dev = Hive.hive_mind.register(
57
56
  hostname: device.model,
@@ -76,8 +75,9 @@ module Hive
76
75
 
77
76
  else
78
77
  Hive.logger.info('HM) No Hive Mind connection')
78
+ Hive.logger.debug("HM) Error: #{Hive.hive_mind.device_details[:error]}")
79
79
  # Hive Mind isn't available, use DeviceAPI instead
80
- device_info = devices.select { |a| a.status != :unauthorized }.map do |device|
80
+ device_info = devices.select { |a| a.status != :unauthorized && a.status != :no_permissions }.map do |device|
81
81
  {
82
82
  'id' => device.serial,
83
83
  'serial' => device.serial,
@@ -117,11 +117,10 @@ module Hive
117
117
  if hive_details.is_a? Hash
118
118
  # DeviceDB information is available, use it
119
119
  hive_details['devices'].select {|a| a['os'] == 'android'}.each do |device|
120
- registered_device = devices.select { |a| a.serial == device['serial'] && a.status != :unauthorized}
120
+ registered_device = devices.select { |a| a.serial == device['serial'] && a.status != :unauthorized && a.status != :no_permissions }
121
121
  if registered_device.empty?
122
122
  # A previously registered device isn't attached
123
- Hive.logger.debug("Removing previously registered device - #{device}")
124
- Hive.devicedb('Device').hive_disconnect(device['id'])
123
+ Hive.logger.debug("HM) A previously registered device has disappeared: #{device}")
125
124
  else
126
125
  # A previously registered device is attached, poll it
127
126
  Hive.logger.debug("#{Time.now} Polling attached device - #{device}")
@@ -154,7 +153,7 @@ module Hive
154
153
  else
155
154
  # DeviceDB isn't available, use DeviceAPI instead
156
155
 
157
- device_info = devices.select { |a| a.status != :unauthorized }.map do |device|
156
+ device_info = devices.select { |a| a.status != :unauthorized && a.status != :no_permissions }.map do |device|
158
157
  {
159
158
  'id' => device.serial,
160
159
  'serial' => device.serial,
@@ -12,19 +12,21 @@ module Hive
12
12
  @brand = config['brand'].downcase.gsub(/\s/, '_')
13
13
  @os_version = config['os_version']
14
14
 
15
- Hive.logger.info("Config: #{config.inspect}")
15
+ # TODO The setting of config['queues'] can be removed when DeviceDB
16
+ # is no longer being used
16
17
  new_queues = calculate_queue_names
17
18
  new_queues = new_queues | config['queues'] if config.has_key?('queues')
18
19
 
19
20
  devicedb_ids = new_queues.map { |queue| find_or_create_queue(queue) }
20
21
  Hive.devicedb('Device').edit(@identity, { device_queue_ids: devicedb_ids })
21
22
  config['queues'] = new_queues
23
+
22
24
  super
23
25
  end
24
26
 
25
27
  # Uses either DeviceAPI or DeviceDB to generate queue names for a device
28
+ # TODO Remove when DeviceDB is not being used any more
26
29
  def calculate_queue_names
27
- Hive.logger.info("QUEUE PREFIX; #{@queue_prefix}")
28
30
  [
29
31
  "#{@queue_prefix}#{self.model}",
30
32
  "#{@queue_prefix}#{self.brand}",
@@ -20,6 +20,10 @@ module Hive
20
20
  attr_accessor :device
21
21
 
22
22
  def initialize(device)
23
+ @queue_prefix = device['queue_prefix'].to_s == '' ? '' : "#{device['queue_prefix']}-"
24
+ @model = device['model'].downcase.gsub(/\s/, '_')
25
+ @brand = device['brand'].downcase.gsub(/\s/, '_')
26
+ @os_version = device['os_version']
23
27
  @worker_ports = PortReserver.new
24
28
  begin
25
29
  device.merge!({"device_api" => DeviceAPI::Android.device(device['serial'])})
@@ -105,6 +109,24 @@ module Hive
105
109
  @state
106
110
  end
107
111
  end
112
+
113
+ def autogenerated_queues
114
+ @log.info("Autogenerating queues")
115
+ [
116
+ "#{@queue_prefix}#{@model}",
117
+ "#{@queue_prefix}#{@brand}",
118
+ "#{@queue_prefix}android",
119
+ "#{@queue_prefix}android-#{@os_version}",
120
+ "#{@queue_prefix}android-#{@os_version}-#{@model}"
121
+ ]
122
+ end
123
+
124
+ def hive_mind_device_identifiers
125
+ {
126
+ serial: @device_id,
127
+ device_type: 'Mobile'
128
+ }
129
+ end
108
130
  end
109
131
  end
110
132
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hive-runner-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
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-02-22 00:00:00.000000000 Z
11
+ date: 2016-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: device_api-android