Merge branch 'development' into update/update_submodule_configuration

This commit is contained in:
Patrick Kanzler 2018-05-13 17:20:15 +02:00 committed by GitHub
commit 073742a73b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 13 deletions

View File

@ -47,7 +47,7 @@ PROFILES = CAPABILITIES['profiles']
class NotSupported(Exception): class NotSupported(Exception):
"""Raised if a requested feature is not suppored by the """Raised if a requested feature is not supported by the
printer profile. printer profile.
""" """
pass pass
@ -90,7 +90,7 @@ class BaseProfile(object):
return self.features.get(feature) return self.features.get(feature)
def get_code_pages(self): def get_code_pages(self):
"""Return the support code pages as a {name: index} dict. """Return the support code pages as a ``{name: index}`` dict.
""" """
return {v: k for k, v in self.codePages.items()} return {v: k for k, v in self.codePages.items()}

View File

@ -828,30 +828,41 @@ class Escpos(object):
self._raw(PANEL_BUTTON_OFF) self._raw(PANEL_BUTTON_OFF)
def query_status(self, mode): def query_status(self, mode):
""" Queries the printer for its status, and returns an array of integers containing it. """
Queries the printer for its status, and returns an array of integers containing it.
:param mode: Integer that sets the status mode queried to the printer. :param mode: Integer that sets the status mode queried to the printer.
RT_STATUS_ONLINE: Printer status. - RT_STATUS_ONLINE: Printer status.
RT_STATUS_PAPER: Paper sensor. - RT_STATUS_PAPER: Paper sensor.
:rtype: array(integer)""" :rtype: array(integer)
"""
self._raw(mode) self._raw(mode)
time.sleep(1) time.sleep(1)
status = self._read() status = self._read()
return status return status
def is_online(self): def is_online(self):
""" Queries the printer its online status. """
When online, returns True; False otherwise. Queries the online status of the printer.
:rtype: bool: True if online, False if offline."""
:returns: When online, returns ``True``; ``False`` otherwise.
:rtype: bool
"""
status = self.query_status(RT_STATUS_ONLINE) status = self.query_status(RT_STATUS_ONLINE)
if len(status) == 0: if len(status) == 0:
return False return False
return not (status & RT_MASK_ONLINE) return not (status[0] & RT_MASK_ONLINE)
def paper_status(self): def paper_status(self):
""" Queries the printer its paper status. """
Queries the paper status of the printer.
Returns 2 if there is plenty of paper, 1 if the paper has arrived to Returns 2 if there is plenty of paper, 1 if the paper has arrived to
the near-end sensor and 0 if there is no paper. the near-end sensor and 0 if there is no paper.
:rtype: int: 2: Paper is adequate. 1: Paper ending. 0: No paper."""
:returns: 2: Paper is adequate. 1: Paper ending. 0: No paper.
:rtype: int
"""
status = self.query_status(RT_STATUS_PAPER) status = self.query_status(RT_STATUS_PAPER)
if len(status) == 0: if len(status) == 0:
return 2 return 2
@ -867,7 +878,7 @@ class EscposIO(object):
"""ESC/POS Printer IO object """ESC/POS Printer IO object
Allows the class to be used together with the `with`-statement. You have to define a printer instance Allows the class to be used together with the `with`-statement. You have to define a printer instance
and assign it to the EsposIO-class. and assign it to the EscposIO class.
This example explains the usage: This example explains the usage:
.. code-block:: Python .. code-block:: Python