Chromium Code Reviews| Index: build/android/pylib/android_commands.py |
| diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py |
| index 7a32eaa4f25de1f16fcc7cc99caac78afe033a9f..0446766910331e93f2fe54db7a982f4978ddece0 100644 |
| --- a/build/android/pylib/android_commands.py |
| +++ b/build/android/pylib/android_commands.py |
| @@ -319,6 +319,23 @@ class AndroidCommands(object): |
| if out.strip() != 'remount succeeded': |
| raise errors.MsgException('Remount failed: %s' % out) |
| + def WaitForSdCardReady(self, timeout_time=20): |
|
bulach
2012/07/12 07:39:10
nit: please, avoid using default params... it's a
Wei James(wistoch)
2012/07/12 08:03:32
fixed. thanks
|
| + """Wait for the SD card ready before pushing data into it""" |
|
bulach
2012/07/12 07:39:10
nit: end this sentence with a period.
Wei James(wistoch)
2012/07/12 08:03:32
fixed. thanks
|
| + logging.info("Waiting for SD card ready...") |
|
bulach
2012/07/12 07:39:10
nit: use single quotes here.
Wei James(wistoch)
2012/07/12 08:03:32
fixed. thanks
|
| + sdcard_ready = False |
| + attempts = 0 |
| + wait_period = 5 |
| + while not sdcard_ready and (attempts*wait_period) < timeout_time: |
|
bulach
2012/07/12 07:39:10
nit: spaces around *, and I think the parenthesis
Wei James(wistoch)
2012/07/12 08:03:32
fixed. thanks
|
| + output = self.RunShellCommand("ls /sdcard/") |
|
bulach
2012/07/12 07:39:10
nit: single quote.
Wei James(wistoch)
2012/07/12 08:03:32
fixed. thanks
|
| + if len(output) > 0: |
|
bulach
2012/07/12 07:39:10
is this condition right? I think ls nonexistingdir
Wei James(wistoch)
2012/07/12 08:03:32
ths /sdcard/ is a symbolic link to /mnt/sdcard and
|
| + sdcard_ready = True |
| + else: |
| + time.sleep(wait_period) |
| + attempts += 1 |
| + if not sdcard_ready: |
| + raise errors.WaitForResponseTimedOutError( |
| + "SD card not ready after %s seconds" %timeout_time) |
| + |
| # It is tempting to turn this function into a generator, however this is not |
| # possible without using a private (local) adb_shell instance (to ensure no |
| # other command interleaves usage of it), which would defeat the main aim of |