Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: build/android/pylib/remote/device/remote_device_environment.py

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Environment setup and teardown for remote devices.""" 5 """Environment setup and teardown for remote devices."""
6 6
7 import logging
7 import os 8 import os
8 import sys 9 import sys
9 10
10 from pylib import constants 11 from pylib import constants
11 from pylib.base import environment 12 from pylib.base import environment
13 from pylib.remote.device import appurify_sanitized
12 from pylib.remote.device import remote_device_helper 14 from pylib.remote.device import remote_device_helper
13 15
14 sys.path.append(os.path.join(
15 constants.DIR_SOURCE_ROOT, 'third_party', 'requests', 'src'))
16 sys.path.append(os.path.join(
17 constants.DIR_SOURCE_ROOT, 'third_party', 'appurify-python', 'src'))
18 import appurify.api
19
20
21 class RemoteDeviceEnvironment(environment.Environment): 16 class RemoteDeviceEnvironment(environment.Environment):
22 """An environment for running on remote devices.""" 17 """An environment for running on remote devices."""
23 18
24 def __init__(self, args, error_func): 19 def __init__(self, args, error_func):
25 """Constructor. 20 """Constructor.
26 21
27 Args: 22 Args:
28 args: Command line arguments. 23 args: Command line arguments.
29 error_func: error to show when using bad command line arguments. 24 error_func: error to show when using bad command line arguments.
30 """ 25 """
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 """Set up the test run when used as a context manager.""" 84 """Set up the test run when used as a context manager."""
90 self.SetUp() 85 self.SetUp()
91 return self 86 return self
92 87
93 def __exit__(self, exc_type, exc_val, exc_tb): 88 def __exit__(self, exc_type, exc_val, exc_tb):
94 """Tears down the test run when used as a context manager.""" 89 """Tears down the test run when used as a context manager."""
95 self.TearDown() 90 self.TearDown()
96 91
97 def _GetAccessToken(self): 92 def _GetAccessToken(self):
98 """Generates access token for remote device service.""" 93 """Generates access token for remote device service."""
99 access_token_results = appurify.api.access_token_generate( 94 logging.info('Generating remote service access token')
95 access_token_results = appurify_sanitized.api.access_token_generate(
100 self._api_key, self._api_secret) 96 self._api_key, self._api_secret)
101 remote_device_helper.TestHttpResponse(access_token_results, 97 remote_device_helper.TestHttpResponse(access_token_results,
102 'Unable to generate access token.') 98 'Unable to generate access token.')
103 self._access_token = access_token_results.json()['response']['access_token'] 99 self._access_token = access_token_results.json()['response']['access_token']
104 100
105 def _RevokeAccessToken(self): 101 def _RevokeAccessToken(self):
106 """Destroys access token for remote device service.""" 102 """Destroys access token for remote device service."""
107 revoke_token_results = appurify.api.access_token_revoke(self._access_token) 103 logging.info('Revoking remote service access token')
104 revoke_token_results = appurify_sanitized.api.access_token_revoke(
105 self._access_token)
108 remote_device_helper.TestHttpResponse(revoke_token_results, 106 remote_device_helper.TestHttpResponse(revoke_token_results,
109 'Unable to revoke access token.') 107 'Unable to revoke access token.')
110 108
111 def _SelectDevice(self): 109 def _SelectDevice(self):
112 """Select which device to use.""" 110 """Select which device to use."""
113 dev_list_res = appurify.api.devices_list(self._access_token) 111 logging.info('Finding %s with %s to run tests on.' %
112 (self._remote_device, self._remote_device_os))
113 dev_list_res = appurify_sanitized.api.devices_list(self._access_token)
114 remote_device_helper.TestHttpResponse(dev_list_res, 114 remote_device_helper.TestHttpResponse(dev_list_res,
115 'Unable to generate access token.') 115 'Unable to generate access token.')
116 device_list = dev_list_res.json()['response'] 116 device_list = dev_list_res.json()['response']
117 for device in device_list: 117 for device in device_list:
118 if (device['name'] == self._remote_device 118 if (device['name'] == self._remote_device
119 and device['os_version'] == self._remote_device_os): 119 and device['os_version'] == self._remote_device_os):
120 return device['device_type_id'] 120 return device['device_type_id']
121 raise remote_device_helper.RemoteDeviceError( 121 raise remote_device_helper.RemoteDeviceError(
122 'No device found: %s %s' % (self._remote_device, 122 'No device found: %s %s' % (self._remote_device,
123 self._remote_device_os)) 123 self._remote_device_os))
(...skipping 18 matching lines...) Expand all
142 def runner_package(self): 142 def runner_package(self):
143 return self._runner_package 143 return self._runner_package
144 144
145 @property 145 @property
146 def trigger(self): 146 def trigger(self):
147 return self._trigger 147 return self._trigger
148 148
149 @property 149 @property
150 def collect(self): 150 def collect(self):
151 return self._collect 151 return self._collect
OLDNEW
« no previous file with comments | « build/android/pylib/remote/device/appurify_sanitized.py ('k') | build/android/pylib/remote/device/remote_device_gtest_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698