Skip to content

Commit

Permalink
chore: Snoop on the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgate committed Jul 10, 2024
1 parent f777faf commit 1de571a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
-r doc/requirements.txt \
-r example/requirements.txt \
-r test/requirements.txt
python3 -m pip install snoop
- name: Test install
run: python3 -m pip install .
Expand Down
7 changes: 7 additions & 0 deletions shell_logger/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from types import SimpleNamespace
from typing import IO, List, Optional, TextIO, Tuple

import snoop


END_OF_READ = 4

Expand All @@ -44,6 +46,7 @@ class Shell:
with the shell.
"""

@snoop
def __init__(
self, pwd: Optional[Path] = None, *, login_shell: bool = False
) -> None:
Expand Down Expand Up @@ -145,6 +148,7 @@ def pwd(self) -> str:
directory, _ = self.auxiliary_command(posix="pwd", strip=True)
return directory

@snoop
def cd(self, path: Path) -> None:
"""
Change to the given directory.
Expand Down Expand Up @@ -318,6 +322,7 @@ def write(input_file: TextIO, output_files: List[TextIO]) -> None:
file.close()
return SimpleNamespace(stdout_str=stdout_str, stderr_str=stderr_str)

@snoop
def auxiliary_command(
self, **kwargs
) -> Tuple[Optional[str], Optional[str]]:
Expand Down Expand Up @@ -351,6 +356,8 @@ def auxiliary_command(
stderr = ""

max_anonymous_pipe_buffer_size = 65536

# This next line is where the hang occurs.
aux = os.read(self.aux_stdout_rfd, max_anonymous_pipe_buffer_size)
while aux[-1] != END_OF_READ:
stdout += aux.decode()
Expand Down
3 changes: 3 additions & 0 deletions shell_logger/shell_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from types import SimpleNamespace
from typing import Iterator, List, Optional, Union

import snoop

from .html_utilities import (
append_html,
child_logger_card,
Expand Down Expand Up @@ -130,6 +132,7 @@ def append(path: Path) -> ShellLogger:
with path.open("r") as jf:
return json.load(jf, cls=ShellLoggerDecoder)

@snoop
def __init__( # noqa: PLR0913
self,
name: str,
Expand Down

0 comments on commit 1de571a

Please sign in to comment.