Lines Matching refs:self
29 def __init__(self, serial): argument
30 self.serial = serial
31 super(DeviceNotFoundError, self).__init__(
36 def __init__(self): argument
37 super(NoUniqueDeviceError, self).__init__('No unique device')
41 def __init__(self, cmd, stdout, stderr, exit_code): argument
42 super(ShellError, self).__init__(
44 self.cmd = cmd
45 self.stdout = stdout
46 self.stderr = stderr
47 self.exit_code = exit_code
262 def __init__(self, serial, product=None, adb_path='adb'): argument
263 self.serial = serial
264 self.product = product
265 self.adb_path = adb_path
266 self.adb_cmd = [adb_path]
268 if self.serial is not None:
269 self.adb_cmd.extend(['-s', serial])
270 if self.product is not None:
271 self.adb_cmd.extend(['-p', product])
272 self._linesep = None
273 self._features = None
276 def linesep(self): argument
277 if self._linesep is None:
278 self._linesep = subprocess.check_output(
279 self.adb_cmd + ['shell', 'echo']).decode('utf-8')
280 return self._linesep
283 def features(self): argument
284 if self._features is None:
286 self._features = split_lines(self._simple_call(['features']))
288 self._features = []
289 return self._features
291 def has_shell_protocol(self): argument
292 return version(self.adb_cmd) >= 35 and 'shell_v2' in self.features
294 def _make_shell_cmd(self, user_cmd): argument
295 command = self.adb_cmd + ['shell'] + user_cmd
296 if not self.has_shell_protocol():
297 command += self._RETURN_CODE_PROBE
300 def _parse_shell_output(self, out): argument
315 if len(search_text) > self._RETURN_CODE_SEARCH_LENGTH:
318 search_text = search_text[-self._RETURN_CODE_SEARCH_LENGTH:]
319 partition = search_text.rpartition(self._RETURN_CODE_DELIMITER)
328 def _simple_call(self, cmd): argument
329 logging.info(' '.join(self.adb_cmd + cmd))
331 self.adb_cmd + cmd, stderr=subprocess.STDOUT).decode('utf-8')
333 def shell(self, cmd): argument
346 exit_code, stdout, stderr = self.shell_nocheck(cmd)
351 def shell_nocheck(self, cmd): argument
361 cmd = self._make_shell_cmd(cmd)
368 if self.has_shell_protocol():
371 exit_code, stdout = self._parse_shell_output(stdout)
374 def shell_popen(self, cmd, kill_atexit=True, preexec_fn=None, argument
393 command = self.adb_cmd + ['shell'] + cmd
416 def install(self, filename, replace=False): argument
421 return self._simple_call(cmd)
423 def push(self, local, remote, sync=False): argument
445 return self._simple_call(cmd)
447 def pull(self, remote, local): argument
448 return self._simple_call(['pull', remote, local])
450 def sync(self, directory=None): argument
454 return self._simple_call(cmd)
456 def tcpip(self, port): argument
457 return self._simple_call(['tcpip', port])
459 def usb(self): argument
460 return self._simple_call(['usb'])
462 def reboot(self): argument
463 return self._simple_call(['reboot'])
465 def remount(self): argument
466 return self._simple_call(['remount'])
468 def root(self): argument
469 return self._simple_call(['root'])
471 def unroot(self): argument
472 return self._simple_call(['unroot'])
474 def connect(self, host): argument
475 return self._simple_call(['connect', host])
477 def disconnect(self, host): argument
478 return self._simple_call(['disconnect', host])
480 def forward(self, local, remote): argument
481 return self._simple_call(['forward', local, remote])
483 def forward_list(self): argument
484 return self._simple_call(['forward', '--list'])
486 def forward_no_rebind(self, local, remote): argument
487 return self._simple_call(['forward', '--no-rebind', local, remote])
489 def forward_remove(self, local): argument
490 return self._simple_call(['forward', '--remove', local])
492 def forward_remove_all(self): argument
493 return self._simple_call(['forward', '--remove-all'])
495 def reverse(self, remote, local): argument
496 return self._simple_call(['reverse', remote, local])
498 def reverse_list(self): argument
499 return self._simple_call(['reverse', '--list'])
501 def reverse_no_rebind(self, local, remote): argument
502 return self._simple_call(['reverse', '--no-rebind', local, remote])
504 def reverse_remove_all(self): argument
505 return self._simple_call(['reverse', '--remove-all'])
507 def reverse_remove(self, remote): argument
508 return self._simple_call(['reverse', '--remove', remote])
510 def wait(self): argument
511 return self._simple_call(['wait-for-device'])
513 def get_prop(self, prop_name): argument
514 output = split_lines(self.shell(['getprop', prop_name])[0])
523 def set_prop(self, prop_name, value): argument
524 self.shell(['setprop', prop_name, value])