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

Unified Diff: build/android/pylib/android_commands.py

Issue 197883005: [Telementry][Android] Only copy changed or missing files of profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index c5fa3d436df7ce30de661d2eb350fdd10ae6956c..472a11dbae4734ec41317f3a47acb163905bca65 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -1800,6 +1800,98 @@ class AndroidCommands(object):
logging.error('Still showing a %s dialog for %s' % match.groups())
return package
+ def EfficientDeviceDirectoryCopy(self, source, dest):
+ """ Copy a directory efficiently on the device
+
+ Copy new and changed files the source directory to the destination directory
+ and remove added files. This is in some cases much faster than cp -r.
+
+ Args:
+ source: absolute path of source directory
+ dest: absolute path of destination directory
+ """
+ logging.info("In EfficientDeviceDirectoryCopy %s %s" % (source, dest))
bulach 2014/03/13 17:22:57 nit: s/"/'/ also, s/%/,/ that is, logging.info t
+ script = """
bulach 2014/03/13 17:22:57 would it make sense to have this in a separate fil
aberent 2014/03/13 18:32:45 Done.
+source=$1
+dest=$2
+echo copying $source to $dest
+
+delete_extra() {
+ # Don't delete symbolic links, since doing so deletes the vital lib link.
+ if [ ! -L "$1" ]
+ then
+ if [ ! -e "$source/$1" ]
+ then
+ echo rm -rf "$dest/$1"
+ rm -rf "$dest/$1"
+ elif [ -d "$1" ]
+ then
+ for f in "$1"/*
+ do
+ delete_extra "$f"
+ done
+ fi
+ fi
+}
+
+copy_if_older() {
+ if [ -d "$1" ] && [ -e "$dest/$1" ]
+ then
+ if [ ! -e "$dest/$1" ]
+ then
+ echo cp -a "$1" "$dest/$1"
+ cp -a "$1" "$dest/$1"
+ else
+ for f in "$1"/*
+ do
+ copy_if_older "$f"
bulach 2014/03/13 17:22:57 indent
aberent 2014/03/13 18:32:45 Done.
+ done
+ fi
+ elif [ ! -e "$dest/$1" ] || [ "$1" -ot "$dest/$1" ]
+ then
+ echo cp -a "$1" "$dest/$1"
+ cp -a "$1" "$dest/$1"
+ fi
+}
+
+if [ -e "$dest" ]
+then
+ echo cd "$dest"
+ cd "$dest"
+ for f in ./*
+ do
+ if [ -e "$f" ]
+ then
+ delete_extra "$f"
+ fi
+ done
+else
+ echo mkdir "$dest"
+ mkdir "$dest"
+fi
+echo cd "$source"
+cd "$source"
+for f in ./*
+do
+ if [ -e "$f" ]
+ then
+ copy_if_older "$f"
+ fi
+done
+"""
+ temp_script_file = self._GetDeviceTempFileName(
+ AndroidCommands._TEMP_SCRIPT_FILE_BASE_FMT)
+ self.SetFileContents(temp_script_file, script)
+ self.EnableAdbRoot
+ out = self.RunShellCommand("sh %s %s %s" % (temp_script_file, source, dest),
bulach 2014/03/13 17:22:57 nit: s/"/'/
aberent 2014/03/13 18:32:45 Done.
+ timeout_time=120)
+ if self._device:
+ device_repr = self._device[-4:]
+ else:
+ device_repr = '????'
+ for line in out:
+ logging.info('[%s]> %s', device_repr, line)
bulach 2014/03/13 17:22:57 I think logging is already hooked up to have a dev
aberent 2014/03/13 18:32:45 No, the device is added by RunShellCommand, but th
+
class NewLineNormalizer(object):
"""A file-like object to normalize EOLs to '\n'.

Powered by Google App Engine
This is Rietveld 408576698