1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-09-13 09:09:58 +00:00

72 Commits

Author SHA1 Message Date
Patrick Kanzler
ef34cca463 update changelog 2020-05-12 19:32:22 +02:00
Patrick Kanzler
4680fb16b1 Merge pull request #399 from python-escpos/omit-capabilities-env-on-travis
omit env for capabilities on travis
2020-05-12 19:00:06 +02:00
Patrick Kanzler
544bb4f904 omit env for capabilities on travis 2020-05-12 18:39:38 +02:00
Patrick Kanzler
d330dd80fd Merge pull request #398 from python-escpos/390-add-spellcheck-to-sphinx
add sphinxcontrib-spelling
2020-05-12 18:29:48 +02:00
Patrick Kanzler
570661b3c8 install libenchant1c2a on travis 2020-05-12 18:17:22 +02:00
Patrick Kanzler
aa7f2773eb install spelling on travis 2020-05-12 00:06:07 +02:00
Patrick Kanzler
ff39908674 Merge branch 'master' into 390-add-spellcheck-to-sphinx 2020-05-11 23:45:34 +02:00
Patrick Kanzler
d960eea4a8 Merge pull request #397 from python-escpos/use-pkg-resources-for-capabilities-access
use pkg_resources
2020-05-11 23:44:53 +02:00
Patrick Kanzler
f7962576b4 fix tox config 2020-05-11 23:44:10 +02:00
Patrick Kanzler
f4e214ad17 add spellchecker with first conf, fix some errors 2020-05-11 23:39:56 +02:00
Patrick Kanzler
9e406efc86 add sphinxcontrib-spelling 2020-05-11 23:22:40 +02:00
Patrick Kanzler
b9e3827867 use pkg_resources
This change uses if no path for e capabilities-file is supplied a
temporary file created by pkg_resources, which should be more robust
than directly accessing the file. (This failed sometimes, for example
in zipped distributions or uncommon structures)
2020-05-11 22:54:22 +02:00
Patrick Kanzler
cbe412cfdb fix gitignore for vscode 2020-05-11 01:15:41 +02:00
Patrick Kanzler
42554d836c Merge pull request #395 from MicroJoe/python-barcode
replace viivakoodi with python-barcode, center soft barcodes by default
2020-05-10 18:42:04 +02:00
Romain Porte
8ca682e3ac soft_barcode: add new center=True option 2020-05-10 14:08:50 +02:00
Romain Porte
ab30ef4a8c test_function_softbarcode: use pytest fixture 2020-05-10 14:05:33 +02:00
Romain Porte
725f1254aa examples: software_barcode: fix too long code39 for 5890 printer 2020-05-10 14:04:25 +02:00
Romain Porte
1e313cefc6 test_function_barcode.py: remove unused imports 2020-05-10 14:03:43 +02:00
Romain Porte
b0ea9aec41 barcodes: replace viivakoodi with python-barcode
python-barcode is yet another clone of the PyPI barcode library, but
which is still developped compared to viivakoodi.

Signed-off-by: Romain Porte <microjoe@microjoe.org>
2020-05-10 13:36:16 +02:00
Patrick Kanzler
ab210b5996 Merge pull request #392 from MicroJoe/python3-only
drop Python 2.7 support
2020-05-10 13:10:04 +02:00
Patrick Kanzler
f3e1db8da2 Merge branch 'master' into python3-only 2020-05-10 12:45:03 +02:00
Patrick Kanzler
1e7b43a92d Merge pull request #394 from python-escpos/disable-codecov-status
disable codecov status
2020-05-10 12:44:50 +02:00
Patrick Kanzler
0e41709703 disable codecov status 2020-05-10 12:35:36 +02:00
Romain Porte
cb30d7a881 drop Python 2.7 support
Python 2.7 EOL is arriving on 2020-01-01: https://pythonclock.org/

This will allow us to use Python 3 only libraries, like python-barcode,
which can maintain a reduced, simpler codebase, due to only one version
to support.

Closes #371.

