Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ python:
- requirements: doc/requirements.txt
- method: pip
path: .
system_packages: true
system_packages: false
64 changes: 42 additions & 22 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
Contributing
============

This project is open to any kind of contribution. You can help with improving the documentation, adding fixes to the
code, providing test cases in code or as a description or just spreading the word. Please feel free to create an
issue or pull request.
In order to reduce the amount of work for everyone please try to adhere to good practice.
:Last Reviewed: 2023-08-10

The pull requests and issues will be prefilled with templates. Please fill in your information where applicable.
This project is open to any kind of contribution.
You can help with improving the documentation, adding fixes to the
code, providing test cases in code or as a description or just
spreading the word.
Please feel free to create an issue or pull request.
In order to reduce the amount of work for everyone please try
to adhere to good practice.

This project uses `semantic versioning <https://semver.org/>`_ and tries to adhere to the proposed rules as
well as possible.
The pull requests and issues will be prefilled with templates.
Please fill in your information where applicable.

This project uses `semantic versioning <https://semver.org/>`_
and tries to adhere to the proposed rules as well as possible.

Author-list
-----------

This project keeps a list of authors. This can be auto-generated by calling `./doc/generate-authors.sh`.
When contributing the first time, please include a commit with the output of this script in place.
This project keeps a list of authors.
This can be auto-generated by calling `./doc/generate-authors.sh`.
When contributing the first time, please include a commit with
the output of this script in place.

When you change your username or mail-address, please also update the `.mailmap` and the authors-list.
When you change your username or mail-address, please also
update the `.mailmap` and the authors-list.
You can find a good documentation on the mapping-feature in the
`documentation of git-shortlog <https://git-scm.com/docs/git-shortlog#_mapping_authors>`_.

Expand All @@ -33,31 +42,42 @@ Please format your contributions with black, otherwise they will be rejected.

GIT
^^^
The master-branch contains the main development of the project. A release to PyPi is marked with a tag
corresponding to the version. Issues are closed when they have been resolved by merging into the master-branch.
When you have a change to make, begin by creating a new branch from the HEAD of `python-escpos/master`.
The master-branch contains the main development of the project.
A release to PyPi is marked with a tag corresponding to the version.
Issues are closed when they have been resolved by merging
into the master-branch.
When you have a change to make, begin by creating a new branch
from the HEAD of `python-escpos/master`.

Please try to group your commits into logical units. If you need to tidy up your branch, you can make use of a
git feature called an 'interactive rebase' before making a pull request. A small, self-contained change-set is
easier to review, and improves the chance of your code being merged.
Please also make sure that before creating your PR, your branch is rebased on a recent commit or you merged a recent
commit into your branch. This way you can ensure that your PR is without merge conflicts.
Please try to group your commits into logical units.
If you need to tidy up your branch, you can make use of a
git feature called an 'interactive rebase' before making a pull request.
A small, self-contained change-set is easier to review, and
improves the chance of your code being merged.
Please also make sure that before creating your PR, your branch
is rebased on a recent commit or you merged a recent
commit into your branch.
This way you can ensure that your PR is without merge conflicts.

Docstrings
^^^^^^^^^^
This project tries to have a good documentation.
Please add a docstring to every method and class. Have a look at existing methods and classes for the style.
Please add a docstring to every method and class.
Have a look at existing methods and classes for the style.
We use basically standard rst-docstrings for Sphinx.

Test
^^^^
Try to write tests whenever possible. Our goal for the future is 100% coverage.
You can copy the structure from other testcases. Please remember to adapt the docstrings.
Try to write tests whenever possible.
Our goal for the future is 100% coverage.
You can copy the structure from other testcases.
Please remember to adapt the docstrings.

Further reading
^^^^^^^^^^^^^^^
For further best practices and hints on contributing please see the
`contribution-guide <https://www.contribution-guide.org/>`_. Should there be any contradictions between this guide
`contribution-guide <https://www.contribution-guide.org/>`_.
Should there be any contradictions between this guide
and the linked one, please stick to this text.
Aside from that feel free to create an issue or write an email if anything is unclear.

Expand Down
2 changes: 2 additions & 0 deletions doc/dev/release-process.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Release process
===============

:Last Reviewed: 2023-08-10

* Update authors file
* Update changelog
* Set annotated tag for release and push to public github
Expand Down
2 changes: 2 additions & 0 deletions doc/dev/todo.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TODO
====

