Skip to content

Commit

Permalink
Print names of received files
Browse files Browse the repository at this point in the history
For #21
  • Loading branch information
peterstory committed Jul 19, 2024
1 parent 773aa63 commit 388cf9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/pydiode/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def main():
try:
with tarfile.open(fileobj=sys.stdin.buffer, mode="r|") as tar:
tar.extractall(args.path)
# Print the name of each file extracted
tar.list(verbose=False)
# Don't print the full stack trace for known error types
except tarfile.ReadError as e:
if str(e) == "empty file":
Expand Down
11 changes: 8 additions & 3 deletions tests/test_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ def test_tar_untar(self):
tar_receiver = subprocess.Popen(
[sys.executable, "-m", "pydiode.tar", "extract", dest],
stdin=tar_sender.stdout,
stdout=subprocess.PIPE,
)

# Wait for the subprocesses to finish
tar_receiver.wait(timeout=1)
tar_sender.wait(timeout=1)
tar_sender.stdout.close()
receiver_stdout, _ = tar_receiver.communicate(timeout=1)
_, _ = tar_sender.communicate(timeout=1)

# Ensure the printed filenames match the sent files
self.assertEqual(
list(files.keys()), receiver_stdout.decode("utf-8").split()
)

# Ensure the extracted files match the sent files
for file, data in files.items():
Expand Down

0 comments on commit 388cf9d

Please sign in to comment.