Skip to content

Commit

Permalink
Remove 'adb shell ' prefix for ADB commands
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion committed Dec 16, 2020
1 parent b759084 commit 5683538
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions androidtv/basetv/basetv.py
Expand Up @@ -105,6 +105,23 @@ def available(self):
"""
return self._adb.available

@staticmethod
def _remove_adb_shell_prefix(cmd):
"""Remove the 'adb shell ' prefix from ``cmd``, if present.
Parameters
----------
cmd : str
The ADB shell command
Returns
-------
str
``cmd`` with the 'adb shell ' prefix removed, if it was present
"""
return cmd[len("adb shell "):] if cmd.startswith("adb shell ") else cmd

# ======================================================================= #
# #
# Home Assistant device info #
Expand Down
2 changes: 1 addition & 1 deletion androidtv/basetv/basetv_async.py
Expand Up @@ -100,7 +100,7 @@ async def adb_shell(self, cmd):
The response from the device, if there is a response
"""
return await self._adb.shell(cmd)
return await self._adb.shell(self._remove_adb_shell_prefix(cmd))

async def adb_pull(self, local_path, device_path):
"""Pull a file from the device.
Expand Down
2 changes: 1 addition & 1 deletion androidtv/basetv/basetv_sync.py
Expand Up @@ -100,7 +100,7 @@ def adb_shell(self, cmd):
The response from the device, if there is a response
"""
return self._adb.shell(cmd)
return self._adb.shell(self._remove_adb_shell_prefix(cmd))

def adb_pull(self, local_path, device_path):
"""Pull a file from the device.
Expand Down

0 comments on commit 5683538

Please sign in to comment.