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

Unified Diff: tools/telemetry/telemetry/core/platform/ios_device.py

Issue 760653002: Telemetry --device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
Index: tools/telemetry/telemetry/core/platform/ios_device.py
diff --git a/tools/telemetry/telemetry/core/platform/ios_device.py b/tools/telemetry/telemetry/core/platform/ios_device.py
new file mode 100644
index 0000000000000000000000000000000000000000..83e7a8ca7e68b2ac4950955bfdf3e836effb2c61
--- /dev/null
+++ b/tools/telemetry/telemetry/core/platform/ios_device.py
@@ -0,0 +1,49 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import re
+import subprocess
+
+from telemetry import decorators
+from telemetry.core import platform
+from telemetry.core.platform import device
+
+
+class IOSDevice(device.Device):
+ def __init__(self):
+ super(IOSDevice, self).__init__(name='ios', guid='')
+
+ @classmethod
+ def GetAllConnectedDevices(cls):
+ return []
+
+ def FindAllAvailableBrowsers(self, options):
+ return []
+
+
+def CanFindAvailableBrowsers():
+ # TODO(baxley): Add support for all platforms possible. Probably Linux,
+ # probably not Windows.
+ return platform.GetHostPlatform().GetOSName() == 'mac'
+
+
+@decorators.Cache
+def IsIosDeviceAttached():
+ devices = subprocess.check_output('system_profiler SPUSBDataType', shell=True)
+ for line in devices.split('\n'):
+ if line and re.match(r'\s*(iPod|iPhone|iPad):', line):
+ return True
+ return False
+
+
+def FindAllAvailableDevices(options):
+ """Returns a list of available devices.
+ """
+ if not CanFindAvailableBrowsers():
+ return []
+
+ if not IsIosDeviceAttached():
+ return []
+
+ return [IOSDevice()]

Powered by Google App Engine
This is Rietveld 408576698