Remove semicolons, syntax enhancements, remove unused constant.

This commit is contained in:
csoft2k 2017-07-22 21:38:07 +02:00
parent 2d8a774b9f
commit 05cd028ac6
2 changed files with 16 additions and 12 deletions

View File

@ -252,5 +252,4 @@ S_RASTER_Q = _PRINT_RASTER_IMG(b'\x03') # Set raster image quadruple
# Status Command
RT_STATUS_ONLINE = DLE + EOT + b'\x01';
RT_STATUS_OFFLINECAUSE = DLE + EOT + b'\x02';
RT_MASK_ONLINE = 8;

View File

@ -35,7 +35,7 @@ from .constants import CD_KICK_DEC_SEQUENCE, CD_KICK_5, CD_KICK_2, PAPER_FULL_CU
from .constants import HW_RESET, HW_SELECT, HW_INIT
from .constants import CTL_VT, CTL_HT, CTL_CR, CTL_FF, CTL_LF, CTL_SET_HT, PANEL_BUTTON_OFF, PANEL_BUTTON_ON
from .constants import TXT_STYLE
from .constants import RT_STATUS_ONLINE, RT_STATUS_OFFLINECAUSE, RT_MASK_ONLINE
from .constants import RT_STATUS_ONLINE, RT_MASK_ONLINE
from .exceptions import BarcodeTypeError, BarcodeSizeError, TabPosError
from .exceptions import CashDrawerError, SetVariableError, BarcodeCodeError
@ -80,7 +80,10 @@ class Escpos(object):
pass
def _read(self, msg):
raise NotImplementedError();
""" Returns a NotImplementedError if the instance of the class doesn't override this method.
:raises NotImplementedError
"""
raise NotImplementedError()
def image(self, img_source, high_density_vertical=True, high_density_horizontal=True, impl="bitImageRaster",
fragment_height=960):
@ -738,18 +741,20 @@ class Escpos(object):
else:
self._raw(PANEL_BUTTON_OFF)
def queryStatus(self):
def query_status(self):
""" Queries the printer for its status, and returns an array of integers containing it.
:rtype: array(integer)"""
self._raw(RT_STATUS_ONLINE)
time.sleep(1)
status = self._read();
if (len(status) > 0):
return status;
else:
return [8];
status = self._read()
return status or [8]
def is_online(self):
""" Queries the printer its online status.
When online, returns True; False otherwise.
:rtype: bool: True if online, False if offline."""
return (self.query_status()[0] & RT_MASK_ONLINE) == 0
def isOnline(self):
status = self.queryStatus()[0];
return ((status & RT_MASK_ONLINE) == 0);
class EscposIO(object):
"""ESC/POS Printer IO object