Signed-off-by: Romain Porte <microjoe@microjoe.org>
2020-05-10 10:55:44 +02:00
Patrick Kanzler
142fc4af71 fix readthedocs badge 2020-05-09 03:05:58 +02:00
Patrick Kanzler
8f71372bb0 remove landscape io badge 2020-05-09 03:02:35 +02:00
Patrick Kanzler
6a60b6706e apply black to setup.py 2020-05-09 02:48:24 +02:00
Patrick Kanzler
c14a414924 transition setup.py to setup.cfg 2020-05-09 02:45:34 +02:00
Patrick Kanzler
faa9414da5 move marker down to other requires 2020-05-09 02:15:13 +02:00
Patrick Kanzler
2c4552a528 mark as requiring at least python 3.5 2020-05-09 02:14:23 +02:00
Patrick Kanzler
557991d80b Merge pull request #388 from python-escpos/development
v3.0a7
2020-05-09 01:45:25 +02:00
Patrick Kanzler
fe08fc1469 drop pypy 2020-05-09 01:35:00 +02:00
Patrick Kanzler
6c27222aeb use bionic on travis 2020-05-09 01:30:38 +02:00
Patrick Kanzler
6731057456 checkout submodules on github 2020-05-09 01:25:28 +02:00
Patrick Kanzler
f0b1a89c48 fix syntax 2020-05-09 01:19:32 +02:00
Patrick Kanzler
fd7bd0710e set path to capabilities file 2020-05-09 01:11:38 +02:00
Patrick Kanzler
7ea58625e6 use tox plugin for github 2020-05-09 01:08:16 +02:00
Patrick Kanzler
baffd98a22 use focal on travis 2020-05-09 01:05:35 +02:00
Patrick Kanzler
ecbdd43dff install tox in github ci 2020-05-09 01:03:45 +02:00
Patrick Kanzler
5b6b96d2a0 update changelog 2020-05-09 00:58:54 +02:00
Patrick Kanzler
7aa20a60e3 update capabilities 2020-05-09 00:40:05 +02:00
Patrick Kanzler
95ec6d5c08 update hypothesis 2020-05-09 00:39:41 +02:00
Patrick Kanzler
18c3a5f298 add capabilities to manifest 2020-05-09 00:37:35 +02:00
Patrick Kanzler
4836dcd486 change pytest call in tox 2020-05-09 00:27:58 +02:00
Patrick Kanzler
d9d400da6d ignore vscode settings 2020-05-09 00:07:35 +02:00
Patrick Kanzler
fe2e1a6d28 add tox task for vscode 2020-05-09 00:07:02 +02:00
Patrick Kanzler
c53575a155 update tox config 2020-05-09 00:02:28 +02:00
Patrick Kanzler
cadf448c38 update travis 2020-05-08 23:53:35 +02:00
Patrick Kanzler
7c05404ac4 build docs with python 3 2020-05-08 23:51:06 +02:00
Patrick Kanzler
e1e1ccb3f2 update trove identifiers 2020-05-08 23:50:28 +02:00
Patrick Kanzler
32c56e78ea simplify branching model 2020-05-08 23:48:48 +02:00
Patrick Kanzler
4d106e8659 Create pythonpackage.yml 2020-05-08 23:34:24 +02:00
Patrick Kanzler
ddab5318cf Merge pull request #380 from mofosyne/development
Add to readme Serial usage example
2020-05-08 23:21:59 +02:00
Patrick Kanzler
9b60e2e3ab Merge pull request #381 from Foaly/feature/image-center-doc
Added some documentation and error handling to the image center flag.
2020-05-08 23:21:17 +02:00
Patrick Kanzler
34cd1ebde1 readd authors 2020-05-08 23:19:47 +02:00
Patrick Kanzler
a2db415559 remove authors 2020-05-08 23:19:31 +02:00
Patrick Kanzler
4e19b0ca51 Merge branch 'development' into feature/image-center-doc 2020-05-08 23:15:35 +02:00
Patrick Kanzler
a3660a6366 fix authors file 2020-05-08 23:14:05 +02:00
Patrick Kanzler
9fa551e6e8 Merge branch 'development' into development 2020-05-08 22:44:07 +02:00
Patrick Kanzler
ae0a049efa fix authors file 2020-05-08 22:43:47 +02:00
Patrick Kanzler
117d286371 Merge branch 'development' into development 2020-05-08 22:41:56 +02:00
Patrick Kanzler
a555a651b4 Merge pull request #385 from Bougakov/patch-1
Clarify the positions of vendor_id and product_id
2020-05-08 22:38:48 +02:00
Alexander Bougakov
e350a49cad Clarify the positions of vendor_id and product_id
An existing example uses same value, `0x1a2b`  in both `Vendor id` and `Product id` fields, which can confuse a new user.
2020-03-22 13:36:49 +03:00
Maximilian Wagenbach
f49c1dcb89 Updating AUTHORS. 2020-03-11 15:56:51 +01:00
Maximilian Wagenbach
cc67cb1c1e Added some documentation and error handling to the image center flag. 2020-03-11 15:51:16 +01:00
Brian
2ee3ff7f87 Update README.rst 2020-03-09 23:19:11 +11:00
Brian
ca45d25670 Update README.rst
Added example on serial.
2020-03-09 23:18:36 +11:00
Patrick Kanzler
51d1299285 update installation information
INSTALL has been outdated

