sdev 0.7.4__tar.gz → 0.7.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sdev-0.7.4/sdev.egg-info → sdev-0.7.5}/PKG-INFO +1 -1
- {sdev-0.7.4 → sdev-0.7.5}/pyproject.toml +1 -1
- {sdev-0.7.4 → sdev-0.7.5}/sdev/cli/__init__.py +2 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev/deprecated/demoboard.py +3 -5
- {sdev-0.7.4 → sdev-0.7.5}/sdev/modules/mcp_server.py +1 -4
- {sdev-0.7.4 → sdev-0.7.5}/sdev/modules/serial_notebook.py +7 -9
- {sdev-0.7.4 → sdev-0.7.5/sdev.egg-info}/PKG-INFO +1 -1
- {sdev-0.7.4 → sdev-0.7.5}/setup.py +1 -1
- {sdev-0.7.4 → sdev-0.7.5}/LICENSE +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/MANIFEST.in +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/README.md +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev/__init__.py +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev/cli/__main__.py +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev/modules/__init__.py +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev/modules/serial_rw.py +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev/modules/serial_rw_server.py +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev.egg-info/SOURCES.txt +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev.egg-info/dependency_links.txt +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev.egg-info/entry_points.txt +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev.egg-info/requires.txt +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/sdev.egg-info/top_level.txt +0 -0
- {sdev-0.7.4 → sdev-0.7.5}/setup.cfg +0 -0
|
@@ -350,11 +350,13 @@ def _handle_run(args: argparse.Namespace) -> int:
|
|
|
350
350
|
response_timeout=response_timeout,
|
|
351
351
|
stream=False,
|
|
352
352
|
verbose=False,
|
|
353
|
+
keep_type=True,
|
|
353
354
|
)
|
|
354
355
|
for line in ret:
|
|
355
356
|
if line.kind == 'body' or line.kind == 'error':
|
|
356
357
|
sys.stdout.write(line.text)
|
|
357
358
|
sys.stdout.flush()
|
|
359
|
+
print()
|
|
358
360
|
except KeyboardInterrupt:
|
|
359
361
|
# 捕获本地 Ctrl-C:向开发板发送一次中断信号(Ctrl-C),尽量中断远端前台命令。
|
|
360
362
|
nb.send_interrupt()
|
|
@@ -105,17 +105,15 @@ class Demoboard:
|
|
|
105
105
|
response_timeout = None if wait_forever else timeout
|
|
106
106
|
|
|
107
107
|
def _iter_cmd() -> Generator[str, None, None]:
|
|
108
|
-
|
|
108
|
+
return self._nb.run(
|
|
109
109
|
cmd=cmd,
|
|
110
110
|
end_flag=flag,
|
|
111
111
|
overall_timeout=timeout,
|
|
112
112
|
response_timeout=response_timeout,
|
|
113
113
|
stream=True,
|
|
114
114
|
verbose=True,
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
yield text
|
|
118
|
-
|
|
115
|
+
)
|
|
116
|
+
|
|
119
117
|
if stream:
|
|
120
118
|
return _iter_cmd()
|
|
121
119
|
return list(_iter_cmd())
|
|
@@ -102,10 +102,7 @@ def sdev_run(cmd: str, device_id: str = None, timeout: float = 10.0) -> str:
|
|
|
102
102
|
|
|
103
103
|
with nb:
|
|
104
104
|
lines = nb.run(cmd, overall_timeout=timeout, stream=False, verbose=False)
|
|
105
|
-
|
|
106
|
-
for line in lines:
|
|
107
|
-
output.append(line.text)
|
|
108
|
-
return "".join(output).strip()
|
|
105
|
+
return "".join(lines).strip()
|
|
109
106
|
except Exception as e:
|
|
110
107
|
return f"执行失败:{e}"
|
|
111
108
|
|
|
@@ -3,7 +3,7 @@ import sys
|
|
|
3
3
|
import time
|
|
4
4
|
from loguru import logger
|
|
5
5
|
|
|
6
|
-
from .serial_rw import
|
|
6
|
+
from .serial_rw import SerialLine, CTRL_C
|
|
7
7
|
|
|
8
8
|
GREY = "\033[90m"
|
|
9
9
|
YELLOW = "\033[33m"
|
|
@@ -41,7 +41,7 @@ class SerialNotebook():
|
|
|
41
41
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
42
42
|
self._core.disconnect()
|
|
43
43
|
|
|
44
|
-
def run(self, cmd: str, end_flag=None, allow_fold=True, max_fold_lines=4, strip_echo=True, stream=False, verbose=True, overall_timeout=None, response_timeout=None):
|
|
44
|
+
def run(self, cmd: str, end_flag=None, allow_fold=True, max_fold_lines=4, strip_echo=True, stream=False, verbose=True, overall_timeout=None, response_timeout=None, keep_type=False):
|
|
45
45
|
# 先清理残留输出,避免前一次命令的尾巴影响本次结果。
|
|
46
46
|
assert cmd is not None
|
|
47
47
|
self._core.drain_buffer()
|
|
@@ -79,7 +79,10 @@ class SerialNotebook():
|
|
|
79
79
|
# print(line.kind, line.line, show_log, isinstance(line, SerialLine), line.kind == 'body')
|
|
80
80
|
if show_log and isinstance(line, SerialLine) and line.kind == 'body':
|
|
81
81
|
self._write_raw(f"{GREY}{line.text}{RESET}")
|
|
82
|
-
|
|
82
|
+
if keep_type:
|
|
83
|
+
yield line
|
|
84
|
+
else:
|
|
85
|
+
yield line.text
|
|
83
86
|
# 整个命令结束后,如启用 display,则额外输出一个空行(两个换行),
|
|
84
87
|
# 便于与后续命令在视觉上明显隔离。
|
|
85
88
|
if show_log:
|
|
@@ -157,13 +160,8 @@ class SerialNotebook():
|
|
|
157
160
|
response_timeout=timeout,
|
|
158
161
|
verbose=verbose,
|
|
159
162
|
)
|
|
160
|
-
# lines: [cmd, body, next_prompt]
|
|
161
163
|
if lines and len(lines) >= 2:
|
|
162
|
-
|
|
163
|
-
for line in reversed(lines[:-1]):
|
|
164
|
-
text = line.text.strip()
|
|
165
|
-
if text and not text.startswith("cat /proc"):
|
|
166
|
-
return text
|
|
164
|
+
return lines[-2].strip()
|
|
167
165
|
except Exception:
|
|
168
166
|
pass
|
|
169
167
|
return None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|