Skip to content

Commit

Permalink
add open_local function(get file-like stream object directly instead …
Browse files Browse the repository at this point in the history
…of tcp forward)
  • Loading branch information
xuqd committed Jul 24, 2020
1 parent 74426a9 commit 2254215
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions adbutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,17 @@ def reverse_list(self, serial: Union[None, str] = None):
continue
yield ReverseItem(*parts[1:])

def open_local(self, serial: str, path, mode='wb'):
c = self._connect()
c.send("host:transport:" + serial)
c.check_okay()
if path.startswith('localabstract:') or path.startswith('localfilesystem:'):
c.send(path)
else:
c.send('localfilesystem:' + path)
c.check_okay()
return c.conn.makefile(mode)

def iter_device(self):
"""
Returns:
Expand Down Expand Up @@ -518,6 +529,9 @@ def reverse(self, remote: str, local: str):
def reverse_list(self):
return self._client.reverse_list(self._serial)

def open_local(self, path, mode='wb'):
return self._client.open_local(self._serial, path, mode)

def push(self, local: str, remote: str):
self.adb_output("push", local, remote)

Expand Down

0 comments on commit 2254215

Please sign in to comment.