# Waits for an android device to be available
def _wait_for_device(self):
- self.m.python.inline('wait for device', """
+ self.m.run(self.m.python.inline, 'wait for device', program="""
import subprocess
import sys
import time
- times = 0
-
- while times < 30:
- print 'Waiting for the device to be connected and ready.'
- try:
- output = subprocess.check_output(['adb', 'shell',
- 'getprop', 'sys.boot_completed'])
- if '1' in output:
- print 'Connected'
- sys.exit(0)
- except subprocess.CalledProcessError:
- # no device connected/authorized yet
- pass
- time.sleep(5)
+ kicks = 0
+ while kicks < 2:
+
+ times = 0
+
+ while times < 30:
+ print 'Waiting for the device to be connected and ready.'
+ try:
+ times += 1
+ output = subprocess.check_output(['adb', 'shell',
+ 'getprop', 'sys.boot_completed'])
+ if '1' in output:
+ print 'Connected'
+ sys.exit(0)
+ except subprocess.CalledProcessError:
+ # no device connected/authorized yet
+ pass
+ time.sleep(5)
+ print 'Giving the device a "kick" by trying to reboot it.'
+ kicks += 1
+ print subprocess.check_output(['adb', 'reboot'])
print 'Timed out waiting for device'
sys.exit(1)
def cleanup_steps(self):
if self._ever_ran_adb:
- self.m.python.inline('dump log', """
+ self.m.run(self.m.python.inline, 'dump log', program="""
import os
import subprocess
import sys
def copy_directory_contents_to_device(self, host, device):
# Copy the tree, avoiding hidden directories and resolving symlinks.
- self.m.python.inline('push %s/* %s' % (host, device), """
+ self.m.run(self.m.python.inline, 'push %s/* %s' % (host, device),
+ program="""
import os
import subprocess
import sys
"cmd": [
"python",
"-u",
- "\nimport subprocess\nimport sys\nimport time\n\ntimes = 0\n\nwhile times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
+ "\nimport subprocess\nimport sys\nimport time\n\nkicks = 0\nwhile kicks < 2:\n\n times = 0\n\n while times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n times += 1\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n print 'Giving the device a \"kick\" by trying to reboot it.'\n kicks += 1\n print subprocess.check_output(['adb', 'reboot'])\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
],
"name": "wait for device",
"~followup_annotations": [
"@@@STEP_LOG_LINE@python.inline@import sys@@@",
"@@@STEP_LOG_LINE@python.inline@import time@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@kicks = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@while kicks < 2:@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@while times < 30:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
- "@@@STEP_LOG_LINE@python.inline@ try:@@@",
- "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
- "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
- "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
- "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
- "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
- "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
- "@@@STEP_LOG_LINE@python.inline@ pass@@@",
- "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@ while times < 30:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ try:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
+ "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
+ "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
+ "@@@STEP_LOG_LINE@python.inline@ pass@@@",
+ "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Giving the device a \"kick\" by trying to reboot it.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ kicks += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print subprocess.check_output(['adb', 'reboot'])@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@print 'Timed out waiting for device'@@@",
"@@@STEP_LOG_LINE@python.inline@sys.exit(1)@@@",
"cmd": [
"python",
"-u",
- "\nimport subprocess\nimport sys\nimport time\n\ntimes = 0\n\nwhile times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
+ "\nimport subprocess\nimport sys\nimport time\n\nkicks = 0\nwhile kicks < 2:\n\n times = 0\n\n while times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n times += 1\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n print 'Giving the device a \"kick\" by trying to reboot it.'\n kicks += 1\n print subprocess.check_output(['adb', 'reboot'])\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
],
"name": "wait for device",
"~followup_annotations": [
"@@@STEP_LOG_LINE@python.inline@import sys@@@",
"@@@STEP_LOG_LINE@python.inline@import time@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@kicks = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@while kicks < 2:@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@while times < 30:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
- "@@@STEP_LOG_LINE@python.inline@ try:@@@",
- "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
- "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
- "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
- "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
- "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
- "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
- "@@@STEP_LOG_LINE@python.inline@ pass@@@",
- "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@ while times < 30:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ try:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
+ "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
+ "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
+ "@@@STEP_LOG_LINE@python.inline@ pass@@@",
+ "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Giving the device a \"kick\" by trying to reboot it.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ kicks += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print subprocess.check_output(['adb', 'reboot'])@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@print 'Timed out waiting for device'@@@",
"@@@STEP_LOG_LINE@python.inline@sys.exit(1)@@@",
"cmd": [
"python",
"-u",
- "\nimport subprocess\nimport sys\nimport time\n\ntimes = 0\n\nwhile times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
+ "\nimport subprocess\nimport sys\nimport time\n\nkicks = 0\nwhile kicks < 2:\n\n times = 0\n\n while times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n times += 1\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n print 'Giving the device a \"kick\" by trying to reboot it.'\n kicks += 1\n print subprocess.check_output(['adb', 'reboot'])\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
],
"name": "wait for device",
"~followup_annotations": [
"@@@STEP_LOG_LINE@python.inline@import sys@@@",
"@@@STEP_LOG_LINE@python.inline@import time@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@kicks = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@while kicks < 2:@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@while times < 30:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
- "@@@STEP_LOG_LINE@python.inline@ try:@@@",
- "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
- "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
- "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
- "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
- "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
- "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
- "@@@STEP_LOG_LINE@python.inline@ pass@@@",
- "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@ while times < 30:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ try:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
+ "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
+ "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
+ "@@@STEP_LOG_LINE@python.inline@ pass@@@",
+ "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Giving the device a \"kick\" by trying to reboot it.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ kicks += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print subprocess.check_output(['adb', 'reboot'])@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@print 'Timed out waiting for device'@@@",
"@@@STEP_LOG_LINE@python.inline@sys.exit(1)@@@",
"cmd": [
"python",
"-u",
- "\nimport subprocess\nimport sys\nimport time\n\ntimes = 0\n\nwhile times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
+ "\nimport subprocess\nimport sys\nimport time\n\nkicks = 0\nwhile kicks < 2:\n\n times = 0\n\n while times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n times += 1\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n print 'Giving the device a \"kick\" by trying to reboot it.'\n kicks += 1\n print subprocess.check_output(['adb', 'reboot'])\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
],
"name": "wait for device",
"~followup_annotations": [
"@@@STEP_LOG_LINE@python.inline@import sys@@@",
"@@@STEP_LOG_LINE@python.inline@import time@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@kicks = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@while kicks < 2:@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@while times < 30:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
- "@@@STEP_LOG_LINE@python.inline@ try:@@@",
- "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
- "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
- "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
- "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
- "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
- "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
- "@@@STEP_LOG_LINE@python.inline@ pass@@@",
- "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@ while times < 30:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ try:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
+ "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
+ "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
+ "@@@STEP_LOG_LINE@python.inline@ pass@@@",
+ "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Giving the device a \"kick\" by trying to reboot it.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ kicks += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print subprocess.check_output(['adb', 'reboot'])@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@print 'Timed out waiting for device'@@@",
"@@@STEP_LOG_LINE@python.inline@sys.exit(1)@@@",
"cmd": [
"python",
"-u",
- "\nimport subprocess\nimport sys\nimport time\n\ntimes = 0\n\nwhile times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
+ "\nimport subprocess\nimport sys\nimport time\n\nkicks = 0\nwhile kicks < 2:\n\n times = 0\n\n while times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n times += 1\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n print 'Giving the device a \"kick\" by trying to reboot it.'\n kicks += 1\n print subprocess.check_output(['adb', 'reboot'])\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
],
"name": "wait for device",
"~followup_annotations": [
"@@@STEP_LOG_LINE@python.inline@import sys@@@",
"@@@STEP_LOG_LINE@python.inline@import time@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@kicks = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@while kicks < 2:@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@while times < 30:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
- "@@@STEP_LOG_LINE@python.inline@ try:@@@",
- "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
- "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
- "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
- "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
- "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
- "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
- "@@@STEP_LOG_LINE@python.inline@ pass@@@",
- "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@ while times < 30:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ try:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
+ "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
+ "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
+ "@@@STEP_LOG_LINE@python.inline@ pass@@@",
+ "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Giving the device a \"kick\" by trying to reboot it.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ kicks += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print subprocess.check_output(['adb', 'reboot'])@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@print 'Timed out waiting for device'@@@",
"@@@STEP_LOG_LINE@python.inline@sys.exit(1)@@@",
"cmd": [
"python",
"-u",
- "\nimport subprocess\nimport sys\nimport time\n\ntimes = 0\n\nwhile times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
+ "\nimport subprocess\nimport sys\nimport time\n\nkicks = 0\nwhile kicks < 2:\n\n times = 0\n\n while times < 30:\n print 'Waiting for the device to be connected and ready.'\n try:\n times += 1\n output = subprocess.check_output(['adb', 'shell',\n 'getprop', 'sys.boot_completed'])\n if '1' in output:\n print 'Connected'\n sys.exit(0)\n except subprocess.CalledProcessError:\n # no device connected/authorized yet\n pass\n time.sleep(5)\n print 'Giving the device a \"kick\" by trying to reboot it.'\n kicks += 1\n print subprocess.check_output(['adb', 'reboot'])\n\nprint 'Timed out waiting for device'\nsys.exit(1)\n"
],
"name": "wait for device",
"~followup_annotations": [
"@@@STEP_LOG_LINE@python.inline@import sys@@@",
"@@@STEP_LOG_LINE@python.inline@import time@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@kicks = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@while kicks < 2:@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
- "@@@STEP_LOG_LINE@python.inline@while times < 30:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
- "@@@STEP_LOG_LINE@python.inline@ try:@@@",
- "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
- "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
- "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
- "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
- "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
- "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
- "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
- "@@@STEP_LOG_LINE@python.inline@ pass@@@",
- "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times = 0@@@",
+ "@@@STEP_LOG_LINE@python.inline@@@@",
+ "@@@STEP_LOG_LINE@python.inline@ while times < 30:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Waiting for the device to be connected and ready.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ try:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ times += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ output = subprocess.check_output(['adb', 'shell',@@@",
+ "@@@STEP_LOG_LINE@python.inline@ 'getprop', 'sys.boot_completed'])@@@",
+ "@@@STEP_LOG_LINE@python.inline@ if '1' in output:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Connected'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ sys.exit(0)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ except subprocess.CalledProcessError:@@@",
+ "@@@STEP_LOG_LINE@python.inline@ # no device connected/authorized yet@@@",
+ "@@@STEP_LOG_LINE@python.inline@ pass@@@",
+ "@@@STEP_LOG_LINE@python.inline@ time.sleep(5)@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print 'Giving the device a \"kick\" by trying to reboot it.'@@@",
+ "@@@STEP_LOG_LINE@python.inline@ kicks += 1@@@",
+ "@@@STEP_LOG_LINE@python.inline@ print subprocess.check_output(['adb', 'reboot'])@@@",
"@@@STEP_LOG_LINE@python.inline@@@@",
"@@@STEP_LOG_LINE@python.inline@print 'Timed out waiting for device'@@@",
"@@@STEP_LOG_LINE@python.inline@sys.exit(1)@@@",