Skip to content

Commit 7d89b2f

Browse files
committed
1.8.0 (#25)
* update setup.py and add LICENSE * pyusb@1.0.0 compatibility * change project name in setup.py
1 parent 43f2b00 commit 7d89b2f

File tree

5 files changed

+102
-19
lines changed

5 files changed

+102
-19
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ eggs
55
build
66
*.pyc
77
*.pyo
8-
virtualenv
8+
virtualenv

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2016 Benoît Guigal
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

epson_printer/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
2+
__version__ = "1.8.0"
3+
14
__all__ = ["epsonprinter","testpage"]
25

epson_printer/epsonprinter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,21 @@ class EpsonPrinter:
168168

169169
printer = None
170170

171-
def __init__(self, id_vendor, id_product, interface=0, in_ep=0x82, out_ep=0x01):
171+
def __init__(self, id_vendor, id_product, out_ep=0x01):
172172
"""
173173
@param id_vendor : Vendor ID
174174
@param id_product : Product ID
175175
@param interface : USB device interface
176176
@param in_ep : Input end point
177177
@param out_ep : Output end point
178178
"""
179-
self.interface = interface
180-
self.in_ep = in_ep
179+
181180
self.out_ep = out_ep
182181

183182
# Search device on USB tree and set is as printer
184183
self.printer = usb.core.find(idVendor=id_vendor, idProduct=id_product)
185184
if self.printer is None:
186-
raise Exception("Printer not found. Make sure the cable is plugged in.")
185+
raise ValueError("Printer not found. Make sure the cable is plugged in.")
187186

188187
if self.printer.is_kernel_driver_active(0):
189188
try:
@@ -212,7 +211,7 @@ def write_bytes(self, byte_array):
212211
self.write(msg)
213212

214213
def write(self, msg):
215-
self.printer.write(self.out_ep, msg, self.interface, timeout=20000)
214+
self.printer.write(self.out_ep, msg, timeout=20000)
216215

217216
def print_text(self, msg):
218217
self.write(msg)

setup.py

Lines changed: 73 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,74 @@
11

2-
from setuptools import setup
3-
4-
setup(name="python_epson_printer",
5-
version="1.7.1",
6-
description="A library to control Epson thermal printers based on ESC/POS language",
7-
url="https://github.com/benoitguigal/python-epson-printer",
8-
author="benoitguigal",
9-
author_email="benoit.guigal@gmail.com",
10-
packages=['epson_printer'],
11-
install_requires=[
12-
'pyusb==1.0.0b1',
13-
'Pillow==2.6'
14-
])
2+
# Always prefer setuptools over distutils
3+
from setuptools import setup, find_packages
4+
import os
5+
import re
6+
7+
8+
def get_version(package):
9+
"""
10+
Return package version as listed in `__version__` in `init.py`.
11+
"""
12+
init_py = open(os.path.join(package, '__init__.py')).read()
13+
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
14+
15+
setup(
16+
name='python-epson-printer',
17+
18+
# Versions should comply with PEP440. For a discussion on single-sourcing
19+
# the version across setup.py and the project code, see
20+
# https://packaging.python.org/en/latest/single_source_version.html
21+
version=get_version('epson_printer'),
22+
23+
description='A library to control Epson thermal printers based on ESC/POS language',
24+
25+
# The project's main homepage.
26+
url='https://github.com/benoitguigal/python-epson-printer/',
27+
28+
# Author details
29+
author='Benoit Guigal',
30+
author_email='benoit.guigal@gmail.com',
31+
32+
# Choose your license
33+
license='MIT',
34+
35+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
36+
classifiers=[
37+
# How mature is this project? Common values are
38+
# 3 - Alpha
39+
# 4 - Beta
40+
# 5 - Production/Stable
41+
'Development Status :: 4 - Beta',
42+
43+
# Indicate who your project is intended for
44+
'Intended Audience :: Developers',
45+
'Topic :: Software Development :: Build Tools',
46+
47+
# Pick your license as you wish (should match "license" above)
48+
'License :: OSI Approved :: MIT License',
49+
50+
# Specify the Python versions you support here. In particular, ensure
51+
# that you indicate whether you support Python 2, Python 3 or both.
52+
'Programming Language :: Python :: 2',
53+
'Programming Language :: Python :: 2.6',
54+
'Programming Language :: Python :: 2.7',
55+
],
56+
57+
# What does your project relate to?
58+
keywords='epson printer escpos',
59+
60+
# You can just specify the packages manually here if your project is
61+
# simple. Or you can use find_packages().
62+
packages=find_packages(exclude=['tests*']),
63+
64+
# List run-time dependencies here. These will be installed by pip when
65+
# your project is installed. For an analysis of "install_requires" vs pip's
66+
# requirements files see:
67+
# https://packaging.python.org/en/latest/requirements.html
68+
install_requires=[
69+
'pyusb>=1.0.0',
70+
'Pillow>=3.1.0',
71+
'numpy>=1.11.0'
72+
]
73+
74+
)

0 commit comments

Comments
 (0)