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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 201443017: Replace GetHostSize with a cross-platform implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle dirs Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 # pylint: disable-all 9 # pylint: disable-all
10 10
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 994
995 # See if the file on the host changed since the last push (if any) and 995 # See if the file on the host changed since the last push (if any) and
996 # return early if it didn't. Note that this shortcut assumes that the tests 996 # return early if it didn't. Note that this shortcut assumes that the tests
997 # on the device don't modify the files. 997 # on the device don't modify the files.
998 if not os.path.isdir(host_path): 998 if not os.path.isdir(host_path):
999 if host_path in self._push_if_needed_cache: 999 if host_path in self._push_if_needed_cache:
1000 host_path_mtime = self._push_if_needed_cache[host_path] 1000 host_path_mtime = self._push_if_needed_cache[host_path]
1001 if host_path_mtime == os.stat(host_path).st_mtime: 1001 if host_path_mtime == os.stat(host_path).st_mtime:
1002 return 1002 return
1003 1003
1004 def GetHostSize(path): 1004 def GetHostSize(path):
craigdh 2014/03/24 23:36:46 This is getting really big for an inline function
1005 return int(cmd_helper.GetCmdOutput(['du', '-sb', path]).split()[0]) 1005 running_size = os.path.getsize(path)
1006 if os.path.isdir(path):
1007 for root, dirs, files in os.walk(path):
1008 running_size += sum([GetHostSize(os.path.join(root, f))
craigdh 2014/03/24 23:36:46 You should just be able to call os.path.getsize on
1009 for f in files])
1010 running_size += sum([os.path.getsize(os.path.join(root, d))
1011 for d in dirs])
1012 return running_size
1006 1013
1007 size = GetHostSize(host_path) 1014 size = GetHostSize(host_path)
1008 self._pushed_files.append(device_path) 1015 self._pushed_files.append(device_path)
1009 self._potential_push_size += size 1016 self._potential_push_size += size
1010 1017
1011 changed_files = self.GetFilesChanged(host_path, device_path) 1018 changed_files = self.GetFilesChanged(host_path, device_path)
1012 logging.info('Found %d files that need to be pushed to %s', 1019 logging.info('Found %d files that need to be pushed to %s',
1013 len(changed_files), device_path) 1020 len(changed_files), device_path)
1014 if not changed_files: 1021 if not changed_files:
1015 return 1022 return
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 """ 1850 """
1844 def __init__(self, output): 1851 def __init__(self, output):
1845 self._output = output 1852 self._output = output
1846 1853
1847 def write(self, data): 1854 def write(self, data):
1848 data = data.replace('\r\r\n', '\n') 1855 data = data.replace('\r\r\n', '\n')
1849 self._output.write(data) 1856 self._output.write(data)
1850 1857
1851 def flush(self): 1858 def flush(self):
1852 self._output.flush() 1859 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698