mirror of
https://github.com/python-escpos/python-escpos
synced 2025-09-13 09:09:58 +00:00
Compare commits
15 Commits
v3.0a
...
debian/jes
Author | SHA1 | Date | |
---|---|---|---|
![]() |
83185bf2f3 | ||
![]() |
57ce8389d7 | ||
![]() |
df33945458 | ||
![]() |
c1a7d71fd7 | ||
![]() |
a7ee11a78c | ||
![]() |
43e0a87a74 | ||
![]() |
abbe32f845 | ||
![]() |
29cc8baab7 | ||
![]() |
0f33d68f3a | ||
![]() |
a0ef820947 | ||
![]() |
7b24df6581 | ||
![]() |
5078c49b3a | ||
![]() |
b2ce102ca5 | ||
![]() |
d50c407edb | ||
![]() |
2a2ba9a0e2 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -23,3 +23,8 @@ src/escpos/version.py
|
||||
|
||||
# testing temporary directories
|
||||
test/test-cli-output/
|
||||
|
||||
# vim swap files
|
||||
*.swp
|
||||
*.swn
|
||||
*.swo
|
||||
|
15
.travis.yml
15
.travis.yml
@@ -29,7 +29,7 @@ matrix:
|
||||
env: TOXENV=docs
|
||||
- python: 2.7
|
||||
env: TOXENV=flake8
|
||||
- python: 3.5
|
||||
- python: 3.6
|
||||
env: TOXENV=flake8
|
||||
allow_failures:
|
||||
- python: 3.6-dev
|
||||
@@ -44,3 +44,16 @@ notifications:
|
||||
email:
|
||||
on_success: never
|
||||
on_failure: change
|
||||
deploy:
|
||||
# Github deployment
|
||||
- provider: releases
|
||||
api_key:
|
||||
secure: oiR3r5AIx9ENIRtbUKIxorRx8GMv4BxgVIZcieXbgSTN4DBZdRWdzs1Xxngu/90Xf79G0X+XGxZyXrYN7eFFNp0kUYj8kwZ1aS/dyR88scskumERWi1Hv5WUJrYGrDe7PcjNGsJ2jw0nNnRPKG87Y84aR4lQygyGBSlDcdrOBnBv0sHYJMxRvHSRkGgWpur06QIOGOk4oOipTXR/7E9cg3YQC5nvZAf2QiprwTa8IcOSFlZQPykEVRYSiAgXrgqBYcZzpX0hAGuIBv7DmPI2ORTF+t79Wbhxhnho3gGJleDv7Z96//sf1vQNCG6qOgeIc9ZY08Jm1AwXQoW0p6F1/XcEPxeyPDkXJzlojE9rjYNLCPL4gxb/LESEuUafm0U4JGMsZ6hnsBOw583yTuAdfQuJ9M+QaSyem6OVNkky3+DKAD3z0WJnl9jmGXIXigNSIxD25XhpvY+j9P0XTLBG1GT2Q+wXCIjSYJc2XnYcdgVJcLoxSWk1fKj/KPi7buAWtqwnL3tjeldpMMOZMliPUTWMM14zoGskHztt0JCkAtcotm9AQtvL8eZ2LHLDK/jyLzjv0wAwU5vzSVp14XHLZl7Q0AIoNc20p1EYGa9C/gSPd9CkrWZoG4lMOiAu3tp2PRLVrdXH3ZWSPQq4Ek5MczrUTkmB82XErNbOa8QB1Dw=
|
||||
file: .tox/dist/python-escpos*.zip
|
||||
file_glob: true
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
repo: python-escpos/python-escpos
|
||||
branch: master
|
||||
condition: $TRAVIS_PYTHON_VERSION = "3.5"
|
||||
|
@@ -2,6 +2,24 @@
|
||||
Changelog
|
||||
*********
|
||||
|
||||
2017-03-29 - Version 3.0a1 - "Headcrash"
|
||||
----------------------------------------
|
||||
This release is the second alpha release of the new version 3.0. Please
|
||||
be aware that the API will still change until v3.0 is released.
|
||||
|
||||
changes
|
||||
^^^^^^^
|
||||
- automatically upload releases to GitHub
|
||||
- add environment variable ESCPOS_CAPABILITIES_FILE
|
||||
- automatically handle cases where full cut or partial cut is not available
|
||||
- add print_and_feed
|
||||
|
||||
contributors
|
||||
^^^^^^^^^^^^
|
||||
- Sam Cheng
|
||||
- Patrick Kanzler
|
||||
- Dmytro Katyukha
|
||||
|
||||
2017-01-31 - Version 3.0a - "Grey Area"
|
||||
---------------------------------------
|
||||
This release is the first alpha release of the new version 3.0. Please
|
||||
|
Submodule capabilities-data updated: 31d2269651...fd207aa9de
@@ -7,10 +7,6 @@ coverage:
|
||||
default: # status context
|
||||
target: auto
|
||||
threshold: "1%"
|
||||
patch:
|
||||
default:
|
||||
target: auto
|
||||
threshold: "1%"
|
||||
range: "60...100"
|
||||
|
||||
comment: off
|
||||
|
94
debian/changelog
vendored
Normal file
94
debian/changelog
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
python-escpos (1.0.8-3) unstable; urgency=medium
|
||||
|
||||
[ Christoph Heuel ]
|
||||
* Fix text wrapping error after image
|
||||
|
||||
[ Patrick Kanzler ]
|
||||
* moved .hgignore to .gitignore
|
||||
* REFACTOR chained boolean expression in escpos
|
||||
* REFACTOR use new-style class for Escpos
|
||||
* REFACTOR style and PEP8, fixes #66
|
||||
* REFACTOR do not shadow built-ins
|
||||
* ADD requirements.txt and requirements to setup.py
|
||||
* DOC, IMPROVE improve docstrings and add abstract method _raw to Escpos
|
||||
* FIX constant definition for PC1252
|
||||
|
||||
-- Christoph Heuel <mail@christoph-heuel.net> Sun, 13 Dec 2015 14:27:27 +0100
|
||||
|
||||
python-escpos (1.0.8-2) unstable; urgency=low
|
||||
|
||||
* Imported source
|
||||
* First debianization
|
||||
|
||||
-- Christoph Heuel <mail@christoph-heuel.net> Sat, 12 Dec 2015 19:13:33 +0100
|
||||
|
||||
python-escpos (1.0.8-1) unstable; urgency=low
|
||||
|
||||
[ Manuel F Martinez ]
|
||||
* Added donation message
|
||||
|
||||
[ Joel Lehtonen ]
|
||||
* Support for images vertically longer than 256 pixels
|
||||
|
||||
[ Christoph Heuel ]
|
||||
* Fix mixed tabs/space error
|
||||
|
||||
[ Hark ]
|
||||
* Prevent crash when using libusb0 printers
|
||||
|
||||
[ Manuel F Martinez ]
|
||||
* Updated README and documentation
|
||||
|
||||
[ Christoph Heuel ]
|
||||
* Add flush function
|
||||
* Debian packaging
|
||||
|
||||
-- Manuel F Martinez <manpaz@gmail.com> Sat, 12 Dec 2015 20:59:53 +0100
|
||||
|
||||
python-escpos (1.0.7-1) unstable; urgency=low
|
||||
|
||||
[ Kristi ]
|
||||
* Raising the right error when wrong charcode is used
|
||||
|
||||
[ Christoph Heuel ]
|
||||
* After running 2to3 tool
|
||||
* Fix for string operation
|
||||
* Integer is needed, not float
|
||||
* Add text wrapping
|
||||
|
||||
[ Manuel F Martinez ]
|
||||
* Updated URL for the documentation
|
||||
* Updated documentation URL to local wiki
|
||||
* Updated setup URLs
|
||||
|
||||
[ Christoph Heuel ]
|
||||
* Introduce new direct_image
|
||||
|
||||
[ Manuel F Martinez ]
|
||||
* Fixed License version mismatch
|
||||
|
||||
[ Christoph Heuel ]
|
||||
* Use unhexlify
|
||||
* Hexlify text
|
||||
|
||||
[ Manuel F Martinez ]
|
||||
* Updated accordingly to the wiki
|
||||
|
||||
[ ldos ]
|
||||
* Extended params for serial printers
|
||||
|
||||
[ Manuel F Martinez ]
|
||||
* Fixed issues with transparent images
|
||||
* Updated project version
|
||||
|
||||
-- Manuel F Martinez <manpaz@gmail.com> Sat, 12 Dec 2015 20:59:53 +0100
|
||||
|
||||
python-escpos (1.0.4-1) unstable; urgency=medium
|
||||
|
||||
[ Manuel F Martinez ]
|
||||
* Added density support
|
||||
* Added quad support
|
||||
* fixed code tabulators
|
||||
* Updated version
|
||||
|
||||
-- Manuel F Martinez <manpaz@gmail.com> Sat, 12 Dec 2015 20:59:53 +0100
|
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@@ -0,0 +1 @@
|
||||
9
|
55
debian/control
vendored
Normal file
55
debian/control
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
Source: python-escpos
|
||||
Section: unknown
|
||||
Priority: optional
|
||||
Maintainer: Christoph Heuel <mail@christoph-heuel.net>
|
||||
Build-Depends: debhelper (>= 9), dh-python
|
||||
Standards-Version: 3.9.5
|
||||
Homepage: https://github.com/braveheuel/python-escpos
|
||||
#Vcs-Git: git@github.com:braveheuel/python-escpos.git
|
||||
#Vcs-Browser: https://github.com/braveheuel/python-escpos
|
||||
|
||||
Package: python-escpos
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Description: Python library to manipulate ESC/POS Printers (Python 2)
|
||||
Python ESC/POS is a library which lets the user have access to all
|
||||
those printers handled by ESC/POS commands, as defined by Epson,
|
||||
from a Python application.
|
||||
.
|
||||
The standard usage is send raw text to the printer, but in also
|
||||
helps the user to enhance the experience with those printers by
|
||||
facilitating the bar code printing in many different standards,
|
||||
as well as manipulating images so they can be printed as brand
|
||||
logo or any other usage images migh have.
|
||||
.
|
||||
Text can be aligned/justified and fonts can be changed by size,
|
||||
type and weight.
|
||||
.
|
||||
Also, this module handles some hardware functionalities like, cut
|
||||
paper, carrier return, printer reset and others concerned to the
|
||||
carriage alignment.
|
||||
.
|
||||
This package covers Python 2 code.
|
||||
|
||||
Package: python3-escpos
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Description: Python library to manipulate ESC/POS Printers (Python 3)
|
||||
Python ESC/POS is a library which lets the user have access to all
|
||||
those printers handled by ESC/POS commands, as defined by Epson,
|
||||
from a Python application.
|
||||
.
|
||||
The standard usage is send raw text to the printer, but in also
|
||||
helps the user to enhance the experience with those printers by
|
||||
facilitating the bar code printing in many different standards,
|
||||
as well as manipulating images so they can be printed as brand
|
||||
logo or any other usage images migh have.
|
||||
.
|
||||
Text can be aligned/justified and fonts can be changed by size,
|
||||
type and weight.
|
||||
.
|
||||
Also, this module handles some hardware functionalities like, cut
|
||||
paper, carrier return, printer reset and others concerned to the
|
||||
carriage alignment.
|
||||
.
|
||||
This package covers Python 3 code.
|
26
debian/copyright
vendored
Normal file
26
debian/copyright
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: python-escpos
|
||||
Source: https://github.com/manpaz/python-escpos
|
||||
|
||||
Files: *
|
||||
Copyright: 2015 Manuel F Martinez <manpaz@bashlinux.com>
|
||||
License: GPL v3
|
||||
|
||||
Files: debian/*
|
||||
Copyright: 2015 Christoph Heuel <mail@christoph-heuel.net>
|
||||
License: GPL-2+
|
||||
This package is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
.
|
||||
This package is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
.
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
|
1
debian/docs
vendored
Normal file
1
debian/docs
vendored
Normal file
@@ -0,0 +1 @@
|
||||
README.rst
|
6
debian/gbp.conf
vendored
Normal file
6
debian/gbp.conf
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[DEFAULT]
|
||||
upstream-branch=master
|
||||
upstream-tree = tag
|
||||
debian-branch = debian/jessie
|
||||
upstream-tag = v%(version)s
|
||||
debian-tag = v%(version)s
|
28
debian/rules
vendored
Executable file
28
debian/rules
vendored
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/make -f
|
||||
# See debhelper(7) (uncomment to enable)
|
||||
# output every command that modifies files on the build system.
|
||||
#DH_VERBOSE = 1
|
||||
|
||||
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
|
||||
DPKG_EXPORT_BUILDFLAGS = 1
|
||||
include /usr/share/dpkg/default.mk
|
||||
|
||||
# see FEATURE AREAS in dpkg-buildflags(1)
|
||||
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
|
||||
|
||||
# see ENVIRONMENT in dpkg-buildflags(1)
|
||||
# package maintainers to append CFLAGS
|
||||
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
|
||||
# package maintainers to append LDFLAGS
|
||||
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
|
||||
|
||||
|
||||
# main packaging script based on dh7 syntax
|
||||
%:
|
||||
dh $@ --with python2,python3 --buildsystem=pybuild
|
||||
|
||||
# debmake generated override targets
|
||||
# This is example for Cmake (See http://bugs.debian.org/641051 )
|
||||
#override_dh_auto_configure:
|
||||
# dh_auto_configure -- \
|
||||
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
|
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
||||
3.0 (quilt)
|
@@ -216,6 +216,32 @@ Here you can download an example, that will print a set of common barcodes:
|
||||
|
||||
* :download:`barcode.bin </download/barcode.bin>` by `@mike42 <https://github.com/mike42>`_
|
||||
|
||||
Advanced Usage: change capabilities-profile
|
||||
-------------------------------------------
|
||||
|
||||
Packaged together with the escpos-code is a capabilities-file. This file in
|
||||
JSON-format describes the capabilities of different printers. It is developed and hosted in
|
||||
`escpos-printer-db <https://github.com/receipt-print-hq/escpos-printer-db>`_.
|
||||
|
||||
Certain applications like the usage of `cx_freeze <https://cx-freeze.readthedocs.io>`_ might change the
|
||||
packaging structure. This leads to the capabilities-profile not being found.
|
||||
In this case you can use the environment-variable `ESCPOS_CAPABILITIES_FILE`.
|
||||
The following code is an example.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
# use packaged capabilities-profile
|
||||
python-escpos cut
|
||||
|
||||
# use capabilities-profile that you have put in /usr/python-escpos
|
||||
export ESCPOS_CAPABILITIES_FILE=/usr/python-escpos/capabilities.json
|
||||
python-escpos cut
|
||||
|
||||
# use packaged file again
|
||||
unset ESCPOS_CAPABILITIES_FILE
|
||||
python-escpos cut
|
||||
|
||||
|
||||
Hint: preprocess printing
|
||||
-------------------------
|
||||
|
||||
|
@@ -1,10 +1,15 @@
|
||||
import re
|
||||
import six
|
||||
from os import path
|
||||
from os import environ, path
|
||||
import yaml
|
||||
|
||||
# Load external printer database
|
||||
with open(path.join(path.dirname(__file__), 'capabilities.json')) as f:
|
||||
if 'ESCPOS_CAPABILITIES_FILE' in environ:
|
||||
file_path = environ['ESCPOS_CAPABILITIES_FILE']
|
||||
else:
|
||||
file_path = path.join(path.dirname(__file__), 'capabilities.json')
|
||||
|
||||
with open(file_path) as f:
|
||||
CAPABILITIES = yaml.load(f)
|
||||
|
||||
PROFILES = CAPABILITIES['profiles']
|
||||
|
@@ -100,6 +100,12 @@ ESCPOS_COMMANDS = [
|
||||
'option_strings': ('--content',),
|
||||
'help': 'Text to print as a qr code',
|
||||
'required': True,
|
||||
},
|
||||
{
|
||||
'option_strings': ('--size',),
|
||||
'help': 'QR code size (1-16) [default:3]',
|
||||
'required': False,
|
||||
'type': int,
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@@ -564,7 +564,7 @@ class Escpos(object):
|
||||
|
||||
self._raw(LINESPACING_FUNCS[divisor] + six.int2byte(spacing))
|
||||
|
||||
def cut(self, mode=''):
|
||||
def cut(self, mode='FULL'):
|
||||
""" Cut paper.
|
||||
|
||||
Without any arguments the paper will be cut completely. With 'mode=PART' a partial cut will
|
||||
@@ -573,15 +573,25 @@ class Escpos(object):
|
||||
|
||||
.. todo:: Check this function on TM-T88II.
|
||||
|
||||
:param mode: set to 'PART' for a partial cut
|
||||
:param mode: set to 'PART' for a partial cut. default: 'FULL'
|
||||
:raises ValueError: if mode not in ('FULL', 'PART')
|
||||
"""
|
||||
# Fix the size between last line and cut
|
||||
# TODO: handle this with a line feed
|
||||
self._raw(b"\n\n\n\n\n\n")
|
||||
if mode.upper() == "PART":
|
||||
self._raw(PAPER_PART_CUT)
|
||||
else: # DEFAULT MODE: FULL CUT
|
||||
self._raw(PAPER_FULL_CUT)
|
||||
self.print_and_feed(6)
|
||||
|
||||
mode = mode.upper()
|
||||
if mode not in ('FULL', 'PART'):
|
||||
raise ValueError("Mode must be one of ('FULL', 'PART')")
|
||||
|
||||
if mode == "PART":
|
||||
if self.profile.supports('paperPartCut'):
|
||||
self._raw(PAPER_PART_CUT)
|
||||
elif self.profile.supports('paperFullCut'):
|
||||
self._raw(PAPER_FULL_CUT)
|
||||
elif mode == "FULL":
|
||||
if self.profile.supports('paperFullCut'):
|
||||
self._raw(PAPER_FULL_CUT)
|
||||
elif self.profile.supports('paperPartCut'):
|
||||
self._raw(PAPER_PART_CUT)
|
||||
|
||||
def cashdraw(self, pin):
|
||||
""" Send pulse to kick the cash drawer
|
||||
@@ -620,6 +630,20 @@ class Escpos(object):
|
||||
else: # DEFAULT: DOES NOTHING
|
||||
pass
|
||||
|
||||
def print_and_feed(self, n=1):
|
||||
""" Print data in print buffer and feed *n* lines
|
||||
|
||||
if n not in range (0, 255) then ValueError will be raised
|
||||
|
||||
:param n: number of n to feed. 0 <= n <= 255. default: 1
|
||||
:raises ValueError: if not 0 <= n <= 255
|
||||
"""
|
||||
if 0 <= n <= 255:
|
||||
# ESC d n
|
||||
self._raw(ESC + b"d" + six.int2byte(n))
|
||||
else:
|
||||
raise ValueError("n must be betwen 0 and 255")
|
||||
|
||||
def control(self, ctl, pos=4):
|
||||
""" Feed control sequences
|
||||
|
||||
@@ -634,11 +658,6 @@ class Escpos(object):
|
||||
:param pos: integer between 1 and 16, controls the horizontal tab position
|
||||
:raises: :py:exc:`~escpos.exceptions.TabPosError`
|
||||
"""
|
||||
# Set tab positions
|
||||
if not (1 <= pos <= 16):
|
||||
raise TabPosError()
|
||||
else:
|
||||
self._raw(CTL_SET_HT + six.int2byte(pos))
|
||||
# Set position
|
||||
if ctl.upper() == "LF":
|
||||
self._raw(CTL_LF)
|
||||
@@ -647,6 +666,12 @@ class Escpos(object):
|
||||
elif ctl.upper() == "CR":
|
||||
self._raw(CTL_CR)
|
||||
elif ctl.upper() == "HT":
|
||||
if not (1 <= pos <= 16):
|
||||
raise TabPosError()
|
||||
else:
|
||||
# Set tab positions
|
||||
self._raw(CTL_SET_HT + six.int2byte(pos))
|
||||
|
||||
self._raw(CTL_HT)
|
||||
elif ctl.upper() == "VT":
|
||||
self._raw(CTL_VT)
|
||||
|
Reference in New Issue
Block a user