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

Unified Diff: tools/android/loading/device_setup.py

Issue 1619713002: Upgrade analyze.py and related scripts to new world order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/android/loading/deprecated/process_request_log.py ('k') | tools/android/loading/devtools_monitor.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/loading/device_setup.py
diff --git a/tools/android/loading/device_setup.py b/tools/android/loading/device_setup.py
index 4d5d40b3050a382ea4d5a2b653ce1ff4964956fe..8784024db4ecac1999931f6cc56fb933fc527e04 100644
--- a/tools/android/loading/device_setup.py
+++ b/tools/android/loading/device_setup.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import contextlib
+import logging
import os
import sys
import time
@@ -11,6 +12,7 @@ _SRC_DIR = os.path.abspath(os.path.join(
os.path.dirname(__file__), '..', '..', '..'))
sys.path.append(os.path.join(_SRC_DIR, 'third_party', 'catapult', 'devil'))
+from devil.android import device_utils
from devil.android.sdk import intent
sys.path.append(os.path.join(_SRC_DIR, 'build', 'android'))
@@ -23,6 +25,25 @@ DEVTOOLS_PORT = 9222
DEVTOOLS_HOSTNAME = 'localhost'
DEFAULT_CHROME_PACKAGE = 'chrome'
+
+class DeviceSetupException(Exception):
+ def __init__(self, msg):
+ super(DeviceSetupException, self).__init__(msg)
+ logging.error(msg)
+
+
+def GetFirstDevice():
+ """Returns the first connected device.
+
+ Raises:
+ DeviceSetupException if there is no such device.
+ """
+ devices = device_utils.DeviceUtils.HealthyDevices()
+ if not devices:
+ raise DeviceSetupException('No devices found')
+ return devices[0]
+
+
@contextlib.contextmanager
def FlagReplacer(device, command_line_path, new_flags):
"""Replaces chrome flags in a context, restores them afterwards.
« no previous file with comments | « tools/android/loading/deprecated/process_request_log.py ('k') | tools/android/loading/devtools_monitor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698