:Last Reviewed: 2023-08-10

Open points and issues of the project are tracked in the GitHub issues.
Some annotations still remain in the code and should be moved over time
into the issue tracker.
Expand Down
7 changes: 6 additions & 1 deletion doc/printer_profiles/available-encodings.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Available Encodings
-------------------
:Last Reviewed: 2023-07-29
:Last Reviewed: 2023-08-10

If you find any issues with the described encodings,
please open an issue in the
`ESC/POS printer database <https://github.com/receipt-print-hq/escpos-printer-db>`_.
The data shown here is directly taken from there.

.. datatemplate:json:: ../../capabilities-data/dist/capabilities.json
:template: capabilities-template-encoding.jinja
3 changes: 2 additions & 1 deletion doc/printer_profiles/available-profiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Available Profiles
------------------
:Last Reviewed: 2023-07-29
:Last Reviewed: 2023-08-10

The following list describes which printer profiles are
available in this release.
Expand All @@ -12,6 +12,7 @@ that this printer actually can be controlled by this library.
If you find any issues with the described capabilities,
please open an issue in the
`ESC/POS printer database <https://github.com/receipt-print-hq/escpos-printer-db>`_.
The data shown here is directly taken from there.

.. datatemplate:json:: ../../capabilities-data/dist/capabilities.json
:template: capabilities-template.jinja
2 changes: 1 addition & 1 deletion doc/printer_profiles/capabilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Capabilities
------------
:Last Reviewed: 2023-07-29
:Last Reviewed: 2023-08-10

Since the used command set often differs between printers,
a model for supporting different printers is implemented.
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ python-barcode>=0.11.0,<1
importlib-metadata
importlib_resources
sphinxcontrib.datatemplates
pycups
29 changes: 20 additions & 9 deletions doc/user/barcode.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
Printing Barcodes
-----------------

:Last Reviewed: 2023-05-16
:Last Reviewed: 2023-08-10

Many printers implement barcode printing natively.
This hardware renderered barcodes are fast but the supported formats are limited by the printer itself and different between models.
However, almost all printers support printing images, so barcode renderization can be performed externally by software and then sent to the printer as an image.
As a drawback, this operation is much slower and the user needs to know and choose the image implementation method supported by the printer's commandset.
This hardware renderered barcodes are fast but the supported
formats are limited by the printer itself and different between models.
However, almost all printers support printing images, so barcode
rendering can be performed externally by software and then sent
to the printer as an image.
As a drawback, this operation is much slower and the user needs
to know and choose the image implementation method supported by
the printer's commandset.

barcode-method
~~~~~~~~~~~~~~
Since version 3.0, the ``barcode`` method unifies the previous ``barcode`` (hardware) and ``soft_barcode`` (software) methods.
It is able to choose automatically the best printer implementation for barcode printing based on the capabilities of the printer and the type of barcode desired.
To achieve this, it relies on the information contained in the escpos-printer-db profiles.
The chosen profile needs to match the capabilities of the printer as closely as possible.
Since version 3.0, the ``barcode`` method unifies the previous
``barcode`` (hardware) and ``soft_barcode`` (software) methods.
It is able to choose automatically the best printer implementation
for barcode printing based on the capabilities of the printer
and the type of barcode desired.
To achieve this, it relies on the information contained in the
escpos-printer-db profiles.
The chosen profile needs to match the capabilities of the printer
as closely as possible.

.. py:currentmodule:: escpos.escpos

Expand All @@ -33,4 +43,5 @@ For alphanumeric CODE128 you have to preface your payload with `{B`.
# print CODE128 012ABCDabcd
p.barcode("{B012ABCDabcd", "CODE128", function_type="B")

A very good description on CODE128 is also on `Wikipedia <https://en.wikipedia.org/wiki/Code_128>`_.
A very good description on CODE128 is also on
`Wikipedia <https://en.wikipedia.org/wiki/Code_128>`_.
19 changes: 13 additions & 6 deletions doc/user/installation.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
.. _user_installation:

Installation
============

:Last Reviewed: 2016-07-23
:Last Reviewed: 2023-08-10

Installation with PIP
---------------------
Installation should be rather straight-forward. python-escpos is on PyPi, so you can simply enter:
Installation should be rather straight-forward. python-escpos is on PyPi,
so you can simply enter:

::

pip install python-escpos

