Skip to content

Commit 7805249

Browse files
committed
[datatransfer] made EOF marker default none
Previously it was not really possible to receive a file that had blank lines in it with autoclose enabled.
1 parent 53f77a6 commit 7805249

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1919

2020
### Changed
2121

22-
- `geocompy` dependency minimum version was bumped to `v0.13.0`
23-
- All console output was updated to use the `rich` package instead of `click`
22+
- Bumped `geocompy` dependency minimum version to `v0.13.0`
23+
- Updated all console feedback to use the `rich` package instead of `click`
24+
- Changed `eof` option of `download data` to have no default value
2425

2526
### Fixed
2627

src/instrumentman/datatransfer/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
@option(
3333
"--eof",
3434
help="End-of-file marker (i.e. the last line to receive)",
35-
type=str,
36-
default=""
35+
type=str
3736
)
3837
@option(
3938
"--autoclose/--no-autoclose",

src/instrumentman/datatransfer/app.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ def main_download(
2121
baud: int = 9600,
2222
timeout: int = 2,
2323
output: BufferedWriter | None = None,
24-
eof: str = "",
24+
eof: str | None = None,
2525
autoclose: bool = True,
2626
include_eof: bool = False
2727
) -> None:
28-
eof_bytes = eof.encode("ascii")
28+
eof_bytes: bytes | None = None
29+
if eof is not None:
30+
eof_bytes = eof.encode("ascii")
31+
2932
logger = getLogger("iman.data.download")
3033
with open_serial(
3134
port,
@@ -55,13 +58,18 @@ def main_download(
5558
logger.debug("Received first line")
5659
progress.update(task, description="Receiving data")
5760

58-
if data == eof_bytes and autoclose and not include_eof:
61+
if (
62+
eof_bytes is not None
63+
and data == eof_bytes
64+
and autoclose
65+
and not include_eof
66+
):
5967
logger.info("Download finished (end-of-file)")
68+
print_success("Download reached end-of-file")
6069

6170
progress.update(
6271
task,
63-
total=lines,
64-
description="End-Of-File"
72+
total=lines
6573
)
6674
break
6775

@@ -71,7 +79,11 @@ def main_download(
7179
if output is not None:
7280
output.write(data + eol_bytes)
7381

74-
if data == eof_bytes and autoclose:
82+
if (
83+
eof_bytes is not None
84+
and data == eof_bytes
85+
and autoclose
86+
):
7587
logger.info("Download finished (end-of-file)")
7688
print_success("Download reached end-of-file")
7789

0 commit comments

Comments
 (0)