Skip to content

Commit 31f5a84

Browse files
authored
Fix: place -s before adb subcommand and improve logging (#50)
* fix "-s" argument placing * set shell=False
1 parent 27652d3 commit 31f5a84

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

android_unpinner/vendor/platform_tools/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@
1616

1717
def adb(cmd: str) -> subprocess.CompletedProcess[str]:
1818
"""Helper function to call adb and capture stdout."""
19-
cmd = f"{adb_binary} {cmd}"
19+
base = f"{adb_binary}"
2020
if device:
21-
cmd += f" -s {device}"
21+
base += f" -s {device}"
2222
logging.debug(f"Using device: {device}")
23+
full_cmd = f"{base} {cmd}"
2324
try:
2425
proc = subprocess.run(
25-
cmd, shell=True, check=True, capture_output=True, text=True
26+
full_cmd, shell=False, check=True, capture_output=True, text=True
2627
)
2728
except subprocess.CalledProcessError as e:
28-
logging.debug(f"cmd='{cmd}'\n" f"{e.stdout=}\n" f"{e.stderr=}")
29+
logging.debug(f"cmd='{full_cmd}'\n" f"{e.stdout=}\n" f"{e.stderr=}")
2930
raise
30-
logging.debug(f"cmd='{cmd}'\n" f"{proc.stdout=}\n" f"{proc.stderr=}")
31+
logging.debug(f"cmd='{full_cmd}'\n" f"{proc.stdout=}\n" f"{proc.stderr=}")
3132
return proc
3233

3334

0 commit comments

Comments
 (0)