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

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 375603003: [Android] Ignore exceptions when provision attempts to write local props. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | « build/android/provision_devices.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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 4
5 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=W0613 9 # pylint: disable=W0613
10 10
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 @decorators.WithTimeoutAndRetriesFromInstance() 313 @decorators.WithTimeoutAndRetriesFromInstance()
314 def KillAll(self, process_name, signum=9, as_root=False, blocking=False, 314 def KillAll(self, process_name, signum=9, as_root=False, blocking=False,
315 timeout=None, retries=None): 315 timeout=None, retries=None):
316 """Kill all processes with the given name on the device. 316 """Kill all processes with the given name on the device.
317 317
318 Args: 318 Args:
319 process_name: A string containing the name of the process to kill. 319 process_name: A string containing the name of the process to kill.
320 signum: An integer containing the signal number to send to kill. Defaults 320 signum: An integer containing the signal number to send to kill. Defaults
321 to 9 (SIGKILL). 321 to 9 (SIGKILL).
322 as_root: A boolean indicating whether the kill should be executed with 322 as_root: A boolean indicating whether the kill should be executed with
323 root priveleges. 323 root privileges.
324 blocking: A boolean indicating whether we should wait until all processes 324 blocking: A boolean indicating whether we should wait until all processes
325 with the given |process_name| are dead. 325 with the given |process_name| are dead.
326 timeout: Same as for |IsOnline|. 326 timeout: Same as for |IsOnline|.
327 retries: Same as for |IsOnline|. 327 retries: Same as for |IsOnline|.
328 Raises: 328 Raises:
329 CommandFailedError if no process was killed. 329 CommandFailedError if no process was killed.
330 """ 330 """
331 pids = self.old_interface.ExtractPid(process_name) 331 pids = self.old_interface.ExtractPid(process_name)
332 if len(pids) == 0: 332 if len(pids) == 0:
333 raise device_errors.CommandFailedError( 333 raise device_errors.CommandFailedError(
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 self.old_interface.PullFileFromDevice(device_path, host_path) 497 self.old_interface.PullFileFromDevice(device_path, host_path)
498 498
499 @decorators.WithTimeoutAndRetriesFromInstance() 499 @decorators.WithTimeoutAndRetriesFromInstance()
500 def ReadFile(self, device_path, as_root=False, timeout=None, retries=None): 500 def ReadFile(self, device_path, as_root=False, timeout=None, retries=None):
501 """Reads the contents of a file from the device. 501 """Reads the contents of a file from the device.
502 502
503 Args: 503 Args:
504 device_path: A string containing the absolute path of the file to read 504 device_path: A string containing the absolute path of the file to read
505 from the device. 505 from the device.
506 as_root: A boolean indicating whether the read should be executed with 506 as_root: A boolean indicating whether the read should be executed with
507 root priveleges. 507 root privileges.
508 timeout: Same as for |IsOnline|. 508 timeout: Same as for |IsOnline|.
509 retries: Same as for |IsOnline|. 509 retries: Same as for |IsOnline|.
510 Returns: 510 Returns:
511 The contents of the file at |device_path| as a list of lines. 511 The contents of the file at |device_path| as a list of lines.
512 Raises: 512 Raises:
513 CommandFailedError if the file can't be read. 513 CommandFailedError if the file can't be read.
514 """ 514 """
515 # TODO(jbudorick) Evaluate whether we actually want to return a list of 515 # TODO(jbudorick) Evaluate whether we actually want to return a list of
516 # lines after the implementation switch. 516 # lines after the implementation switch.
517 if as_root: 517 if as_root:
518 if not self.old_interface.CanAccessProtectedFileContents(): 518 if not self.old_interface.CanAccessProtectedFileContents():
519 raise device_errors.CommandFailedError( 519 raise device_errors.CommandFailedError(
520 'Cannot read from %s with root priveleges.' % device_path) 520 'Cannot read from %s with root privileges.' % device_path)
521 return self.old_interface.GetProtectedFileContents(device_path) 521 return self.old_interface.GetProtectedFileContents(device_path)
522 else: 522 else:
523 return self.old_interface.GetFileContents(device_path) 523 return self.old_interface.GetFileContents(device_path)
524 524
525 @decorators.WithTimeoutAndRetriesFromInstance() 525 @decorators.WithTimeoutAndRetriesFromInstance()
526 def WriteFile(self, device_path, contents, as_root=False, timeout=None, 526 def WriteFile(self, device_path, contents, as_root=False, timeout=None,
527 retries=None): 527 retries=None):
528 """Writes |contents| to a file on the device. 528 """Writes |contents| to a file on the device.
529 529
530 Args: 530 Args:
531 device_path: A string containing the absolute path to the file to write 531 device_path: A string containing the absolute path to the file to write
532 on the device. 532 on the device.
533 contents: A string containing the data to write to the device. 533 contents: A string containing the data to write to the device.
534 as_root: A boolean indicating whether the write should be executed with 534 as_root: A boolean indicating whether the write should be executed with
535 root priveleges. 535 root privileges.
536 timeout: Same as for |IsOnline|. 536 timeout: Same as for |IsOnline|.
537 retries: Same as for |IsOnline|. 537 retries: Same as for |IsOnline|.
538 Raises: 538 Raises:
539 CommandFailedError if the file could not be written on the device. 539 CommandFailedError if the file could not be written on the device.
540 """ 540 """
541 if as_root: 541 if as_root:
542 if not self.old_interface.CanAccessProtectedFileContents(): 542 if not self.old_interface.CanAccessProtectedFileContents():
543 raise device_errors.CommandFailedError( 543 raise device_errors.CommandFailedError(
544 'Cannot write to %s with root priveleges.' % device_path) 544 'Cannot write to %s with root privileges.' % device_path)
545 self.old_interface.SetProtectedFileContents(device_path, contents) 545 self.old_interface.SetProtectedFileContents(device_path, contents)
546 else: 546 else:
547 self.old_interface.SetFileContents(device_path, contents) 547 self.old_interface.SetFileContents(device_path, contents)
548 548
549 def __str__(self): 549 def __str__(self):
550 """Returns the device serial.""" 550 """Returns the device serial."""
551 return self.old_interface.GetDevice() 551 return self.old_interface.GetDevice()
552 552
553 @staticmethod 553 @staticmethod
554 def parallel(devices=None, async=False): 554 def parallel(devices=None, async=False):
(...skipping 12 matching lines...) Expand all
567 A Parallelizer operating over |devices|. 567 A Parallelizer operating over |devices|.
568 """ 568 """
569 if not devices or len(devices) == 0: 569 if not devices or len(devices) == 0:
570 devices = pylib.android_commands.GetAttachedDevices() 570 devices = pylib.android_commands.GetAttachedDevices()
571 parallelizer_type = (parallelizer.Parallelizer if async 571 parallelizer_type = (parallelizer.Parallelizer if async
572 else parallelizer.SyncParallelizer) 572 else parallelizer.SyncParallelizer)
573 return parallelizer_type([ 573 return parallelizer_type([
574 d if isinstance(d, DeviceUtils) else DeviceUtils(d) 574 d if isinstance(d, DeviceUtils) else DeviceUtils(d)
575 for d in devices]) 575 for d in devices])
576 576
OLDNEW
« no previous file with comments | « build/android/provision_devices.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698