解决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,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user