2016-09-19 19:04:56 +00:00
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
from _adb import Adb
|
2016-09-19 19:04:56 +00:00
|
|
|
import re
|
|
|
|
import subprocess
|
|
|
|
|
2016-09-22 12:10:02 +00:00
|
|
|
__ADB = None
|
2016-09-19 19:04:56 +00:00
|
|
|
|
2017-10-13 12:15:09 +00:00
|
|
|
def init(device_serial, adb_binary):
|
2016-09-22 12:10:02 +00:00
|
|
|
global __ADB
|
2017-10-13 12:15:09 +00:00
|
|
|
__ADB = Adb(device_serial, adb_binary)
|
2016-09-19 19:04:56 +00:00
|
|
|
|
|
|
|
def join(*pathnames):
|
|
|
|
return '/'.join(pathnames)
|
|
|
|
|
|
|
|
def basename(pathname):
|
|
|
|
return pathname.rsplit('/', maxsplit=1)[-1]
|
|
|
|
|
|
|
|
def find_skps(skps):
|
2018-04-27 23:10:39 +00:00
|
|
|
# root first, in case skps reside in a protected directory
|
|
|
|
__ADB.root()
|
2016-09-22 12:10:02 +00:00
|
|
|
escapedskps = [re.sub(r'([^a-zA-Z0-9_/\.\*\?\[\!\]])', r'\\\1', x)
|
2016-09-19 19:04:56 +00:00
|
|
|
for x in skps]
|
2016-11-09 16:41:23 +00:00
|
|
|
return __ADB.check('''\
|
2016-09-19 19:04:56 +00:00
|
|
|
for PATHNAME in %s; do
|
|
|
|
if [ -d "$PATHNAME" ]; then
|
2019-09-11 18:00:20 +00:00
|
|
|
find "$PATHNAME" -maxdepth 1 -name '*.skp' -o -name '*.mskp'
|
2016-09-19 19:04:56 +00:00
|
|
|
else
|
|
|
|
echo "$PATHNAME"
|
|
|
|
fi
|
2016-11-09 16:41:23 +00:00
|
|
|
done''' % ' '.join(escapedskps)).splitlines()
|