Skip to content

Conversation

@belono
Copy link
Contributor

@belono belono commented Oct 5, 2025

Description

This is part 3 of the series to improve and extend the availability of the _read() method.

Part 1: #709

Part 2: #711

Part 3: Add the _read() method to the File() connector:

This fixes #622 by adding an initial implementation of the _read() method to the File() connector that, until now, was lacking this feature and was raising a NotImplementedError exception.

The only way I found for this to work is by the use of the low level os module thanks to its ability to manage file descriptors. No other file access/read method has been successful, at least for me.
This implementation does not include any timeout/cancellation ability in case of the file not being accessible, although this is not currently planned for the near future.

Features:

  • Implement the _read() method on the File() class.
  • Adapt the File() class.
  • Adapt existing File() printer tests.
  • Add a test for _read()

Part 4: #714

Tested with

TM-U210 Parallel port printer
Regular files

@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.35%. Comparing base (11d46fd) to head (4df8913).

Files with missing lines Patch % Lines
src/escpos/printer/file.py 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #712      +/-   ##
==========================================
- Coverage   81.39%   81.35%   -0.04%     
==========================================
  Files          21       21              
  Lines        1693     1706      +13     
  Branches      267      268       +1     
==========================================
+ Hits         1378     1388      +10     
  Misses        235      235              
- Partials       80       83       +3     
Flag Coverage Δ
unittests 81.30% <93.33%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/escpos/printer/file.py 96.42% <93.33%> (-1.25%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is_online() fails with raise NotImplementedError()

1 participant