Created
July 24, 2014 22:10
-
-
Save alexflint/10d9a11532f17daf0bff to your computer and use it in GitHub Desktop.
Example of parsing arguments and calling into adb from python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import os | |
import argparse | |
import subprocess | |
from pathlib import Path | |
def main(): | |
argument_parser = argparse.ArgumentParser(description="Android unittest runner") | |
argument_parser.add_argument('--gtest_output', type=str) | |
argument_parser.add_argument('--sandbox_path', type=str) | |
argument_parser.add_argument('--resource_path', type=str) | |
argument_parser.add_argument('name', type=str) | |
args = argument_parser.parse_args() | |
try: | |
subprocess.check_call('adb shell mkdir '+args.sandbox_path, shell=True) | |
os.mkdir('/tmp/foo') | |
subprocess.check_call('adb push '+args.sandbox_path, shell=True) | |
except OSError as ex: | |
print 'adb command not found' | |
except subprocess.CalledProcessError as ex: | |
print 'Error was '+ex | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment