Mike Klein | 7d92103 | 2017-01-05 12:20:41 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2016 Google Inc. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file. |
| 7 | |
| 8 | import os |
| 9 | import subprocess |
| 10 | import sys |
| 11 | |
| 12 | host, serial, stamp = sys.argv[1:] |
| 13 | device = '/data/local/tmp/' + os.path.basename(host) |
| 14 | |
Mike Klein | a005acc | 2017-01-12 10:48:19 -0500 | [diff] [blame] | 15 | restrict = [] if serial == 'auto' else ['-s', serial] |
| 16 | |
Mike Klein | 7d92103 | 2017-01-05 12:20:41 -0500 | [diff] [blame] | 17 | # adb push is verbose, so eat its output with check_output(). |
Mike Klein | a005acc | 2017-01-12 10:48:19 -0500 | [diff] [blame] | 18 | subprocess.check_output(['adb'] + restrict + ['push', host, device]) |
| 19 | subprocess.check_call(['adb'] + restrict + ['shell', 'chmod', '+x', device]) |
Mike Klein | 7d92103 | 2017-01-05 12:20:41 -0500 | [diff] [blame] | 20 | |
| 21 | # Touch a file to let GN/Ninja know we succeeded. |
| 22 | with open(stamp, 'w'): |
| 23 | pass |