解决issue154中的model_output有换行的问题以及多行文本输出。解决subprocessing编码问题
This commit is contained in:
@@ -109,7 +109,7 @@ class ADBConnection:
|
||||
if address:
|
||||
cmd.append(address)
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=5)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", timeout=5)
|
||||
|
||||
output = result.stdout + result.stderr
|
||||
return True, output.strip() or "Disconnected"
|
||||
@@ -241,7 +241,7 @@ class ADBConnection:
|
||||
cmd.extend(["-s", device_id])
|
||||
cmd.extend(["tcpip", str(port)])
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", timeout=10)
|
||||
|
||||
output = result.stdout + result.stderr
|
||||
|
||||
@@ -270,7 +270,7 @@ class ADBConnection:
|
||||
cmd.extend(["-s", device_id])
|
||||
cmd.extend(["shell", "ip", "route"])
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=5)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", timeout=5)
|
||||
|
||||
# Parse IP from route output
|
||||
for line in result.stdout.split("\n"):
|
||||
@@ -286,6 +286,7 @@ class ADBConnection:
|
||||
cmd[:-1] + ["shell", "ip", "addr", "show", "wlan0"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=5,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,9 +22,11 @@ def get_current_app(device_id: str | None = None) -> str:
|
||||
adb_prefix = _get_adb_prefix(device_id)
|
||||
|
||||
result = subprocess.run(
|
||||
adb_prefix + ["shell", "dumpsys", "window"], capture_output=True, text=True
|
||||
adb_prefix + ["shell", "dumpsys", "window"], capture_output=True, text=True, encoding="utf-8"
|
||||
)
|
||||
output = result.stdout
|
||||
if not output:
|
||||
raise ValueError("No output from dumpsys window")
|
||||
|
||||
# Parse window focus info
|
||||
for line in output.split("\n"):
|
||||
|
||||
Reference in New Issue
Block a user