[MERGE] hw_escpos: moving list of supported printers to a separate file
bzr revid: fva@openerp.com-20140129163503-tvd69qd5u5nktjb9
This commit is contained in:
commit
64822bd188
|
@ -21,6 +21,7 @@ except ImportError:
|
|||
from openerp.tools.translate import _
|
||||
from .. import escpos
|
||||
from ..escpos import printer
|
||||
from ..escpos import supported_devices
|
||||
from PIL import Image
|
||||
|
||||
from openerp import http
|
||||
|
@ -35,21 +36,16 @@ class EscposDriver(Thread):
|
|||
self.queue = Queue()
|
||||
self.status = {'status':'connecting', 'messages':[]}
|
||||
|
||||
self.supported_printers = [
|
||||
{ 'vendor' : 0x04b8, 'product' : 0x0e03, 'name' : 'Epson TM-T20' },
|
||||
{ 'vendor' : 0x04b8, 'product' : 0x0202, 'name' : 'Epson TM-T70' },
|
||||
]
|
||||
|
||||
def connected_usb_devices(self,devices):
|
||||
def connected_usb_devices(self):
|
||||
connected = []
|
||||
for device in devices:
|
||||
for device in supported_devices.device_list:
|
||||
if usb.core.find(idVendor=device['vendor'], idProduct=device['product']) != None:
|
||||
connected.append(device)
|
||||
return connected
|
||||
|
||||
def get_escpos_printer(self):
|
||||
try:
|
||||
printers = self.connected_usb_devices(self.supported_printers)
|
||||
printers = self.connected_usb_devices()
|
||||
if len(printers) > 0:
|
||||
self.set_status('connected','Connected to '+printers[0]['name'])
|
||||
return escpos.printer.Usb(printers[0]['vendor'], printers[0]['product'])
|
||||
|
|
|
@ -1 +1 @@
|
|||
__all__ = ["constants","escpos","exceptions","printer"]
|
||||
__all__ = ["constants","escpos","exceptions","printer","supported_devices"]
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# This is a list of esc/pos compatible usb printers. The vendor and product ids can be found by
|
||||
# typing lsusb in a linux terminal, this will give you the ids in the form ID VENDOR:PRODUCT
|
||||
|
||||
device_list = [
|
||||
{ 'vendor' : 0x04b8, 'product' : 0x0e03, 'name' : 'Epson TM-T20' },
|
||||
{ 'vendor' : 0x04b8, 'product' : 0x0202, 'name' : 'Epson TM-T70' },
|
||||
]
|
||||
|
Loading…
Reference in New Issue