1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: module telemetry.core.platform</title> 4<meta charset="utf-8"> 5</head><body bgcolor="#f0f0f8"> 6 7<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> 8<tr bgcolor="#7799ee"> 9<td valign=bottom> <br> 10<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.core.html"><font color="#ffffff">core</font></a>.platform</strong></big></big></font></td 11><td align=right valign=bottom 12><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/core/platform.py">telemetry/core/platform.py</a></font></td></tr></table> 13 <p><tt># Copyright 2012 The Chromium Authors. All rights reserved.<br> 14# Use of this source code is governed by a BSD-style license that can be<br> 15# found in the LICENSE file.</tt></p> 16<p> 17<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 18<tr bgcolor="#aa55cc"> 19<td colspan=3 valign=bottom> <br> 20<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> 21 22<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> 23<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="telemetry.core.discover.html">telemetry.core.discover</a><br> 24<a href="telemetry.core.local_server.html">telemetry.core.local_server</a><br> 25<a href="telemetry.core.memory_cache_http_server.html">telemetry.core.memory_cache_http_server</a><br> 26</td><td width="25%" valign=top><a href="telemetry.core.network_controller.html">telemetry.core.network_controller</a><br> 27<a href="os.html">os</a><br> 28<a href="telemetry.internal.platform.platform_backend.html">telemetry.internal.platform.platform_backend</a><br> 29</td><td width="25%" valign=top><a href="logging.html">logging</a><br> 30<a href="telemetry.core.tracing_controller.html">telemetry.core.tracing_controller</a><br> 31<a href="telemetry.core.util.html">telemetry.core.util</a><br> 32</td><td width="25%" valign=top></td></tr></table></td></tr></table><p> 33<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 34<tr bgcolor="#ee77aa"> 35<td colspan=3 valign=bottom> <br> 36<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 37 38<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 39<td width="100%"><dl> 40<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> 41</font></dt><dd> 42<dl> 43<dt><font face="helvetica, arial"><a href="telemetry.core.platform.html#Platform">Platform</a> 44</font></dt></dl> 45</dd> 46</dl> 47 <p> 48<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 49<tr bgcolor="#ffc8d8"> 50<td colspan=3 valign=bottom> <br> 51<font color="#000000" face="helvetica, arial"><a name="Platform">class <strong>Platform</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 52 53<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> 54<td colspan=2><tt>The platform that the target browser is running on.<br> 55 <br> 56Provides a limited interface to interact with the platform itself, where<br> 57possible. It's important to note that platforms may not provide a specific<br> 58API, so check with IsFooBar() for availability.<br> </tt></td></tr> 59<tr><td> </td> 60<td width="100%">Methods defined here:<br> 61<dl><dt><a name="Platform-CanCaptureVideo"><strong>CanCaptureVideo</strong></a>(self)</dt><dd><tt>Returns a bool indicating whether the platform supports video capture.</tt></dd></dl> 62 63<dl><dt><a name="Platform-CanFlushIndividualFilesFromSystemCache"><strong>CanFlushIndividualFilesFromSystemCache</strong></a>(self)</dt><dd><tt>Returns true if the disk cache can be flushed for specific files.</tt></dd></dl> 64 65<dl><dt><a name="Platform-CanLaunchApplication"><strong>CanLaunchApplication</strong></a>(self, application)</dt><dd><tt>Returns whether the platform can launch the given application.</tt></dd></dl> 66 67<dl><dt><a name="Platform-CanMeasurePerApplicationPower"><strong>CanMeasurePerApplicationPower</strong></a>(self)</dt><dd><tt>Returns True if the power monitor can measure power for the target<br> 68application in isolation. False if power measurement is for full system<br> 69energy consumption.</tt></dd></dl> 70 71<dl><dt><a name="Platform-CanMonitorNetworkData"><strong>CanMonitorNetworkData</strong></a>(self)</dt><dd><tt>Returns true if network data can be retrieved, false otherwise.</tt></dd></dl> 72 73<dl><dt><a name="Platform-CanMonitorPower"><strong>CanMonitorPower</strong></a>(self)</dt><dd><tt>Returns True iff power can be monitored asynchronously via<br> 74<a href="#Platform-StartMonitoringPower">StartMonitoringPower</a>() and <a href="#Platform-StopMonitoringPower">StopMonitoringPower</a>().</tt></dd></dl> 75 76<dl><dt><a name="Platform-CanMonitorThermalThrottling"><strong>CanMonitorThermalThrottling</strong></a>(self)</dt><dd><tt>Platforms may be able to detect thermal throttling.<br> 77 <br> 78Some fan-less computers go into a reduced performance mode when their heat<br> 79exceeds a certain threshold. Performance tests in particular should use this<br> 80API to detect if this has happened and interpret results accordingly.</tt></dd></dl> 81 82<dl><dt><a name="Platform-CanTakeScreenshot"><strong>CanTakeScreenshot</strong></a>(self)</dt></dl> 83 84<dl><dt><a name="Platform-CooperativelyShutdown"><strong>CooperativelyShutdown</strong></a>(self, proc, app_name)</dt><dd><tt>Cooperatively shut down the given process from subprocess.Popen.<br> 85 <br> 86Currently this is only implemented on Windows. See<br> 87crbug.com/424024 for background on why it was added.<br> 88 <br> 89Args:<br> 90 proc: a process <a href="__builtin__.html#object">object</a> returned from subprocess.Popen.<br> 91 app_name: on Windows, is the prefix of the application's window<br> 92 class name that should be searched for. This helps ensure<br> 93 that only the application's windows are closed.<br> 94 <br> 95Returns True if it is believed the attempt succeeded.</tt></dd></dl> 96 97<dl><dt><a name="Platform-FlushDnsCache"><strong>FlushDnsCache</strong></a>(self)</dt><dd><tt>Flushes the OS's DNS cache completely.<br> 98 <br> 99This function may require root or administrator access.</tt></dd></dl> 100 101<dl><dt><a name="Platform-FlushEntireSystemCache"><strong>FlushEntireSystemCache</strong></a>(self)</dt><dd><tt>Flushes the OS's file cache completely.<br> 102 <br> 103This function may require root or administrator access.</tt></dd></dl> 104 105<dl><dt><a name="Platform-FlushSystemCacheForDirectory"><strong>FlushSystemCacheForDirectory</strong></a>(self, directory)</dt><dd><tt>Flushes the OS's file cache for the specified directory.<br> 106 <br> 107This function does not require root or administrator access.</tt></dd></dl> 108 109<dl><dt><a name="Platform-GetArchName"><strong>GetArchName</strong></a>(self)</dt><dd><tt>Returns a string description of the <a href="#Platform">Platform</a> architecture.<br> 110 <br> 111Examples: x86_64 (posix), AMD64 (win), armeabi-v7a, x86</tt></dd></dl> 112 113<dl><dt><a name="Platform-GetDeviceTypeName"><strong>GetDeviceTypeName</strong></a>(self)</dt><dd><tt>Returns a string description of the <a href="#Platform">Platform</a> device, or None.<br> 114 <br> 115Examples: Nexus 7, Nexus 6, Desktop</tt></dd></dl> 116 117<dl><dt><a name="Platform-GetNetworkData"><strong>GetNetworkData</strong></a>(self, browser)</dt><dd><tt>Get current network data.<br> 118Returns:<br> 119 Tuple of (sent_data, received_data) in kb if data can be found,<br> 120 None otherwise.</tt></dd></dl> 121 122<dl><dt><a name="Platform-GetOSName"><strong>GetOSName</strong></a>(self)</dt><dd><tt>Returns a string description of the <a href="#Platform">Platform</a> OS.<br> 123 <br> 124Examples: WIN, MAC, LINUX, CHROMEOS</tt></dd></dl> 125 126<dl><dt><a name="Platform-GetOSVersionName"><strong>GetOSVersionName</strong></a>(self)</dt><dd><tt>Returns a logically sortable, string-like description of the <a href="#Platform">Platform</a> OS<br> 127version.<br> 128 <br> 129Examples: VISTA, WIN7, LION, MOUNTAINLION</tt></dd></dl> 130 131<dl><dt><a name="Platform-GetOSVersionNumber"><strong>GetOSVersionNumber</strong></a>(self)</dt><dd><tt>Returns an integer description of the <a href="#Platform">Platform</a> OS major version.<br> 132 <br> 133Examples: On Mac, 13 for Mavericks, 14 for Yosemite.</tt></dd></dl> 134 135<dl><dt><a name="Platform-HasBeenThermallyThrottled"><strong>HasBeenThermallyThrottled</strong></a>(self)</dt><dd><tt>Returns True if the device has been thermally throttled.</tt></dd></dl> 136 137<dl><dt><a name="Platform-InstallApplication"><strong>InstallApplication</strong></a>(self, application)</dt><dd><tt>Installs the given application.</tt></dd></dl> 138 139<dl><dt><a name="Platform-IsApplicationRunning"><strong>IsApplicationRunning</strong></a>(self, application)</dt><dd><tt>Returns whether an application is currently running.</tt></dd></dl> 140 141<dl><dt><a name="Platform-IsCooperativeShutdownSupported"><strong>IsCooperativeShutdownSupported</strong></a>(self)</dt><dd><tt>Indicates whether CooperativelyShutdown, below, is supported.<br> 142It is not necessary to implement it on all platforms.</tt></dd></dl> 143 144<dl><dt><a name="Platform-IsMonitoringPower"><strong>IsMonitoringPower</strong></a>(self)</dt><dd><tt>Returns true if power is currently being monitored, false otherwise.</tt></dd></dl> 145 146<dl><dt><a name="Platform-IsThermallyThrottled"><strong>IsThermallyThrottled</strong></a>(self)</dt><dd><tt>Returns True if the device is currently thermally throttled.</tt></dd></dl> 147 148<dl><dt><a name="Platform-LaunchApplication"><strong>LaunchApplication</strong></a>(self, application, parameters<font color="#909090">=None</font>, elevate_privilege<font color="#909090">=False</font>)</dt><dd><tt>"Launches the given |application| with a list of |parameters| on the OS.<br> 149 <br> 150Set |elevate_privilege| to launch the application with root or admin rights.<br> 151 <br> 152Returns:<br> 153 A popen style process handle for host platforms.</tt></dd></dl> 154 155<dl><dt><a name="Platform-SetHTTPServerDirectories"><strong>SetHTTPServerDirectories</strong></a>(self, paths)</dt><dd><tt>Returns True if the HTTP server was started, False otherwise.</tt></dd></dl> 156 157<dl><dt><a name="Platform-StartLocalServer"><strong>StartLocalServer</strong></a>(self, server)</dt><dd><tt>Starts a LocalServer and associates it with this platform.<br> 158|server.Close()| should be called manually to close the started server.</tt></dd></dl> 159 160<dl><dt><a name="Platform-StartMonitoringPower"><strong>StartMonitoringPower</strong></a>(self, browser)</dt><dd><tt>Starts monitoring power utilization statistics.<br> 161 <br> 162Args:<br> 163 browser: The browser to monitor.</tt></dd></dl> 164 165<dl><dt><a name="Platform-StartVideoCapture"><strong>StartVideoCapture</strong></a>(self, min_bitrate_mbps)</dt><dd><tt>Starts capturing video.<br> 166 <br> 167Outer framing may be included (from the OS, browser window, and webcam).<br> 168 <br> 169Args:<br> 170 min_bitrate_mbps: The minimum capture bitrate in MegaBits Per Second.<br> 171 The platform is free to deliver a higher bitrate if it can do so<br> 172 without increasing overhead.<br> 173 <br> 174Raises:<br> 175 ValueError if the required |min_bitrate_mbps| can't be achieved.</tt></dd></dl> 176 177<dl><dt><a name="Platform-StopAllLocalServers"><strong>StopAllLocalServers</strong></a>(self)</dt></dl> 178 179<dl><dt><a name="Platform-StopMonitoringPower"><strong>StopMonitoringPower</strong></a>(self)</dt><dd><tt>Stops monitoring power utilization and returns stats<br> 180 <br> 181Returns:<br> 182 None if power measurement failed for some reason, otherwise a dict of<br> 183 power utilization statistics containing: {<br> 184 # An identifier for the data provider. Allows to evaluate the precision<br> 185 # of the data. Example values: monsoon, powermetrics, ds2784<br> 186 'identifier': identifier,<br> 187 <br> 188 # The instantaneous power (voltage * current) reading in milliwatts at<br> 189 # each sample.<br> 190 'power_samples_mw': [mw0, mw1, ..., mwN],<br> 191 <br> 192 # The full system energy consumption during the sampling period in<br> 193 # milliwatt hours. May be estimated by integrating power samples or may<br> 194 # be exact on supported hardware.<br> 195 'energy_consumption_mwh': mwh,<br> 196 <br> 197 # The target application's energy consumption during the sampling period<br> 198 # in milliwatt hours. Should be returned iff<br> 199 # <a href="#Platform-CanMeasurePerApplicationPower">CanMeasurePerApplicationPower</a>() return true.<br> 200 'application_energy_consumption_mwh': mwh,<br> 201 <br> 202 # A platform-specific dictionary of additional details about the<br> 203 # utilization of individual hardware components.<br> 204 component_utilization: {<br> 205 ...<br> 206 }<br> 207 # <a href="#Platform">Platform</a>-specific data not attributed to any particular hardware<br> 208 # component.<br> 209 platform_info: {<br> 210 <br> 211 # Device-specific onboard temperature sensor.<br> 212 'average_temperature_c': c,<br> 213 <br> 214 ...<br> 215 }<br> 216 <br> 217 }</tt></dd></dl> 218 219<dl><dt><a name="Platform-StopVideoCapture"><strong>StopVideoCapture</strong></a>(self)</dt><dd><tt>Stops capturing video.<br> 220 <br> 221Returns:<br> 222 A telemetry.core.video.Video <a href="__builtin__.html#object">object</a>.</tt></dd></dl> 223 224<dl><dt><a name="Platform-TakeScreenshot"><strong>TakeScreenshot</strong></a>(self, file_path)</dt><dd><tt>Takes a screenshot of the platform and save to |file_path|.<br> 225 <br> 226Note that this method may not be supported on all platform, so check with<br> 227CanTakeScreenshot before calling this.<br> 228 <br> 229Args:<br> 230 file_path: Where to save the screenshot to. If the platform is remote,<br> 231 |file_path| is the path on the host platform.<br> 232 <br> 233Returns True if it is believed the attempt succeeded.</tt></dd></dl> 234 235<dl><dt><a name="Platform-__init__"><strong>__init__</strong></a>(self, platform_backend)</dt></dl> 236 237<hr> 238Data descriptors defined here:<br> 239<dl><dt><strong>__dict__</strong></dt> 240<dd><tt>dictionary for instance variables (if defined)</tt></dd> 241</dl> 242<dl><dt><strong>__weakref__</strong></dt> 243<dd><tt>list of weak references to the object (if defined)</tt></dd> 244</dl> 245<dl><dt><strong>http_server</strong></dt> 246</dl> 247<dl><dt><strong>is_host_platform</strong></dt> 248</dl> 249<dl><dt><strong>local_servers</strong></dt> 250<dd><tt>Returns the currently running local servers.</tt></dd> 251</dl> 252<dl><dt><strong>network_controller</strong></dt> 253<dd><tt>Control network settings and servers to simulate the Web.</tt></dd> 254</dl> 255<dl><dt><strong>tracing_controller</strong></dt> 256</dl> 257</td></tr></table></td></tr></table><p> 258<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 259<tr bgcolor="#eeaa77"> 260<td colspan=3 valign=bottom> <br> 261<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> 262 263<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> 264<td width="100%"><dl><dt><a name="-GetHostPlatform"><strong>GetHostPlatform</strong></a>()</dt></dl> 265 <dl><dt><a name="-GetPlatformForDevice"><strong>GetPlatformForDevice</strong></a>(device, finder_options, logging<font color="#909090">=<module 'logging' from '/usr/lib/python2.7/logging/__init__.pyc'></font>)</dt><dd><tt>Returns a platform instance for the device.<br> 266Args:<br> 267 device: a device.Device instance.</tt></dd></dl> 268</td></tr></table> 269</body></html>