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

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

Issue 727543003: [Android] Fix new pylint errors in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 unified diff | Download patch
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 self.old_interface = device 85 self.old_interface = device
86 elif not device: 86 elif not device:
87 self.adb = adb_wrapper.AdbWrapper('') 87 self.adb = adb_wrapper.AdbWrapper('')
88 self.old_interface = pylib.android_commands.AndroidCommands() 88 self.old_interface = pylib.android_commands.AndroidCommands()
89 else: 89 else:
90 raise ValueError('Unsupported type passed for argument "device"') 90 raise ValueError('Unsupported type passed for argument "device"')
91 self._commands_installed = None 91 self._commands_installed = None
92 self._default_timeout = default_timeout 92 self._default_timeout = default_timeout
93 self._default_retries = default_retries 93 self._default_retries = default_retries
94 self._cache = {} 94 self._cache = {}
95 assert(hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR)) 95 assert hasattr(self, decorators.DEFAULT_TIMEOUT_ATTR)
96 assert(hasattr(self, decorators.DEFAULT_RETRIES_ATTR)) 96 assert hasattr(self, decorators.DEFAULT_RETRIES_ATTR)
97 97
98 @decorators.WithTimeoutAndRetriesFromInstance() 98 @decorators.WithTimeoutAndRetriesFromInstance()
99 def IsOnline(self, timeout=None, retries=None): 99 def IsOnline(self, timeout=None, retries=None):
100 """Checks whether the device is online. 100 """Checks whether the device is online.
101 101
102 Args: 102 Args:
103 timeout: timeout in seconds 103 timeout: timeout in seconds
104 retries: number of retries 104 retries: number of retries
105 105
106 Returns: 106 Returns:
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 try: 694 try:
695 real_device_path = self.RunShellCommand( 695 real_device_path = self.RunShellCommand(
696 ['realpath', device_path], single_line=True, check_return=True) 696 ['realpath', device_path], single_line=True, check_return=True)
697 except device_errors.CommandFailedError: 697 except device_errors.CommandFailedError:
698 real_device_path = None 698 real_device_path = None
699 if not real_device_path: 699 if not real_device_path:
700 return [(host_path, device_path)] 700 return [(host_path, device_path)]
701 701
702 # TODO(jbudorick): Move the md5 logic up into DeviceUtils or base 702 # TODO(jbudorick): Move the md5 logic up into DeviceUtils or base
703 # this function on mtime. 703 # this function on mtime.
704 # pylint: disable=W0212 704 # pylint: disable=protected-access
705 host_hash_tuples, device_hash_tuples = self.old_interface._RunMd5Sum( 705 host_hash_tuples, device_hash_tuples = self.old_interface._RunMd5Sum(
706 real_host_path, real_device_path) 706 real_host_path, real_device_path)
707 # pylint: enable=W0212 707 # pylint: enable=protected-access
708 708
709 if os.path.isfile(host_path): 709 if os.path.isfile(host_path):
710 if (not device_hash_tuples 710 if (not device_hash_tuples
711 or device_hash_tuples[0].hash != host_hash_tuples[0].hash): 711 or device_hash_tuples[0].hash != host_hash_tuples[0].hash):
712 return [(host_path, device_path)] 712 return [(host_path, device_path)]
713 else: 713 else:
714 return [] 714 return []
715 else: 715 else:
716 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples) 716 device_tuple_dict = dict((d.path, d.hash) for d in device_hash_tuples)
717 to_push = [] 717 to_push = []
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 COMPRESSION_RATIO = 2.0 # unitless 758 COMPRESSION_RATIO = 2.0 # unitless
759 759
760 adb_call_time = ADB_CALL_PENALTY * adb_calls 760 adb_call_time = ADB_CALL_PENALTY * adb_calls
761 adb_push_setup_time = ADB_PUSH_PENALTY * file_count 761 adb_push_setup_time = ADB_PUSH_PENALTY * file_count
762 if is_zipping: 762 if is_zipping:
763 zip_time = ZIP_PENALTY + byte_count / ZIP_RATE 763 zip_time = ZIP_PENALTY + byte_count / ZIP_RATE
764 transfer_time = byte_count / (TRANSFER_RATE * COMPRESSION_RATIO) 764 transfer_time = byte_count / (TRANSFER_RATE * COMPRESSION_RATIO)
765 else: 765 else:
766 zip_time = 0 766 zip_time = 0
767 transfer_time = byte_count / TRANSFER_RATE 767 transfer_time = byte_count / TRANSFER_RATE
768 return (adb_call_time + adb_push_setup_time + zip_time + transfer_time) 768 return adb_call_time + adb_push_setup_time + zip_time + transfer_time
769 769
770 def _PushChangedFilesIndividually(self, files): 770 def _PushChangedFilesIndividually(self, files):
771 for h, d in files: 771 for h, d in files:
772 self.adb.Push(h, d) 772 self.adb.Push(h, d)
773 773
774 def _PushChangedFilesZipped(self, files): 774 def _PushChangedFilesZipped(self, files):
775 if not files: 775 if not files:
776 return 776 return
777 777
778 with tempfile.NamedTemporaryFile(suffix='.zip') as zip_file: 778 with tempfile.NamedTemporaryFile(suffix='.zip') as zip_file:
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 Returns: 1166 Returns:
1167 A Parallelizer operating over |devices|. 1167 A Parallelizer operating over |devices|.
1168 """ 1168 """
1169 if not devices or len(devices) == 0: 1169 if not devices or len(devices) == 0:
1170 devices = pylib.android_commands.GetAttachedDevices() 1170 devices = pylib.android_commands.GetAttachedDevices()
1171 parallelizer_type = (parallelizer.Parallelizer if async 1171 parallelizer_type = (parallelizer.Parallelizer if async
1172 else parallelizer.SyncParallelizer) 1172 else parallelizer.SyncParallelizer)
1173 return parallelizer_type([ 1173 return parallelizer_type([
1174 d if isinstance(d, DeviceUtils) else DeviceUtils(d) 1174 d if isinstance(d, DeviceUtils) else DeviceUtils(d)
1175 for d in devices]) 1175 for d in devices])
OLDNEW
« no previous file with comments | « build/android/pylib/device/decorators_test.py ('k') | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698