aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpbench/_adb_path.py
diff options
context:
space:
mode:
authorGravatar csmartdalton <csmartdalton@google.com>2016-09-19 12:04:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-19 12:04:56 -0700
commit0262b5c1a0ab704e42d367b070a09bb83188d983 (patch)
tree1231f8e42dab5433c26cb1d4032b9fc9e9b02788 /tools/skpbench/_adb_path.py
parent613664b1bc645de31253c335c4f17e26ca40378f (diff)
Add adb support to skpbench
Diffstat (limited to 'tools/skpbench/_adb_path.py')
-rw-r--r--tools/skpbench/_adb_path.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/skpbench/_adb_path.py b/tools/skpbench/_adb_path.py
new file mode 100644
index 0000000000..377ba12490
--- /dev/null
+++ b/tools/skpbench/_adb_path.py
@@ -0,0 +1,33 @@
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import _adb
+import re
+import subprocess
+
+__ADB_DEVICE_SERIAL = None
+
+def set_device_serial(device_serial):
+ global __ADB_DEVICE_SERIAL
+ __ADB_DEVICE_SERIAL = device_serial
+
+def join(*pathnames):
+ return '/'.join(pathnames)
+
+def basename(pathname):
+ return pathname.rsplit('/', maxsplit=1)[-1]
+
+def find_skps(skps):
+ escapedskps = [re.sub(r'([^a-zA-Z0-9_\*\?\[\!\]])', r'\\\1', x) # Keep globs.
+ for x in skps]
+ pathnames = _adb.check('''
+ for PATHNAME in %s; do
+ if [ -d "$PATHNAME" ]; then
+ ls "$PATHNAME"/*.skp
+ else
+ echo "$PATHNAME"
+ fi
+ done''' % ' '.join(escapedskps), device_serial=__ADB_DEVICE_SERIAL)
+ return re.split('[\r\n]+', pathnames)