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

Unified Diff: telemetry/telemetry/core/cros_interface.py

Issue 1954573002: Disable screenshots on VMs. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: . Created 4 years, 7 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 | « no previous file | telemetry/telemetry/internal/platform/cros_platform_backend.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/core/cros_interface.py
diff --git a/telemetry/telemetry/core/cros_interface.py b/telemetry/telemetry/core/cros_interface.py
index 94e73167664ef12ff2b7569bc076092a0e80a843..021f8ac939055a293d1299b527cdc643d0937e52 100644
--- a/telemetry/telemetry/core/cros_interface.py
+++ b/telemetry/telemetry/core/cros_interface.py
@@ -326,15 +326,12 @@ class CrOSInterface(object):
Returns:
A string containing the contents of the file.
"""
- # TODO: handle the self.local case
- assert not self.local
- t = tempfile.NamedTemporaryFile()
- self.GetFile(filename, t.name)
- with open(t.name, 'r') as f2:
- res = f2.read()
- logging.debug("GetFileContents(%s)->%s" % (filename, res))
- f2.close()
- return res
+ with tempfile.NamedTemporaryFile() as t:
+ self.GetFile(filename, t.name)
+ with open(t.name, 'r') as f2:
+ res = f2.read()
+ logging.debug("GetFileContents(%s)->%s" % (filename, res))
+ return res
def ListProcesses(self):
"""Returns (pid, cmd, ppid, state) of all processes on the device."""
@@ -503,6 +500,12 @@ class CrOSInterface(object):
def GetArchName(self):
return self.RunCmdOnDevice(['uname', '-m'])[0]
+ def SysVendor(self):
+ return self.GetFileContents('/sys/class/dmi/id/sys_vendor').rstrip()
+
+ def IsRunningOnVM(self):
+ return self.SysVendor() == 'QEMU'
+
def RestartUI(self, clear_enterprise_policy):
logging.info('(Re)starting the ui (logs the user out)')
if clear_enterprise_policy:
« no previous file with comments | « no previous file | telemetry/telemetry/internal/platform/cros_platform_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698