fixes #357
2019-08-08 11:00:27 +02:00
Patrick Kanzler
0c0e6b9b4c Merge pull request #349 from hurta2yaisel/development
Adding except NotImplementedError for 'detach_kernel_driver' in order…
2019-06-30 17:29:48 +02:00
Yaisel Hurtado
50437cc9d2 Generating AUTHORS 2019-06-28 10:10:45 -04:00
Yaisel Hurtado
7c7d401f31 Adding except NotImplementedError for 'detach_kernel_driver' in order to avoid the exception NotImplementedError: Operation not supported or unimplemented on this platform. 2019-06-27 19:28:49 -04:00
Patrick Kanzler
fa140c2df5 cleanup todo page 2019-06-19 15:50:19 +02:00
56 changed files with 329 additions and 346 deletions

43
.github/workflows/pythonpackage.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest tox tox-gh-actions
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with tox
run: |
tox
env:
ESCPOS_CAPABILITIES_FILE: /home/runner/work/python-escpos/python-escpos/capabilities-data/dist/capabilities.json

7
.gitignore vendored
View File

@@ -29,3 +29,10 @@ test/test-cli-output/
*.swp
*.swn
*.swo
# vscode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

View File

@@ -1,16 +1,14 @@
language: python
sudo: false
cache: pip
dist: xenial
dist: bionic
git:
depth: 100000
addons:
apt:
packages:
- graphviz
env:
global:
- ESCPOS_CAPABILITIES_FILE=/home/travis/build/python-escpos/python-escpos/capabilities-data/dist/capabilities.json
- libenchant1c2a
matrix:
fast_finish: true
include:
@@ -19,7 +17,7 @@ matrix:
language: shell
before_install:
- choco install python
- pip install tox codecov 'sphinx>=1.5.1'
- pip install tox codecov 'sphinx>=1.5.1' 'sphinxcontrib-spelling>=5'
env:
- TOXENV=py37
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
@@ -29,35 +27,27 @@ matrix:
osx_image: xcode10.2
language: shell
env: TOXENV=py37 ESCPOS_CAPABILITIES_FILE=/Users/travis/build/python-escpos/python-escpos/capabilities-data/dist/capabilities.json
- python: 2.7
env: TOXENV=py27
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: 3.6-dev
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37
- python: 3.7-dev
env: TOXENV=py37
- python: 3.8
env: TOXENV=py38
- python: 3.8-dev
env: TOXENV=py38
- python: nightly
env: TOXENV=py38
- python: pypy
env: TOXENV=pypy
- python: pypy3
env: TOXENV=pypy3
- python: 3.7
- python: 3.8
env: TOXENV=docs
- python: 3.7
- python: 3.8
env: TOXENV=flake8
allow_failures:
- python: 2.7
- python: 3.6-dev
- python: 3.7-dev
- python: 3.8-dev
- python: nightly
@@ -65,7 +55,7 @@ matrix:
- os: windows
- os: osx
before_install:
- pip install tox codecov 'sphinx>=1.5.1'
- pip install tox codecov 'sphinx>=1.5.1' 'sphinxcontrib-spelling>=5'
- ./doc/generate_authors.sh --check
script:
- tox
@@ -86,4 +76,4 @@ deploy:
tags: true
repo: python-escpos/python-escpos
branch: master
condition: $TRAVIS_PYTHON_VERSION = "3.7"
condition: $TRAVIS_PYTHON_VERSION = "3.8"