This should install all necessary dependencies. Apart from that python-escpos should also be
available as a Debian package. If you want to always benefit from the newest stable releases you should probably
install from PyPi.
This should install all necessary dependencies. Apart from that
python-escpos is for some versions also available as a Debian package.
If you want to always benefit from the newest stable releases you should
always install from PyPi.
If you use the ``--pre`` parameter for ``pip``, you will get the latest
pre-release.

Setup udev for USB-Printers
---------------------------
1. Get the *Product ID* and *Vendor ID* from the lsusb command
``# lsusb Bus 002 Device 001: ID 1a2b:1a2b Device name``
``# lsusb Bus 002 Device 001: ID 1a2b:1a2b Device name``.
(Or whichever way your system supplies to get the PID and VID.)

2. Create a udev rule to let users belonging to *dialout* group use the
printer. You can create the file
Expand Down
6 changes: 3 additions & 3 deletions doc/user/methods.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Methods
=======

:Last Reviewed: 2017-01-25
:Last Reviewed: 2023-08-10

Escpos class
------------

The core part of this libraries API is the Escpos class.
You use it by instantiating a :doc:`printer <printers>` which is a child of Escpos.
The core part of the API of this library is the Escpos class.
You use it by instantiating a :doc:`printer <printers>` which is a child of Escpos.
The following methods are available:

.. autoclass:: escpos.escpos.Escpos
Expand Down
45 changes: 32 additions & 13 deletions doc/user/printers.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
Printers
========

:Last Reviewed: 2022-11-25
:Last Reviewed: 2023-08-10

As of now there are 7 different type of printer implementations.
As of now there are 8 different types of printer implementations.

USB
---
The USB-class uses pyusb and libusb to communicate with USB-based
printers. Note that this driver is not suited for USB-to-Serial-adapters
and similiar devices, but only for those implementing native USB.
printers.

.. note::
This driver is not suited for USB-to-Serial-adapters
and similiar devices, but only for those implementing native USB.

.. autoclass:: escpos.printer.Usb
:members:
Expand Down Expand Up @@ -44,20 +47,24 @@ This driver is based on the socket class.

Troubleshooting
^^^^^^^^^^^^^^^
Problems with a network-attached printer can have numerous causes. Make sure that your device has a proper IP address.
Often you can check the IP address by triggering the self-test of the device. As a next step try to send text
manually to the device. You could use for example:
Problems with a network-attached printer can have numerous causes.
Make sure that your device has a proper IP address.
Often you can check the IP address by triggering the self-test of the device.
As a next step try to send text manually to the device.
You could use for example:

::

echo "OK\n" | nc IPADDRESS 9100
# the port number is often 9100

As a last resort try to reset the interface of the printer. This should be described in its manual.
As a last resort try to reset the interface of the printer.
This should be described in its manual.

File
----
This printer "prints" just into a file-handle. Especially on \*nix-systems this comes very handy.
This printer "prints" just into a file-handle.
Especially on \*nix-systems this comes very handy.

.. autoclass:: escpos.printer.File
:members:
Expand All @@ -67,8 +74,8 @@ This printer "prints" just into a file-handle. Especially on \*nix-systems this

Dummy
-----
The Dummy-printer is mainly for testing- and debugging-purposes. It stores
all of the "output" as raw ESC/POS in a string and returns that.
The Dummy-printer is mainly for testing- and debugging-purposes.
It stores all of the "output" as raw ESC/POS in a string and returns that.

.. autoclass:: escpos.printer.Dummy
:members:
Expand All @@ -82,7 +89,10 @@ Supports both local and remote CUPS printers and servers.
The printer must be properly configured in CUPS administration.
The connector generates a print job that is added to the CUPS queue.

.. todo:: fix import in documentation
.. autoclass:: escpos.printer.CupsPrinter
:members:
:member-order: bysource
:noindex:

LP
----
Expand All @@ -91,10 +101,19 @@ Supports local and remote CUPS printers.
The printer must be properly configured in CUPS administration.
The connector spawns a new sub-process where the command lp is executed.

No dependencies required, but somehow the print queue will affect some print job such as barcode.
No dependencies required, but somehow the print queue will affect some
print job such as barcode.

.. autoclass:: escpos.printer.LP
:members:
:special-members:
:member-order: bysource
:noindex:

Win32Raw
--------
This driver uses a native WIN32 interface of Windows in order to print.
Please refer to the code for documentation as this driver is currently
not included in the documentation build.

.. todo:: Include Win32Raw in documentation build
Loading