Index: build/android/pylib/remote/device/remote_device_environment.py |
diff --git a/build/android/pylib/remote/device/remote_device_environment.py b/build/android/pylib/remote/device/remote_device_environment.py |
index a701d9541e6bae2b07497e1e6937339266d2ba81..de761c329310d2979728dfc480ad889aa48bf5ed 100644 |
--- a/build/android/pylib/remote/device/remote_device_environment.py |
+++ b/build/android/pylib/remote/device/remote_device_environment.py |
@@ -4,6 +4,8 @@ |
"""Environment setup and teardown for remote devices.""" |
+from distutils.version import LooseVersion |
jbudorick
2015/01/27 17:58:55
Do we know we'll have this everywhere?
Also, if t
rnephew (Wrong account)
2015/01/27 18:46:21
I didnt' have to install it, and as far as I can f
|
+import json |
import logging |
import os |
import random |
@@ -34,33 +36,28 @@ class RemoteDeviceEnvironment(environment.Environment): |
self._api_key = api_key_file.read().strip() |
elif args.api_key: |
self._api_key = args.api_key |
- else: |
- error_func('Must set api key with --api-key or --api-key-file') |
if args.api_secret_file: |
with open(args.api_secret_file) as api_secret_file: |
self._api_secret = api_secret_file.read().strip() |
elif args.api_secret: |
self._api_secret = args.api_secret |
- else: |
- error_func('Must set api secret with --api-secret or --api-secret-file') |
- if not args.api_protocol: |
- error_func('Must set api protocol with --api-protocol. Example: http') |
self._api_protocol = args.api_protocol |
- |
- if not args.api_address: |
- error_func('Must set api address with --api-address') |
self._api_address = args.api_address |
- |
- if not args.api_port: |
- error_func('Must set api port with --api-port.') |
self._api_port = args.api_port |
self._access_token = '' |
self._results_path = args.results_path |
- self._remote_device = args.remote_device |
- self._remote_device_os = args.remote_device_os |
+ if args.remote_device: |
+ self._remote_device = args.remote_device.split(',') |
jbudorick
2015/01/27 17:58:55
I'm not sure these should necessarily support mult
rnephew (Wrong account)
2015/01/27 18:46:21
Done.
|
+ else: |
+ self._remote_device = '' |
+ if args.remote_device_os: |
+ self._remote_device_os = args.remote_device_os.split(',') |
jbudorick
2015/01/27 17:58:55
ditto
rnephew (Wrong account)
2015/01/27 18:46:21
Done.
|
+ else: |
+ self._remote_device_os = '' |
+ self._remote_device_minimum_os = args.remote_device_minimum_os |
self._runner_package = args.runner_package |
self._runner_type = args.runner_type |
self._device = '' |
@@ -72,6 +69,57 @@ class RemoteDeviceEnvironment(environment.Environment): |
'in-progress': 60 * 30, |
'unknown': 60 * 5 |
} |
+ if args.remote_device_file: |
+ with open(args.remote_device_file) as device_file: |
+ device_json = json.load(device_file) |
+ if 'remote_device' in device_json: |
+ self._remote_device = device_json['remote_device'].split(',') |
jbudorick
2015/01/27 17:58:55
oh, it is json.
Why aren't remote_device and remo
rnephew (Wrong account)
2015/01/27 18:46:21
Done.
|
+ if 'remote_device_os' in device_json: |
+ self._remote_device_os = device_json['remote_device_os'].split(',') |
+ if 'remote_device_minimum_os' in device_json: |
+ self._remote_device_minimum_os = ( |
+ device_json['remote_device_minimum_os']) |
+ if 'api_address' in device_json: |
+ self._api_address = device_json['api_address'] |
+ if 'api_secret' in device_json: |
+ self._api_secret = device_json['api_secret'] |
+ if 'api_key' in device_json: |
+ self._api_key = device_json['api_key'] |
jbudorick
2015/01/27 17:58:55
Most of these can just be
self._blah = device_j
rnephew (Wrong account)
2015/01/27 18:46:21
I went with ..get('blah', self._blah) that way if
|
+ if 'api_protocol' in device_json: |
+ self._api_protocol = device_json['api_protocol'] |
+ if 'api_port' in device_json: |
+ self._api_port = device_json['api_port'] |
+ if 'timeouts' in device_json: |
+ self._timeouts = device_json['timeouts'] |
+ |
+ if not self._api_address: |
+ error_func('Must set api address with --api-address' |
+ 'or in --remote-device-file.') |
+ if not self._api_protocol: |
+ error_func('Must set api protocol with --api-protocol' |
+ ' or in --remote-device-file. Example: http') |
+ if not self._api_key: |
+ error_func('Must set api key with --api-key, --api-key-file' |
+ 'or in --remote-device-file') |
+ if not self._api_secret: |
+ error_func('Must set api secret with --api-secret, --api-secret-file' |
+ 'or in --remote-device-file') |
+ if not self._api_port: |
+ error_func('Must set api port with --api-port' |
+ 'or in --remote-device-file') |
+ if not isinstance(self._timeouts, dict): |
+ error_func('Timeouts must be a dictionary.') |
+ if ('queueing' not in self._timeouts |
+ or 'installing' not in self._timeouts |
+ or 'in-progress' not in self._timeouts |
+ or 'unknown' not in self._timeouts) : |
+ error_func('Timeouts must contain queueing,' |
+ ' installing, in-progress, and unknown.') |
+ # Sanitize inputs. |
+ for x in range(0,len(self._remote_device)): |
+ self._remote_device[x] = self._remote_device[x].strip() |
+ for y in range(0,len(self._remote_device_os)): |
+ self._remote_device_os[y] = self._remote_device_os[y].strip() |
if not args.trigger and not args.collect: |
self._trigger = True |
@@ -150,10 +198,14 @@ class RemoteDeviceEnvironment(environment.Environment): |
for device in device_list: |
if device['os_name'] != self._device_type: |
continue |
- if self._remote_device and device['name'] != self._remote_device: |
+ if self._remote_device and device['name'] not in self._remote_device: |
continue |
if (self._remote_device_os |
- and device['os_version'] != self._remote_device_os): |
+ and device['os_version'] not in self._remote_device_os): |
+ continue |
+ if (self._remote_device_minimum_os |
+ and LooseVersion(device['os_version']) |
+ < LooseVersion(self._remote_device_minimum_os)): |
continue |
if ((self._remote_device and self._remote_device_os) |
or device['available_devices_count']): |