def run_adb(*args, **kwargs):
cmds = ['adb']
serialno = kwargs.get('serialno', None)
if serialno:
cmds.extend(['-s', serialno])
host = kwargs.get('host')
if host:
cmds.extend(['-H', host])
port = kwargs.get('port')
if port:
cmds.extend(['-P', str(port)])
cmds.extend(args)
cmds = map(str, cmds)
cmdline = subprocess.list2cmdline(cmds)
try:
return check_output(cmdline, shell=True)
except Exception, e:
raise EnvironmentError('run cmd: {} failed. {}'.format(cmdline, e))
评论列表
文章目录