Merge lp:~sergiusens/phablet-tools/common_scripts into lp:phablet-tools

Proposed by Sergio Schvezov
Status: Merged
Approved by: Oliver Grawert
Approved revision: 272
Merged at revision: 273
Proposed branch: lp:~sergiusens/phablet-tools/common_scripts
Merge into: lp:phablet-tools
Diff against target: 288 lines (+86/-45)
5 files modified
phablet-network (+29/-26)
phablet-screenshot (+6/-14)
phablet-test-run (+17/-5)
setup.py (+5/-0)
shell-adb-common.sh (+29/-0)
To merge this branch: bzr merge lp:~sergiusens/phablet-tools/common_scripts
Reviewer Review Type Date Requested Status
Oliver Grawert Approve
Andy Doan Pending
Review via email: mp+219520@code.launchpad.net

Commit message

Adding a common script to ref from other scripts and removing ADBOPTS in favor of ANDROID_SERIAL
Fixing minor whitespace issues

To post a comment you must log in.
Revision history for this message
Oliver Grawert (ogra) wrote :

looks good ...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'phablet-network'
--- phablet-network 2014-04-14 20:48:07 +0000
+++ phablet-network 2014-05-14 13:06:51 +0000
@@ -14,6 +14,12 @@
14#14#
15# Copyright (C) 2012 Canonical, Ltd.15# Copyright (C) 2012 Canonical, Ltd.
1616
17if [ -f "$(dirname $0)/shell-adb-common.sh" ]; then
18 . "$(dirname $0)/shell-adb-common.sh"
19else
20 . "/usr/share/phabletutils/shell-adb-common.sh"
21fi
22
17export LC_ALL=C23export LC_ALL=C
1824
19usage() {25usage() {
@@ -24,7 +30,7 @@
2430
25OPTIONS:31OPTIONS:
26 -h Show this message32 -h Show this message
27 -s Specify the serial of the device to install (see adb $ADBOPTS devices)33 -s Specify the serial of the device to install
28 -n Select network file34 -n Select network file
29 -t Timeout for waiting on network connection to become active.35 -t Timeout for waiting on network connection to become active.
30 Default=$WAIT_TIMEOUT36 Default=$WAIT_TIMEOUT
@@ -35,7 +41,6 @@
35EOF41EOF
36}42}
3743
38ADBOPTS=""
39OPTION_NETWORK_FILE=""44OPTION_NETWORK_FILE=""
40SKIP_SETUP=""45SKIP_SETUP=""
41SKIP_WAIT=""46SKIP_WAIT=""
@@ -55,26 +60,26 @@
55 ;;60 ;;
56 -n)61 -n)
57 shift;62 shift;
58 OPTION_NETWORK_FILE=$163 OPTION_NETWORK_FILE=$1
59 shift;64 shift;
60 ;;65 ;;
61 -s)66 -s)
62 shift;67 shift;
63 ADBOPTS="-s $1"68 SERIAL="$1"
64 shift;69 shift;
65 ;;70 ;;
66 -t|--timeout)71 -t|--timeout)
67 shift;72 shift;
68 WAIT_TIMEOUT=$173 WAIT_TIMEOUT=$1
69 shift;74 shift;
70 ;;75 ;;
71 --skip-wait)76 --skip-wait)
72 shift;77 shift;
73 SKIP_WAIT=178 SKIP_WAIT=1
74 ;;79 ;;
75 --skip-setup)80 --skip-setup)
76 shift;81 shift;
77 SKIP_SETUP=182 SKIP_SETUP=1
78 ;;83 ;;
79 --)84 --)
80 shift;85 shift;
@@ -83,6 +88,11 @@
83 esac88 esac
84done89done
8590
91
92# exporting ANDROID_SERIAL to support multiple devices connected
93# seamlessly
94[ -z "$SERIAL" ] || export ANDROID_SERIAL="$SERIAL"
95
86NETWORK_MANAGER=/etc/NetworkManager/system-connections96NETWORK_MANAGER=/etc/NetworkManager/system-connections
8797
88find_active_network() {98find_active_network() {
@@ -125,8 +135,8 @@
125135
126 echo Provisioning network file to device136 echo Provisioning network file to device
127 target_network_file=$NETWORK_MANAGER/active_ws_connection.conf137 target_network_file=$NETWORK_MANAGER/active_ws_connection.conf
128 adb $ADBOPTS push $TMP_FILE $target_network_file138 adb push $TMP_FILE $target_network_file
129 adb $ADBOPTS shell "chmod 600 $target_network_file"139 adb shell "chmod 600 $target_network_file"
130140
131 rm -f $TMP_FILE141 rm -f $TMP_FILE
132142
@@ -142,7 +152,7 @@
142 # the logic below will ensure that DNS resolution part of the152 # the logic below will ensure that DNS resolution part of the
143 # ping worked, which should be enough to prove to us that the153 # ping worked, which should be enough to prove to us that the
144 # network stack is ready154 # network stack is ready
145 if adb $ADBOPTS shell ping -c1 launchpad.net | grep PING ; then155 if adb shell ping -c1 launchpad.net | grep PING ; then
146 exit 0156 exit 0
147 fi157 fi
148 done158 done
@@ -153,14 +163,7 @@
153 fi163 fi
154}164}
155165
156# Quick way to make sure that we fail gracefully if more than one device 166check_devices
157# is connected and no serial is passed
158err="$(adb $ADBOPTS wait-for-device 2>&1)"
159if [ "$err" = "error: more than one device and emulator" ]; then
160 echo "$err"
161 adb devices
162 exit 1
163fi
164167
165[ -n "$SKIP_SETUP" ] || setup_connection168[ -n "$SKIP_SETUP" ] || setup_connection
166[ -n "$SKIP_WAIT" ] || wait_for_network169[ -n "$SKIP_WAIT" ] || wait_for_network
167170
=== modified file 'phablet-screenshot'
--- phablet-screenshot 2014-05-08 12:44:41 +0000
+++ phablet-screenshot 2014-05-14 13:06:51 +0000
@@ -22,6 +22,12 @@
22# Street, Fifth Floor, Boston, MA 02110-1301 USA22# Street, Fifth Floor, Boston, MA 02110-1301 USA
23set -eu23set -eu
2424
25if [ -f "$(dirname $0)/shell-adb-common.sh" ]; then
26 . "$(dirname $0)/shell-adb-common.sh"
27else
28 . "/usr/share/phabletutils/shell-adb-common.sh"
29fi
30
25PICDIR=$(mktemp -d /tmp/$(basename $0).XXXXXX)31PICDIR=$(mktemp -d /tmp/$(basename $0).XXXXXX)
26FBDEV=fb032FBDEV=fb0
27SERIAL=""33SERIAL=""
@@ -78,20 +84,6 @@
78 fi84 fi
79}85}
8086
81check_devices() {
82 # Quick way to make sure that we fail gracefully if more than one device
83 # is connected and no serial is passed
84 set +e
85 adb wait-for-device
86 err=$?
87 set -e
88 if [ $err != 0 ]; then
89 echo "E: more than one device or emulator"
90 adb devices
91 exit 1
92 fi
93}
94
95sf_is_running() {87sf_is_running() {
96 # Return 0 if surface flinger is running then we'll use screencap88 # Return 0 if surface flinger is running then we'll use screencap
97 # instead89 # instead
9890
=== modified file 'phablet-test-run'
--- phablet-test-run 2014-04-01 01:36:31 +0000
+++ phablet-test-run 2014-05-14 13:06:51 +0000
@@ -14,6 +14,12 @@
14#14#
15# Copyright (C) 2012 Canonical, Ltd.15# Copyright (C) 2012 Canonical, Ltd.
1616
17if [ -f "$(dirname $0)/shell-adb-common.sh" ]; then
18 . "$(dirname $0)/shell-adb-common.sh"
19else
20 . "/usr/share/phabletutils/shell-adb-common.sh"
21fi
22
17TESTSUITE=""23TESTSUITE=""
18TESTPACKAGES=""24TESTPACKAGES=""
19LOCALPACKAGES=""25LOCALPACKAGES=""
@@ -24,7 +30,6 @@
2430
25EXECUTE_COMMAND=031EXECUTE_COMMAND=0
26USER=phablet32USER=phablet
27ADBOPTS=""
28NOSHELL=033NOSHELL=0
29RETVAL=034RETVAL=0
30VERBOSE=""35VERBOSE=""
@@ -53,15 +58,15 @@
53}58}
5459
55wait_for_device() {60wait_for_device() {
56 adb $ADBOPTS wait-for-device61 adb wait-for-device
57}62}
5863
59exec_with_adb() {64exec_with_adb() {
60 adb $ADBOPTS shell /usr/bin/env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin "$@"65 adb shell /usr/bin/env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin "$@"
61}66}
6267
63exec_with_adb_user() {68exec_with_adb_user() {
64 adb $ADBOPTS shell sudo -u $USER -i "$@"69 adb shell sudo -u $USER -i "$@"
65}70}
6671
67install_packages() {72install_packages() {
@@ -196,7 +201,7 @@
196 TESTPACKAGES="$TESTPACKAGES $OPTARG"201 TESTPACKAGES="$TESTPACKAGES $OPTARG"
197 ;;202 ;;
198 s)203 s)
199 ADBOPTS="-s $OPTARG"204 SERIAL="$OPTARG"
200 ;;205 ;;
201 x)206 x)
202 EXECUTE_COMMAND=1207 EXECUTE_COMMAND=1
@@ -209,12 +214,19 @@
209214
210shift $((OPTIND - 1))215shift $((OPTIND - 1))
211216
217
218# exporting ANDROID_SERIAL to support multiple devices connected
219# seamlessly
220[ -z "$SERIAL" ] || export ANDROID_SERIAL="$SERIAL"
221
212TESTSUITE=$@222TESTSUITE=$@
213if test -z "$TESTSUITE"; then223if test -z "$TESTSUITE"; then
214 echo To run a test please specify a test suite224 echo To run a test please specify a test suite
215 exit 0225 exit 0
216fi226fi
217227
228check_devices
229
218install_packages230install_packages
219231
220if [ $NOSHELL -eq 1 ]; then232if [ $NOSHELL -eq 1 ]; then
221233
=== modified file 'setup.py'
--- setup.py 2014-04-05 17:01:01 +0000
+++ setup.py 2014-05-14 13:06:51 +0000
@@ -20,6 +20,10 @@
20 'phablet-bootchart',20 'phablet-bootchart',
21 ]21 ]
2222
23DATA_FILES = [
24 ('/usr/share/phabletutils/', ['shell-adb-common.sh', ]),
25 ]
26
23if __name__ == "__main__":27if __name__ == "__main__":
24 setup(28 setup(
25 name='phablet-tools',29 name='phablet-tools',
@@ -30,5 +34,6 @@
30 license='GPLv3',34 license='GPLv3',
31 packages=find_packages(exclude=("tests",)),35 packages=find_packages(exclude=("tests",)),
32 scripts=PYTHON_SCRIPTS + SH_SCRIPTS,36 scripts=PYTHON_SCRIPTS + SH_SCRIPTS,
37 data_files=DATA_FILES,
33 test_suite='tests',38 test_suite='tests',
34 )39 )
3540
=== added file 'shell-adb-common.sh'
--- shell-adb-common.sh 1970-01-01 00:00:00 +0000
+++ shell-adb-common.sh 2014-05-14 13:06:51 +0000
@@ -0,0 +1,29 @@
1#!/bin/sh
2# This program is free software: you can redistribute it and/or modify it
3# under the terms of the the GNU General Public License version 3, as
4# published by the Free Software Foundation.
5#
6# This program is distributed in the hope that it will be useful, but
7# WITHOUT ANY WARRANTY; without even the implied warranties of
8# MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
9# PURPOSE. See the applicable version of the GNU General Public
10# License for more details.
11#.
12# You should have received a copy of the GNU General Public License
13# along with this program. If not, see <http://www.gnu.org/licenses/>.
14#
15# Copyright (C) 2014 Canonical, Ltd.
16
17check_devices() {
18 # Quick way to make sure that we fail gracefully if more than one device
19 # is connected and no serial is passed
20 set +e
21 adb wait-for-device
22 err=$?
23 set -e
24 if [ $err != 0 ]; then
25 echo "E: more than one device or emulator"
26 adb devices
27 exit 1
28 fi
29}

Subscribers

People subscribed via source and target branches