commit
df33945458
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 31d2269651d4d10ca51f59799ee4d05b4c4a1625
|
||||
Subproject commit fd207aa9debc9671405226598a086b282f9f3ad5
|
|
@ -7,10 +7,6 @@ coverage:
|
|||
default: # status context
|
||||
target: auto
|
||||
threshold: "1%"
|
||||
patch:
|
||||
default:
|
||||
target: auto
|
||||
threshold: "1%"
|
||||
range: "60...100"
|
||||
|
||||
comment: off
|
||||
|
|
|
@ -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.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)
|
||||
else: # DEFAULT MODE: FULL 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)
|
||||
|
|
Loading…
Reference in New Issue