11
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"restructuredtext.confPath": "${workspaceFolder}/doc",
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/.eggs/**": true,
"**/.hypothesis/**": true,
"**/.tox/**": true,
}
}

16
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,16 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "test with tox",
"type": "shell",
"command": "tox",
"group": {
"kind": "test",
"isDefault": true
}
}
]
}

View File

@@ -1,8 +1,10 @@
Ahmed Tahri
akeonly
Alexander Bougakov
Alex Debiasio
Asuki Kono
belono
Brian
Christoph Heuel
Cody (Quantified Code Bot)
csoft2k
@@ -19,6 +21,7 @@ Kristi
ldos
Lucy Linder
Manuel F Martinez
Maximilian Wagenbach
Michael Billington
Michael Elsdörfer
mrwunderbar666
@@ -36,4 +39,5 @@ Sergio Pulgarin
Stephan Sokolow
Thijs Triemstra
Thomas van den Berg
Yaisel Hurtado
ysuolmai

View File

@@ -1,10 +1,57 @@
*********
Changelog
*********
2020-05-12 - Version 3.0a8 - "Only Slightly Bent"
-------------------------------------------------
This release is the ninth alpha release of the new version 3.0.
Please be aware that the API is subject to change until v3.0 is
released.
This release drops support for Python 2, requiring at least
version 3.5 of Python.
changes
^^^^^^^
- Drop support for Python 2 and mark in setuptools as only supporting 3.5 and upwards
- remove landscape.io badge
- replace viivakoodi with python-barcode which is maintained
- add configuration for Visual Studio Code
- use pkg_resources for the retrieval of the capabilities.json
contributors
^^^^^^^^^^^^
- Romain Porte
- Patrick Kanzler
2020-05-09 - Version 3.0a7 - "No Fixed Abode"
---------------------------------------------
This release is the eight alpha release of the new version 3.0.
Please be aware that the API is subject to change until v3.0
is released.
This release also marks the point at which the project transitioned
to having only a master-branch (and not an additional development branch).
changes
^^^^^^^
- add Exception for NotImplementedError in detach_kernel_driver
- update installation information
- update and improve documentation
- add error handling to image centering flag
- update and fix tox and CI environment, preparing drop of support for Python 2
contributors
^^^^^^^^^^^^
- Alexander Bougakov
- Brian
- Yaisel Hurtado
- Maximilan Wagenbach
- Patrick Kanzler
2019-06-19 - Version 3.0a6 - "Mistake not..."
---------------------------------------------
This release is the seventh alpha release of the new version 3.0.
Please be aware the the API is subject to change until v3.0 is
Please be aware that the API is subject to change until v3.0 is
released.
changes

View File

@@ -27,25 +27,6 @@ Style-Guide
When writing code please try to stick to these rules.
Python 2 and 3
^^^^^^^^^^^^^^
We have rewritten the code in order to maintain compatibility with both Python 2 and Python 3.
In order to ensure that we do not miss any accidental degradation, please add these imports to the top
of every file of code:
.. code-block:: Python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
Furthermore please be aware of the differences between Python 2 and 3. For
example `this guide <https://docs.python.org/3/howto/pyporting.html>`_ is helpful.
Special care has to be taken when dealing with strings and byte-strings. Please note
that the :py:meth:`~escpos.escpos.Escpos._raw`-method only accepts byte-strings.
Often you can achieve compatibility quite easily with a tool from the `six`-package.
PEP8
^^^^
The entire codebase adheres to the rules of PEP8.
@@ -56,12 +37,9 @@ Apart from that the travis-log and the check by Landscape will provide you with
GIT
^^^
The master-branch contains code that has been released to PyPi. A release is marked with a tag
corresponding to the version. Issues are closed when they have been resolved in the development-branch.
When you have a change to make, begin by creating a new branch from the HEAD of `python-escpos/development`.
Name your branch to indicate what you are trying to achieve. Good branch names might
be `improve/text-handling`, `feature/enable-color-printing`.
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

23
INSTALL
View File

@@ -1,23 +1,10 @@
python-escpos
=============
Ensure the library is installed on ${lib_arch}/${python_ver}/site-packages/escpos
This library is available over pypi. So for most of the use-cases it should be sufficient to run
On CLi you must run:
# python setup.py build
# sudo python setup.py install
```
pip install python-escpos --user # add --pre if you want to install pre-releases
```
On Linux, ensure you belongs to the proper group so you can have access to the printer.
This can be done, by adding yourself to 'dialout' group, this might require to re-login
so the changes make effect.
Then, add the following rule to /etc/udev/rules.d/99-escpos.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0202", MODE="0664", GROUP="dialout"
and restar udev rules.
# sudo service udev restart
Enjoy !!!
And please, don't forget to ALWAYS add Epson.cut() at the end of your printing :)
Manuel F Martinez <manpaz@bashlinux.com>
For more information please read the documentation at https://python-escpos.readthedocs.io/en/latest/user/installation.html

View File

@@ -4,6 +4,7 @@ include LICENSE
include INSTALL
include tox.ini
include capabilities-data/dist/capabilities.json
include src/escpos/capabilities.json
recursive-include doc *.bat
recursive-include doc *.ico
recursive-include doc *.py

View File

@@ -6,16 +6,12 @@ python-escpos - Python library to manipulate ESC/POS Printers
:target: https://travis-ci.org/python-escpos/python-escpos
:alt: Continous Integration
.. image:: https://landscape.io/github/python-escpos/python-escpos/master/landscape.svg?style=flat
:target: https://landscape.io/github/python-escpos/python-escpos/master
:alt: Code Health
.. image:: https://codecov.io/github/python-escpos/python-escpos/coverage.svg?branch=master
:target: https://codecov.io/github/python-escpos/python-escpos?branch=master
:alt: Code Coverage
.. image:: https://readthedocs.org/projects/python-escpos/badge/?version=stable
:target: http://python-escpos.readthedocs.io/en/latest/?badge=stable
.. image:: https://readthedocs.org/projects/python-escpos/badge/?version=latest
:target: http://python-escpos.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
@@ -47,7 +43,7 @@ This library makes use of:
* `Pillow <https://github.com/python-pillow/Pillow>`_ for image printing
* `qrcode <https://github.com/lincolnloop/python-qrcode>`_ for the generation of QR-codes
* `pyserial <https://github.com/pyserial/pyserial>`_ for serial printers
* `viivakoodi <https://github.com/kxepal/viivakoodi>`_ for the generation of barcodes
* `python-barcode <https://github.com/WhyNotHugo/python-barcode>`_ for the generation of barcodes
Documentation and Usage
-----------------------
@@ -76,6 +72,25 @@ Another example based on the Network printer class:
kitchen.text("Hello World\n")
kitchen.barcode('1324354657687', 'EAN13', 64, 2, '', '')
kitchen.cut()
Another example based on the Serial printer class:
.. code:: python
from escpos.printer import Serial
""" 9600 Baud, 8N1, Flow Control Enabled """
p = Serial(devfile='/dev/tty.usbserial',
baudrate=9600,
bytesize=8,
parity='N',
stopbits=1,
timeout=1.00,
dsrdtr=True)
p.text("Hello World\n")
p.qr("You can readme from your smartphone")
p.cut()
The full project-documentation is available on `Read the Docs <https://python-escpos.readthedocs.io>`_.

View File

@@ -3,10 +3,9 @@ codecov:
coverage:
status:
project:
default: # status context
target: auto
threshold: "1%"
project: off
patch: off
changes: off
range: "60...100"
comment: off

View File

@@ -19,7 +19,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext spelling
help:
@echo "Please use \`make <target>' where <target> is one of"
@@ -45,6 +45,7 @@ help:
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " spelling to run the spellchecker"
clean:
rm -rf $(BUILDDIR)/*
@@ -175,3 +176,8 @@ pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
spelling:
$(SPHINXBUILD) -b spelling $(ALLSPHINXOPTS) $(BUILDDIR)/spelling
@echo
@echo "Spellchecker finished."

View File

@@ -43,6 +43,7 @@ extensions = [
'sphinx.ext.todo',
'sphinx.ext.graphviz',
'sphinx.ext.inheritance_diagram',
'sphinxcontrib.spelling',
]
# supress warnings for external images
@@ -292,3 +293,9 @@ texinfo_documents = [
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# spellchecker
spelling_ignore_pypi_package_names = True
spelling_ignore_wiki_words = True
spelling_ignore_python_builtins = True
spelling_ignore_importable_modules = True

View File

@@ -3,6 +3,8 @@ Pillow>=2.0
qrcode>=4.0
pyserial
sphinx-rtd-theme
setuptools
setuptools-scm
docutils>=0.12
viivakoodi
sphinxcontrib-spelling>=5
python-barcode>=0.11.0,<1

View File

@@ -0,0 +1,7 @@
Raspbian
ESC
POS
Escpos
Escpos
baudrate
lsusb

View File

@@ -2,38 +2,9 @@
TODO
****
Introduction
------------
python-escpos is the initial idea, from here we can start to build a
robust library to get most of the ESC/POS printers working with this
library.
Eventually, this library must be able to cover almost all the defined
models detailed in the ESC/POS Command Specification Manual.
Details
-------
What things are planned to work on?
Testing
~~~~~~~
* Test on many printers as possible (USB, Serial, Network)
* automate testing
Design
~~~~~~
* Add all those sequences which are not common, but part of the ESC/POS
Command Specifications.
* Port to Python 3
* Windows compatibility (hidapi instead libusb?)
* PDF417 support
* use something similar to the `capabilities` in escpos-php
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.
Todos in the codebase
~~~~~~~~~~~~~~~~~~~~~

View File

@@ -48,14 +48,16 @@ to have and the second yields the "Output Endpoint" address.
By default the "Interface" number is "0" and the "Output Endpoint"
address is "0x01". If you have other values then you can define them on
your instance. So, assuming that we have another printer where in\_ep is
on 0x81 and out\_ep=0x02, then the printer definition should look like:
your instance. So, assuming that we have another printer, CT-S2000,
manufactured by Citizen (with "Vendor ID" of 2730 and "Product ID" of 0fff)
where in\_ep is on 0x81 and out\_ep=0x02, then the printer definition should
look like:
**Generic USB Printer initialization**
::
p = printer.Usb(0x1a2b,0x1a2b,0,0x81,0x02)
p = printer.Usb(0x2730, 0x0fff, 0, 0x81, 0x02)
Network printer
^^^^^^^^^^^^^^^
@@ -82,7 +84,7 @@ to.
::
p = printer.Serial("/dev/tty0")
# on a Windows OS serial devices are typically accessible as COM
p = printer.Serial("COM1")
@@ -161,7 +163,7 @@ The printer section
The ``printer`` configuration section defines a default printer to create.
The only required paramter is ``type``. The value of this has to be one of the
The only required parameter is ``type``. The value of this has to be one of the
printers defined in :doc:`/user/printers`.
The rest of the given parameters will be passed on to the initialization of the printer class.
@@ -192,12 +194,12 @@ An USB-printer could be defined by::
Printing text right
-------------------
Python-escpos is designed to accept unicode. So make sure that you use ``u'strings'`` or import ``unicode_literals``
from ``__future__`` if you are on Python 2. On Python 3 you should be fine.
Python-escpos is designed to accept unicode.
For normal usage you can simply pass your text to the printers ``text()``-function. It will automatically guess
the right codepage and then send the encoded data to the printer. If this feature does not work, please try to
isolate the error and then create an issue on the Github project page.
isolate the error and then create an issue on the GitHub project page.
If you want or need to you can manually set the codepage. For this please use the ``charcode()``-function. You can set
any key-value that is in ``CHARCODE``. If something is wrong, an ``CharCodeError`` will be raised.

View File

@@ -1,7 +1,6 @@
"""Prints code page tables.
"""
from __future__ import print_function
import six
import sys

View File

@@ -6,4 +6,4 @@ p = Usb(0x0416, 0x5011, profile="POS-5890")
# Some software barcodes
p.soft_barcode('code128', 'Hello')
p.soft_barcode('code39', '123456')
p.soft_barcode('code39', '1234')

View File

@@ -13,7 +13,6 @@
# Check out his github: https://github.com/AdamWhitcroft/climacons
from __future__ import print_function
from datetime import datetime
import calendar
import urllib

View File

@@ -3,5 +3,5 @@ formats:
- epub
requirements_file: doc/requirements.txt
python:
version: 2
version: 3
setup_py_install: true

View File

@@ -1,11 +1,71 @@
[metadata]
name = python-escpos
url = https://github.com/python-escpos/python-escpos
description = Python library to manipulate ESC/POS Printers
long_description = file: README.rst
license = MIT
license_file = LICENSE
author = Manuel F Martinez and others
author_email = dev@pkanzler.de
maintainer = Patrick Kanzler
maintainer_email = dev@pkanzler.de
keywords = ESC/POS, thermoprinter, voucher printer, printing, receipt
classifiers =
Development Status :: 4 - Beta
Environment :: Console
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Office/Business :: Financial :: Point-Of-Sale
project_urls =
Bug Tracker = https://github.com/python-escpos/python-escpos/issues
Documentation = https://python-escpos.readthedocs.io/en/latest/
Release Notes = https://github.com/python-escpos/python-escpos/releases
[options]
python_requires = >=3.5
zip_safe = false
include_package_data = true
install_requires =
pyusb>=1.0.0
Pillow>=2.0
qrcode>=4.0
pyserial
python-barcode>=0.9.1,<1
setuptools
six
appdirs
PyYAML
argparse
argcomplete
future
viivakoodi>=0.8
setup_requires = setuptools_scm
tests_require =
jaconv
tox
pytest!=3.2.0,!=3.3.0
pytest-cov
pytest-mock
nose
scripttest
mock
hypothesis>4
flake8
sphinxcontrib-spelling>=5
[nosetests]
verbosity=3
with-doctest=1
[bdist_wheel]
# This flag says that the code is written to work on both Python 2 and Python 3.
universal=1
[flake8]
exclude = .git,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py
max-line-length = 120

View File

@@ -22,90 +22,19 @@ setuptools_scm_template = """\
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
version = '{version}'
"""
setup(
name='python-escpos',
use_scm_version={
'write_to': 'src/escpos/version.py',
'write_to_template': setuptools_scm_template,
"write_to": "src/escpos/version.py",
"write_to_template": setuptools_scm_template,
},
url='https://github.com/python-escpos/python-escpos',
download_url='https://github.com/python-escpos/python-escpos/archive/master.zip',
description='Python library to manipulate ESC/POS Printers',
license='MIT',
long_description=read('README.rst'),
author='Manuel F Martinez and others',
author_email='manpaz@bashlinux.com',
maintainer='Patrick Kanzler',
maintainer_email='dev@pkanzler.de',
keywords=[
'ESC/POS',
'thermoprinter',
'voucher printer',
'printing',
'receipt,',
],
platforms='any',
platforms="any",
package_dir={"": "src"},
packages=find_packages(where="src", exclude=["tests", "tests.*"]),
package_data={'escpos': ['capabilities.json']},
include_package_data=True,
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Office/Business :: Financial :: Point-Of-Sale',
],
install_requires=[
'pyusb>=1.0.0',
'Pillow>=2.0',
'qrcode>=4.0',
'pyserial',
'six',
'appdirs',
'PyYAML',
'argparse',
'argcomplete',
'future',
'viivakoodi>=0.8'
],
setup_requires=[
'setuptools_scm',
],
tests_require=[
'jaconv',
'tox',
'pytest!=3.2.0,!=3.3.0',
'pytest-cov',
'pytest-mock',
'nose',
'scripttest',
'mock',
'hypothesis!=3.56.9,<4',
'flake8'
],
entry_points={
'console_scripts': [
'python-escpos = escpos.cli:main'
]
},
package_data={"escpos": ["capabilities.json"]},
entry_points={"console_scripts": ["python-escpos = escpos.cli:main"]},
)

View File

@@ -2,10 +2,6 @@
"""
python-escpos enables you to manipulate escpos-printers
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
__all__ = ["constants", "escpos", "exceptions", "printer"]

View File

@@ -1,5 +1,6 @@
import re
from os import environ, path
import pkg_resources
import pickle
import logging
import time
@@ -15,9 +16,9 @@ logger = logging.getLogger(__name__)
pickle_dir = environ.get('ESCPOS_CAPABILITIES_PICKLE_DIR', gettempdir())
pickle_path = path.join(pickle_dir, '{v}.capabilities.pickle'.format(v=platform.python_version()))
capabilities_path = environ.get(
'ESCPOS_CAPABILITIES_FILE',
path.join(path.dirname(__file__), 'capabilities.json'))
# get a temporary file from pkg_resources if no file is specified in env
capabilities_path = environ.get('ESCPOS_CAPABILITIES_FILE',
pkg_resources.resource_filename(__name__, 'capabilities.json'))
# Load external printer database
t0 = time.time()
@@ -58,7 +59,7 @@ BARCODE_B = 'barcodeB'
class BaseProfile(object):
"""This respresents a printer profile.
"""This represents a printer profile.
A printer profile knows about the number of columns, supported
features, colors and more.

View File

@@ -3,16 +3,12 @@
""" CLI
This module acts as a command line interface for python-escpos. It mirrors
closely the available ESCPOS commands while adding a couple extra ones for convience.
closely the available ESCPOS commands while adding a couple extra ones for convenience.
It requires you to have a configuration file. See documentation for details.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
try:
@@ -558,7 +554,7 @@ def main():
def demo(printer, **kwargs):
"""
Prints specificed demos. Called when CLI is passed `demo`. This function
Prints demos. Called when CLI is passed `demo`. This function
uses the DEMO_FUNCTIONS dictionary.
:param printer: A printer from escpos.printer

View File

@@ -1,13 +1,9 @@
""" ESC/POS configuration manager.
This module contains the implentations of abstract base class :py:class:`Config`.
This module contains the implementations of abstract base class :py:class:`Config`.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os
import appdirs

View File

@@ -11,10 +11,6 @@ moved to `capabilities` as in `escpos-php by @mike42 <https://github.com/mike42/
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six

View File

@@ -10,10 +10,6 @@ This module contains the abstract base class :py:class:`Escpos`.
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import qrcode
import textwrap
@@ -106,6 +102,9 @@ class Escpos(object):
* `graphics`: prints with the `GS ( L`-command
* `bitImageColumn`: prints with the `ESC *`-command
When trying to center an image make sure you have initialized the printer with a valid profile, that
contains a media width pixel field. Otherwise the centering will have no effect.
:param img_source: PIL image or filename to load: `jpg`, `gif`, `png` or `bmp`
:param high_density_vertical: print in high density in vertical direction *default:* True
:param high_density_horizontal: print in high density in horizontal direction *default:* True
@@ -117,6 +116,10 @@ class Escpos(object):
im = EscposImage(img_source)
try:
if self.profile.profile_data['media']['width']['pixels'] == "Unknown":
print("The media.width.pixel field of the printer profile is not set. " +
"The center flag will have no effect.")
max_width = int(self.profile.profile_data['media']['width']['pixels'])
if im.width > max_width:
@@ -395,7 +398,7 @@ class Escpos(object):
*default*: A
:param check: If this parameter is True, the barcode format will be checked to ensure it meets the bc
requirements as defigned in the esc/pos documentation. See :py:meth:`.check_barcode()`
requirements as definged in the ESC/POS documentation. See :py:meth:`.check_barcode()`
for more information. *default*: True.
:raises: :py:exc:`~escpos.exceptions.BarcodeSizeError`,
@@ -476,7 +479,8 @@ class Escpos(object):
self._raw(NUL)
def soft_barcode(self, barcode_type, data, impl='bitImageColumn',
module_height=5, module_width=0.2, text_distance=1):
module_height=5, module_width=0.2, text_distance=1,
center=True):
image_writer = ImageWriter()
@@ -499,7 +503,7 @@ class Escpos(object):
# Retrieve the Pillow image and print it
image = my_code.writer._image
self.image(image, impl=impl)
self.image(image, impl=impl, center=center)
def text(self, txt):
""" Print alpha-numeric text

View File

@@ -25,11 +25,6 @@ Result/Exit codes:
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
class Error(Exception):
""" Base class for ESC/POS errors """

View File

@@ -8,10 +8,6 @@ This module contains the image format handler :py:class:`EscposImage`.
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import math
from PIL import Image, ImageOps

View File

@@ -4,11 +4,6 @@
I doubt that this currently works correctly.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
try:
import jaconv

View File

@@ -12,10 +12,6 @@ The code is based on the encoding-code in py-xml-escpos by @fvdsn.
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from builtins import bytes
from .constants import CODEPAGE_CHANGE

View File

@@ -8,15 +8,11 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import usb.core
import usb.util
import serial
import socket
import usb.core
import usb.util
from .escpos import Escpos
from .exceptions import USBNotFoundError
@@ -83,6 +79,8 @@ class Usb(Escpos):
if check_driver is None or check_driver:
try:
self.device.detach_kernel_driver(0)
except NotImplementedError:
pass
except usb.core.USBError as e:
if check_driver is not None:
print("Could not detatch kernel driver: {0}".format(str(e)))
@@ -349,6 +347,7 @@ class Dummy(Escpos):
_WIN32PRINT = False
try:
import win32print
_WIN32PRINT = True
except ImportError:
pass

View File

@@ -1,5 +1,5 @@
#!/usr/bin/python
"""verifies that the metaclass abc is properly used by Escpos
"""verifies that the metaclass abc is properly used by ESC/POS
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_
@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from nose.tools import raises
@@ -20,7 +16,7 @@ from abc import ABCMeta
@raises(TypeError)
def test_abstract_base_class_raises():
"""test whether the abstract base class raises an exception for Escpos"""
"""test whether the abstract base class raises an exception for ESC/POS"""
escpos.Escpos() # This call should raise TypeError because of abstractmethod _raw()

View File

@@ -2,10 +2,6 @@
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os
import sys

View File

@@ -1,11 +1,6 @@
#!/usr/bin/python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer
from escpos.constants import BARCODE_TYPE_A, BARCODE_TYPE_B
from escpos.capabilities import Profile, BARCODE_B
from escpos.exceptions import BarcodeTypeError, BarcodeCodeError
import pytest

View File

@@ -1,8 +1,4 @@
#!/usr/bin/python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer
from escpos.exceptions import CashDrawerError

View File

@@ -1,10 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer
import pytest

View File

@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six

View File

@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest

View File

@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer

View File

@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer

View File

@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from nose.tools import raises
import pytest

View File

@@ -8,10 +8,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest
import mock

View File

@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six

View File

@@ -1,16 +1,17 @@
#!/usr/bin/python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer
import pytest
def test_soft_barcode():
"""just execute soft_barcode
"""
instance = printer.Dummy()
@pytest.fixture
def instance():
return printer.Dummy()
def test_soft_barcode_ean8(instance):
instance.soft_barcode("ean8", "1234")
def test_soft_barcode_ean8_nocenter(instance):
instance.soft_barcode("ean8", "1234", center=False)

View File

@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest
import mock

View File

@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer

View File

@@ -8,10 +8,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest
from nose.tools import raises, assert_raises

View File

@@ -8,10 +8,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import six
@@ -28,7 +24,6 @@ else:
@pytest.mark.skip("this test is broken and has to be fixed or discarded")
@settings(use_coverage=False)
@given(path=text())
def test_load_file_printer(mocker, path):
"""test the loading of the file-printer"""
@@ -40,7 +35,6 @@ def test_load_file_printer(mocker, path):
@pytest.mark.skip("this test is broken and has to be fixed or discarded")
@settings(deadline=None, use_coverage=False)
@given(txt=text())
def test_auto_flush(mocker, txt):
"""test auto_flush in file-printer"""
@@ -62,7 +56,6 @@ def test_auto_flush(mocker, txt):
@pytest.mark.skip("this test is broken and has to be fixed or discarded")
@settings(deadline=None, use_coverage=False)
@given(txt=text())
def test_flush_on_close(mocker, txt):
"""test flush on close in file-printer"""

View File

@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import pytest
import escpos

View File

@@ -7,10 +7,6 @@
:license: MIT
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer
import escpos.escpos as escpos

18
tox.ini
View File

@@ -1,5 +1,12 @@
[tox]
envlist = py27, py34, py35, py36, py37, docs, flake8
envlist = py35, py36, py37, py38, docs, flake8
[gh-actions]
python =
2.7: py27
3.6: py36
3.7: py37
3.8: py38
[testenv]
deps = nose
@@ -10,9 +17,9 @@ deps = nose
pytest!=3.2.0,!=3.3.0
pytest-cov
pytest-mock
hypothesis!=3.56.9,<4
viivakoodi
commands = py.test --cov escpos
hypothesis>4
python-barcode
commands = pytest --cov escpos
passenv = ESCPOS_CAPABILITIES_PICKLE_DIR ESCPOS_CAPABILITIES_FILE CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_*
[testenv:docs]
@@ -20,7 +27,8 @@ basepython = python
changedir = doc
deps = sphinx>=1.5.1
setuptools_scm
viivakoodi
python-barcode
sphinxcontrib-spelling>=5
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
[testenv:flake8]