Skip to content

Commit 654ce85

Browse files
authored
Fix running_servers blank line bug (#1007)
* fix bug when running_server list contains blank line * update core commit and changelog
1 parent 0781cf9 commit 654ce85

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change
99

1010
## [Unreleased]
1111

12+
### Fixed
13+
14+
- Bug which caused error in `pretext view` when the `running_servers` file contained a blank line.
15+
1216
## [2.20.0] - 2025-06-20
1317

1418
Includes updates to core through commit: [1ef97c0](https://github.com/PreTeXtBook/pretext/commit/1ef97c03fda832b25d60d78edfbc729ee3a75683)

pretext/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
VERSION = get_version("pretext", Path(__file__).parent.parent)
2020

2121

22-
CORE_COMMIT = "1ef97c03fda832b25d60d78edfbc729ee3a75683"
22+
CORE_COMMIT = "0a2cdabe586a5e4b54cc2cc204e7ae6c48454b70"
2323

2424

2525
def activate() -> None:

pretext/server.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ class RunningServerInfo:
3232

3333
@staticmethod
3434
def from_file_line(line: str) -> RunningServerInfo:
35-
(path_hash, pid, port, binding) = line.split()
35+
try:
36+
(path_hash, pid, port, binding) = line.split()
37+
except ValueError:
38+
# We only call this function when line.strip() is true, so line is not empty
39+
log.debug(f"Invalid line in running servers file: {line}")
40+
raise
3641
return RunningServerInfo(
3742
path_hash=path_hash, pid=int(pid), port=int(port), binding=binding
3843
)
@@ -107,7 +112,11 @@ def get_running_servers() -> t.List[RunningServerInfo]:
107112
if not running_servers_file.is_file():
108113
return []
109114
with open(running_servers_file, "r") as f:
110-
return [RunningServerInfo.from_file_line(line) for line in f.readlines()]
115+
return [
116+
RunningServerInfo.from_file_line(line)
117+
for line in f.readlines()
118+
if line.strip()
119+
]
111120
except IOError as e:
112121
log.error(
113122
f"Unable to open list of running PreTeXt web servers expected at ({running_servers_file})."

0 commit comments

Comments
 (0)