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

Side by Side Diff: tools/telemetry/telemetry/core/backends/chrome/cros_interface.py

Issue 297823002: Check for errors of cryptohome-path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/backends/chrome/cros_browser_backend.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """A wrapper around ssh for common operations on a CrOS-based device""" 4 """A wrapper around ssh for common operations on a CrOS-based device"""
5 import logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 import shutil 8 import shutil
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 stdout, stderr = self.RunCmdOnDevice([ 190 stdout, stderr = self.RunCmdOnDevice([
191 'if', 'test', '-e', file_name, ';', 191 'if', 'test', '-e', file_name, ';',
192 'then', 'echo', '1', ';', 192 'then', 'echo', '1', ';',
193 'fi' 193 'fi'
194 ], quiet=True) 194 ], quiet=True)
195 if stderr != '': 195 if stderr != '':
196 if "Connection timed out" in stderr: 196 if "Connection timed out" in stderr:
197 raise OSError('Machine wasn\'t responding to ssh: %s' % 197 raise OSError('Machine wasn\'t responding to ssh: %s' %
198 stderr) 198 stderr)
199 raise OSError('Unepected error: %s' % stderr) 199 raise OSError('Unexpected error: %s' % stderr)
200 exists = stdout == '1\n' 200 exists = stdout == '1\n'
201 logging.debug("FileExistsOnDevice(<text>, %s)->%s" % (file_name, exists)) 201 logging.debug("FileExistsOnDevice(<text>, %s)->%s" % (file_name, exists))
202 return exists 202 return exists
203 203
204 def PushFile(self, filename, remote_filename): 204 def PushFile(self, filename, remote_filename):
205 if self.local: 205 if self.local:
206 args = ['cp', '-r', filename, remote_filename] 206 args = ['cp', '-r', filename, remote_filename]
207 stdout, stderr = GetAllCmdOutput(args, quiet=True) 207 stdout, stderr = GetAllCmdOutput(args, quiet=True)
208 if stderr != '': 208 if stderr != '':
209 raise OSError('No such file or directory %s' % stderr) 209 raise OSError('No such file or directory %s' % stderr)
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 df_ary = df_out.split('\n') 394 df_ary = df_out.split('\n')
395 # 3 lines for title, mount info, and empty line. 395 # 3 lines for title, mount info, and empty line.
396 if len(df_ary) == 3: 396 if len(df_ary) == 3:
397 line_ary = df_ary[1].split() 397 line_ary = df_ary[1].split()
398 if line_ary: 398 if line_ary:
399 return line_ary[0] 399 return line_ary[0]
400 return None 400 return None
401 401
402 def CryptohomePath(self, user): 402 def CryptohomePath(self, user):
403 """Returns the cryptohome mount point for |user|.""" 403 """Returns the cryptohome mount point for |user|."""
404 return self.RunCmdOnDevice( 404 stdout, stderr = self.RunCmdOnDevice(
405 ['cryptohome-path', 'user', "'%s'" % user])[0].strip() 405 ['cryptohome-path', 'user', "'%s'" % user])
406 if stderr != '':
407 raise OSError('cryptohome-path failed: %s' % stderr)
408 return stdout.rstrip()
406 409
407 def IsCryptohomeMounted(self, username, is_guest): 410 def IsCryptohomeMounted(self, username, is_guest):
408 """Returns True iff |user|'s cryptohome is mounted.""" 411 """Returns True iff |user|'s cryptohome is mounted."""
409 profile_path = self.CryptohomePath(username) 412 profile_path = self.CryptohomePath(username)
410 mount = self.FilesystemMountedAt(profile_path) 413 mount = self.FilesystemMountedAt(profile_path)
411 mount_prefix = 'guestfs' if is_guest else '/home/.shadow/' 414 mount_prefix = 'guestfs' if is_guest else '/home/.shadow/'
412 return mount and mount.startswith(mount_prefix) 415 return mount and mount.startswith(mount_prefix)
413 416
414 def TakeScreenShot(self, screenshot_prefix): 417 def TakeScreenShot(self, screenshot_prefix):
415 """Takes a screenshot, useful for debugging failures.""" 418 """Takes a screenshot, useful for debugging failures."""
(...skipping 20 matching lines...) Expand all
436 logging.info('(Re)starting the ui (logs the user out)') 439 logging.info('(Re)starting the ui (logs the user out)')
437 if clear_enterprise_policy: 440 if clear_enterprise_policy:
438 self.RunCmdOnDevice(['stop', 'ui']) 441 self.RunCmdOnDevice(['stop', 'ui'])
439 self.RmRF('/var/lib/whitelist/*') 442 self.RmRF('/var/lib/whitelist/*')
440 self.RmRF('/home/chronos/Local\ State') 443 self.RmRF('/home/chronos/Local\ State')
441 444
442 if self.IsServiceRunning('ui'): 445 if self.IsServiceRunning('ui'):
443 self.RunCmdOnDevice(['restart', 'ui']) 446 self.RunCmdOnDevice(['restart', 'ui'])
444 else: 447 else:
445 self.RunCmdOnDevice(['start', 'ui']) 448 self.RunCmdOnDevice(['start', 'ui'])
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/core/backends/chrome/cros_browser_backend.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698