mirror of
https://github.com/python-escpos/python-escpos
synced 2025-09-13 09:09:58 +00:00
Compare commits
3 Commits
v3.0a8
...
brb-ean-ex
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a68347ee1c | ||
![]() |
c40f2abe07 | ||
![]() |
fb82e5dc4a |
43
.github/workflows/pythonpackage.yml
vendored
43
.github/workflows/pythonpackage.yml
vendored
@@ -1,43 +0,0 @@
|
||||
# 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
7
.gitignore
vendored
@@ -29,10 +29,3 @@ test/test-cli-output/
|
||||
*.swp
|
||||
*.swn
|
||||
*.swo
|
||||
|
||||
# vscode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
1
.mailmap
1
.mailmap
@@ -13,3 +13,4 @@ csoft2k <csoft2k@hotmail.com>
|
||||
Sergio Pulgarin <sergio.pulgarin@gmail.com>
|
||||
reck31 <rakesh.gunduka@gmail.com>
|
||||
Alex Debiasio <alex.debiasio@thinkin.io> <alex.debiasio@studenti.unitn.it>
|
||||
Brian 'Redbeard' Harrington <redbeard@dead-city.org>
|
||||
|
28
.travis.yml
28
.travis.yml
@@ -1,14 +1,16 @@
|
||||
language: python
|
||||
sudo: false
|
||||
cache: pip
|
||||
dist: bionic
|
||||
dist: xenial
|
||||
git:
|
||||
depth: 100000
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- graphviz
|
||||
- libenchant1c2a
|
||||
env:
|
||||
global:
|
||||
- ESCPOS_CAPABILITIES_FILE=/home/travis/build/python-escpos/python-escpos/capabilities-data/dist/capabilities.json
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
@@ -17,7 +19,7 @@ matrix:
|
||||
language: shell
|
||||
before_install:
|
||||
- choco install python
|
||||
- pip install tox codecov 'sphinx>=1.5.1' 'sphinxcontrib-spelling>=5'
|
||||
- pip install tox codecov 'sphinx>=1.5.1'
|
||||
env:
|
||||
- TOXENV=py37
|
||||
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
|
||||
@@ -27,27 +29,35 @@ 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.8
|
||||
- python: 3.7
|
||||
env: TOXENV=docs
|
||||
- python: 3.8
|
||||
- python: 3.7
|
||||
env: TOXENV=flake8
|
||||
allow_failures:
|
||||
- python: 2.7
|
||||
- python: 3.6-dev
|
||||
- python: 3.7-dev
|
||||
- python: 3.8-dev
|
||||
- python: nightly
|
||||
@@ -55,7 +65,7 @@ matrix:
|
||||
- os: windows
|
||||
- os: osx
|
||||
before_install:
|
||||
- pip install tox codecov 'sphinx>=1.5.1' 'sphinxcontrib-spelling>=5'
|
||||
- pip install tox codecov 'sphinx>=1.5.1'
|
||||
- ./doc/generate_authors.sh --check
|
||||
script:
|
||||
- tox
|
||||
@@ -76,4 +86,4 @@ deploy:
|
||||
tags: true
|
||||
repo: python-escpos/python-escpos
|
||||
branch: master
|
||||
condition: $TRAVIS_PYTHON_VERSION = "3.8"
|
||||
condition: $TRAVIS_PYTHON_VERSION = "3.7"
|
||||
|
11
.vscode/settings.json
vendored
11
.vscode/settings.json
vendored
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"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
16
.vscode/tasks.json
vendored
@@ -1,16 +0,0 @@
|
||||
{
|
||||
// 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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
5
AUTHORS
5
AUTHORS
@@ -1,10 +1,9 @@
|
||||
Ahmed Tahri
|
||||
akeonly
|
||||
Alexander Bougakov
|
||||
Alex Debiasio
|
||||
Asuki Kono
|
||||
belono
|
||||
Brian
|
||||
Brian 'Redbeard' Harrington
|
||||
Christoph Heuel
|
||||
Cody (Quantified Code Bot)
|
||||
csoft2k
|
||||
@@ -21,7 +20,6 @@ Kristi
|
||||
ldos
|
||||
Lucy Linder
|
||||
Manuel F Martinez
|
||||
Maximilian Wagenbach
|
||||
Michael Billington
|
||||
Michael Elsdörfer
|
||||
mrwunderbar666
|
||||
@@ -39,5 +37,4 @@ Sergio Pulgarin
|
||||
Stephan Sokolow
|
||||
Thijs Triemstra
|
||||
Thomas van den Berg
|
||||
Yaisel Hurtado
|
||||
ysuolmai
|
||||
|
@@ -1,57 +1,10 @@
|
||||
*********
|
||||
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 that the API is subject to change until v3.0 is
|
||||
Please be aware the the API is subject to change until v3.0 is
|
||||
released.
|
||||
|
||||
changes
|
||||
|
@@ -27,6 +27,25 @@ 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.
|
||||
@@ -37,9 +56,12 @@ Apart from that the travis-log and the check by Landscape will provide you with
|
||||
|
||||
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 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`.
|
||||
|
||||
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
23
INSTALL
@@ -1,10 +1,23 @@
|
||||
python-escpos
|
||||
=============
|
||||
|
||||
This library is available over pypi. So for most of the use-cases it should be sufficient to run
|
||||
Ensure the library is installed on ${lib_arch}/${python_ver}/site-packages/escpos
|
||||
|
||||
```
|
||||
pip install python-escpos --user # add --pre if you want to install pre-releases
|
||||
```
|
||||
On CLi you must run:
|
||||
# python setup.py build
|
||||
# sudo python setup.py install
|
||||
|
||||
For more information please read the documentation at https://python-escpos.readthedocs.io/en/latest/user/installation.html
|
||||
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>
|
||||
|
@@ -4,7 +4,6 @@ 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
|
||||
|
33
README.rst
33
README.rst
@@ -6,12 +6,16 @@ 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=latest
|
||||
:target: http://python-escpos.readthedocs.io/en/latest/?badge=latest
|
||||
.. image:: https://readthedocs.org/projects/python-escpos/badge/?version=stable
|
||||
:target: http://python-escpos.readthedocs.io/en/latest/?badge=stable
|
||||
:alt: Documentation Status
|
||||
|
||||
|
||||
@@ -43,7 +47,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
|
||||
* `python-barcode <https://github.com/WhyNotHugo/python-barcode>`_ for the generation of barcodes
|
||||
* `viivakoodi <https://github.com/kxepal/viivakoodi>`_ for the generation of barcodes
|
||||
|
||||
Documentation and Usage
|
||||
-----------------------
|
||||
@@ -58,7 +62,7 @@ The basic usage is:
|
||||
p = Usb(0x04b8, 0x0202, 0, profile="TM-T88III")
|
||||
p.text("Hello World\n")
|
||||
p.image("logo.gif")
|
||||
p.barcode('1324354657687', 'EAN13', 64, 2, '', '')
|
||||
p.barcode('4006381333931', 'EAN13', 64, 2, '', '')
|
||||
p.cut()
|
||||
|
||||
|
||||
@@ -70,27 +74,8 @@ Another example based on the Network printer class:
|
||||
|
||||
kitchen = Network("192.168.1.100") #Printer IP Address
|
||||
kitchen.text("Hello World\n")
|
||||
kitchen.barcode('1324354657687', 'EAN13', 64, 2, '', '')
|
||||
kitchen.barcode('4006381333931', '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>`_.
|
||||
|
Submodule capabilities-data updated: 3b5b35cfd3...8885283d71
@@ -3,9 +3,10 @@ codecov:
|
||||
|
||||
coverage:
|
||||
status:
|
||||
project: off
|
||||
patch: off
|
||||
changes: off
|
||||
project:
|
||||
default: # status context
|
||||
target: auto
|
||||
threshold: "1%"
|
||||
range: "60...100"
|
||||
|
||||
comment: off
|
||||
|
@@ -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 spelling
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@@ -45,7 +45,6 @@ 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)/*
|
||||
@@ -176,8 +175,3 @@ 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."
|
||||
|
@@ -43,7 +43,6 @@ extensions = [
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.graphviz',
|
||||
'sphinx.ext.inheritance_diagram',
|
||||
'sphinxcontrib.spelling',
|
||||
]
|
||||
|
||||
# supress warnings for external images
|
||||
@@ -293,9 +292,3 @@ 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
|
||||
|
@@ -3,8 +3,6 @@ Pillow>=2.0
|
||||
qrcode>=4.0
|
||||
pyserial
|
||||
sphinx-rtd-theme
|
||||
setuptools
|
||||
setuptools-scm
|
||||
docutils>=0.12
|
||||
sphinxcontrib-spelling>=5
|
||||
python-barcode>=0.11.0,<1
|
||||
viivakoodi
|
||||
|
@@ -1,7 +0,0 @@
|
||||
Raspbian
|
||||
ESC
|
||||
POS
|
||||
Escpos
|
||||
Escpos
|
||||
baudrate
|
||||
lsusb
|
@@ -48,16 +48,14 @@ 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, 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:
|
||||
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:
|
||||
|
||||
**Generic USB Printer initialization**
|
||||
|
||||
::
|
||||
|
||||
p = printer.Usb(0x2730, 0x0fff, 0, 0x81, 0x02)
|
||||
p = printer.Usb(0x1a2b,0x1a2b,0,0x81,0x02)
|
||||
|
||||
Network printer
|
||||
^^^^^^^^^^^^^^^
|
||||
@@ -84,7 +82,7 @@ to.
|
||||
::
|
||||
|
||||
p = printer.Serial("/dev/tty0")
|
||||
|
||||
|
||||
# on a Windows OS serial devices are typically accessible as COM
|
||||
p = printer.Serial("COM1")
|
||||
|
||||
@@ -121,7 +119,7 @@ on a USB interface.
|
||||
# Print QR Code
|
||||
p.qr("You can readme from your smartphone")
|
||||
# Print barcode
|
||||
p.barcode('1324354657687','EAN13',64,2,'','')
|
||||
p.barcode('4006381333931','EAN13',64,2,'','')
|
||||
# Cut paper
|
||||
p.cut()
|
||||
|
||||
@@ -163,7 +161,7 @@ The printer section
|
||||
|
||||
The ``printer`` configuration section defines a default printer to create.
|
||||
|
||||
The only required parameter is ``type``. The value of this has to be one of the
|
||||
The only required paramter 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.
|
||||
@@ -194,12 +192,12 @@ An USB-printer could be defined by::
|
||||
|
||||
Printing text right
|
||||
-------------------
|
||||
|
||||
Python-escpos is designed to accept unicode.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
@@ -1,6 +1,7 @@
|
||||
"""Prints code page tables.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import six
|
||||
import sys
|
||||
|
@@ -6,4 +6,4 @@ p = Usb(0x0416, 0x5011, profile="POS-5890")
|
||||
|
||||
# Some software barcodes
|
||||
p.soft_barcode('code128', 'Hello')
|
||||
p.soft_barcode('code39', '1234')
|
||||
p.soft_barcode('code39', '123456')
|
||||
|
@@ -13,6 +13,7 @@
|
||||
# Check out his github: https://github.com/AdamWhitcroft/climacons
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
from datetime import datetime
|
||||
import calendar
|
||||
import urllib
|
||||
|
@@ -3,5 +3,5 @@ formats:
|
||||
- epub
|
||||
requirements_file: doc/requirements.txt
|
||||
python:
|
||||
version: 3
|
||||
version: 2
|
||||
setup_py_install: true
|
68
setup.cfg
68
setup.cfg
@@ -1,71 +1,11 @@
|
||||
[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
|
||||
|
81
setup.py
81
setup.py
@@ -22,19 +22,90 @@ 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,
|
||||
},
|
||||
platforms="any",
|
||||
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',
|
||||
package_dir={"": "src"},
|
||||
packages=find_packages(where="src", exclude=["tests", "tests.*"]),
|
||||
package_data={"escpos": ["capabilities.json"]},
|
||||
entry_points={"console_scripts": ["python-escpos = escpos.cli:main"]},
|
||||
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'
|
||||
]
|
||||
},
|
||||
)
|
||||
|
@@ -2,6 +2,10 @@
|
||||
"""
|
||||
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"]
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import re
|
||||
from os import environ, path
|
||||
import pkg_resources
|
||||
import pickle
|
||||
import logging
|
||||
import time
|
||||
@@ -16,9 +15,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()))
|
||||
# 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'))
|
||||
capabilities_path = environ.get(
|
||||
'ESCPOS_CAPABILITIES_FILE',
|
||||
path.join(path.dirname(__file__), 'capabilities.json'))
|
||||
|
||||
# Load external printer database
|
||||
t0 = time.time()
|
||||
@@ -59,7 +58,7 @@ BARCODE_B = 'barcodeB'
|
||||
|
||||
|
||||
class BaseProfile(object):
|
||||
"""This represents a printer profile.
|
||||
"""This respresents a printer profile.
|
||||
|
||||
A printer profile knows about the number of columns, supported
|
||||
features, colors and more.
|
||||
|
@@ -3,12 +3,16 @@
|
||||
""" 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 convenience.
|
||||
closely the available ESCPOS commands while adding a couple extra ones for convience.
|
||||
|
||||
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:
|
||||
@@ -49,7 +53,7 @@ DEMO_FUNCTIONS = {
|
||||
'barcodes_a': [
|
||||
{'bc': 'UPC-A', 'code': '13243546576'},
|
||||
{'bc': 'UPC-E', 'code': '132435'},
|
||||
{'bc': 'EAN13', 'code': '1324354657687'},
|
||||
{'bc': 'EAN13', 'code': '4006381333931'},
|
||||
{'bc': 'EAN8', 'code': '1324354'},
|
||||
{'bc': 'CODE39', 'code': 'TEST'},
|
||||
{'bc': 'ITF', 'code': '55867492279103'},
|
||||
@@ -58,13 +62,13 @@ DEMO_FUNCTIONS = {
|
||||
'barcodes_b': [
|
||||
{'bc': 'UPC-A', 'code': '13243546576', 'function_type': 'B'},
|
||||
{'bc': 'UPC-E', 'code': '132435', 'function_type': 'B'},
|
||||
{'bc': 'EAN13', 'code': '1324354657687', 'function_type': 'B'},
|
||||
{'bc': 'EAN13', 'code': '4006381333931', 'function_type': 'B'},
|
||||
{'bc': 'EAN8', 'code': '1324354', 'function_type': 'B'},
|
||||
{'bc': 'CODE39', 'code': 'TEST', 'function_type': 'B'},
|
||||
{'bc': 'ITF', 'code': '55867492279103', 'function_type': 'B'},
|
||||
{'bc': 'NW7', 'code': 'A00000000A', 'function_type': 'B'},
|
||||
{'bc': 'CODE93', 'code': 'A00000000A', 'function_type': 'B'},
|
||||
{'bc': 'CODE93', 'code': '1324354657687', 'function_type': 'B'},
|
||||
{'bc': 'CODE93', 'code': '4006381333931', 'function_type': 'B'},
|
||||
{'bc': 'CODE128A', 'code': 'TEST', 'function_type': 'B'},
|
||||
{'bc': 'CODE128B', 'code': 'TEST', 'function_type': 'B'},
|
||||
{'bc': 'CODE128C', 'code': 'TEST', 'function_type': 'B'},
|
||||
@@ -554,7 +558,7 @@ def main():
|
||||
|
||||
def demo(printer, **kwargs):
|
||||
"""
|
||||
Prints demos. Called when CLI is passed `demo`. This function
|
||||
Prints specificed demos. Called when CLI is passed `demo`. This function
|
||||
uses the DEMO_FUNCTIONS dictionary.
|
||||
|
||||
:param printer: A printer from escpos.printer
|
||||
|
@@ -1,9 +1,13 @@
|
||||
""" ESC/POS configuration manager.
|
||||
|
||||
This module contains the implementations of abstract base class :py:class:`Config`.
|
||||
This module contains the implentations 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
|
||||
|
@@ -11,6 +11,10 @@ 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
|
||||
|
||||
|
@@ -10,6 +10,10 @@ 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
|
||||
@@ -102,9 +106,6 @@ 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
|
||||
@@ -116,10 +117,6 @@ 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:
|
||||
@@ -398,7 +395,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 definged in the ESC/POS documentation. See :py:meth:`.check_barcode()`
|
||||
requirements as defigned in the esc/pos documentation. See :py:meth:`.check_barcode()`
|
||||
for more information. *default*: True.
|
||||
|
||||
:raises: :py:exc:`~escpos.exceptions.BarcodeSizeError`,
|
||||
@@ -479,8 +476,7 @@ 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,
|
||||
center=True):
|
||||
module_height=5, module_width=0.2, text_distance=1):
|
||||
|
||||
image_writer = ImageWriter()
|
||||
|
||||
@@ -503,7 +499,7 @@ class Escpos(object):
|
||||
|
||||
# Retrieve the Pillow image and print it
|
||||
image = my_code.writer._image
|
||||
self.image(image, impl=impl, center=center)
|
||||
self.image(image, impl=impl)
|
||||
|
||||
def text(self, txt):
|
||||
""" Print alpha-numeric text
|
||||
|
@@ -25,6 +25,11 @@ 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 """
|
||||
|
@@ -8,6 +8,10 @@ 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
|
||||
|
@@ -4,6 +4,11 @@
|
||||
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
|
||||
|
@@ -12,6 +12,10 @@ 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
|
||||
|
@@ -8,11 +8,15 @@
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import serial
|
||||
import socket
|
||||
import usb.core
|
||||
import usb.util
|
||||
import serial
|
||||
import socket
|
||||
|
||||
from .escpos import Escpos
|
||||
from .exceptions import USBNotFoundError
|
||||
@@ -79,8 +83,6 @@ 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)))
|
||||
@@ -347,7 +349,6 @@ class Dummy(Escpos):
|
||||
_WIN32PRINT = False
|
||||
try:
|
||||
import win32print
|
||||
|
||||
_WIN32PRINT = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
"""verifies that the metaclass abc is properly used by ESC/POS
|
||||
"""verifies that the metaclass abc is properly used by Escpos
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
@@ -7,6 +7,10 @@
|
||||
: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
|
||||
|
||||
@@ -16,7 +20,7 @@ from abc import ABCMeta
|
||||
|
||||
@raises(TypeError)
|
||||
def test_abstract_base_class_raises():
|
||||
"""test whether the abstract base class raises an exception for ESC/POS"""
|
||||
"""test whether the abstract base class raises an exception for Escpos"""
|
||||
escpos.Escpos() # This call should raise TypeError because of abstractmethod _raw()
|
||||
|
||||
|
||||
|
@@ -2,6 +2,10 @@
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@@ -1,6 +1,11 @@
|
||||
#!/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
|
||||
|
@@ -1,4 +1,8 @@
|
||||
#!/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
|
||||
|
@@ -1,6 +1,10 @@
|
||||
#!/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
|
||||
|
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import six
|
||||
|
||||
|
@@ -7,6 +7,10 @@
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pytest
|
||||
|
||||
|
@@ -7,6 +7,10 @@
|
||||
: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
|
||||
|
||||
|
@@ -7,6 +7,10 @@
|
||||
: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
|
||||
|
||||
|
@@ -7,6 +7,10 @@
|
||||
: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
|
||||
|
@@ -8,6 +8,10 @@
|
||||
: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
|
||||
|
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import six
|
||||
|
||||
|
@@ -1,17 +1,16 @@
|
||||
#!/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
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def instance():
|
||||
return printer.Dummy()
|
||||
|
||||
|
||||
def test_soft_barcode_ean8(instance):
|
||||
def test_soft_barcode():
|
||||
"""just execute soft_barcode
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.soft_barcode("ean8", "1234")
|
||||
|
||||
|
||||
def test_soft_barcode_ean8_nocenter(instance):
|
||||
instance.soft_barcode("ean8", "1234", center=False)
|
||||
|
@@ -7,6 +7,10 @@
|
||||
: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
|
||||
|
@@ -7,6 +7,10 @@
|
||||
: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
|
||||
|
||||
|
@@ -8,6 +8,10 @@
|
||||
: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
|
||||
|
@@ -8,6 +8,10 @@
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import six
|
||||
|
||||
@@ -24,6 +28,7 @@ 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"""
|
||||
@@ -35,6 +40,7 @@ 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"""
|
||||
@@ -56,6 +62,7 @@ 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"""
|
||||
|
@@ -7,6 +7,10 @@
|
||||
: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
|
||||
|
@@ -7,6 +7,10 @@
|
||||
: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
18
tox.ini
@@ -1,12 +1,5 @@
|
||||
[tox]
|
||||
envlist = py35, py36, py37, py38, docs, flake8
|
||||
|
||||
[gh-actions]
|
||||
python =
|
||||
2.7: py27
|
||||
3.6: py36
|
||||
3.7: py37
|
||||
3.8: py38
|
||||
envlist = py27, py34, py35, py36, py37, docs, flake8
|
||||
|
||||
[testenv]
|
||||
deps = nose
|
||||
@@ -17,9 +10,9 @@ deps = nose
|
||||
pytest!=3.2.0,!=3.3.0
|
||||
pytest-cov
|
||||
pytest-mock
|
||||
hypothesis>4
|
||||
python-barcode
|
||||
commands = pytest --cov escpos
|
||||
hypothesis!=3.56.9,<4
|
||||
viivakoodi
|
||||
commands = py.test --cov escpos
|
||||
passenv = ESCPOS_CAPABILITIES_PICKLE_DIR ESCPOS_CAPABILITIES_FILE CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_*
|
||||
|
||||
[testenv:docs]
|
||||
@@ -27,8 +20,7 @@ basepython = python
|
||||
changedir = doc
|
||||
deps = sphinx>=1.5.1
|
||||
setuptools_scm
|
||||
python-barcode
|
||||
sphinxcontrib-spelling>=5
|
||||
viivakoodi
|
||||
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
|
||||
|
||||
[testenv:flake8]
|
||||
|
Reference in New Issue
Block a user