Compare commits
3 Commits
65e4a2ad9c
...
multi-prin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09e588c3ff | ||
|
|
0699775d35 | ||
|
|
7d19098b61 |
@@ -123,6 +123,8 @@ limiter = Limiter(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
app.logger.info("🖶 Welcome to LittlePrynter !")
|
||||||
|
|
||||||
# General routes
|
# General routes
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
@limiter.limit("1/second", override_defaults=False)
|
@limiter.limit("1/second", override_defaults=False)
|
||||||
|
|||||||
@@ -322,22 +322,29 @@ class EscPosPrinter(Printer):
|
|||||||
self.app.logger.info("Did a cut")
|
self.app.logger.info("Did a cut")
|
||||||
self.ready = True
|
self.ready = True
|
||||||
|
|
||||||
def _state(self):
|
def _state(self) -> bool:
|
||||||
self.app.logger.debug("Online : %s " , self.printer.is_online())
|
has_paper = self._has_paper()
|
||||||
self.app.logger.debug("Has paper : %s " , self._has_paper())
|
is_ready = self.ready
|
||||||
self.app.logger.debug("Ready : %s " , self.ready)
|
|
||||||
return self.printer.is_online() and self.ready and self._has_paper()
|
self.app.logger.debug("Has paper : %s " , has_paper )
|
||||||
|
self.app.logger.debug("Ready : %s " , is_ready )
|
||||||
|
|
||||||
|
return is_ready and has_paper # and is_online
|
||||||
|
|
||||||
def print_task(self, task_type, data):
|
def print_task(self, task_type, data):
|
||||||
"""Execute actual print based on task type"""
|
"""Execute actual print based on task type"""
|
||||||
|
|
||||||
|
|
||||||
with self._lock:
|
with self._lock:
|
||||||
self.app.logger.debug("Acquired lock to start print")
|
self.app.logger.debug("Acquired lock to start print")
|
||||||
|
|
||||||
while not self._state():
|
i_m_ready = self._state()
|
||||||
self.app.logger.debug("Waiting for the printer to become ready..")
|
while not i_m_ready:
|
||||||
|
self.app.logger.debug("Waiting for the printer to become ready, current state %s ", str(i_m_ready))
|
||||||
|
i_m_ready = self._state()
|
||||||
time.sleep(0.3)
|
time.sleep(0.3)
|
||||||
|
|
||||||
self.app.logger.debug("Checked state to start printing %s", self._state())
|
self.app.logger.debug("Checked state to start printing : %s", self._state())
|
||||||
self.ready = False
|
self.ready = False
|
||||||
try:
|
try:
|
||||||
self.app.logger.debug("Checking task type")
|
self.app.logger.debug("Checking task type")
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class Raspberry:
|
|||||||
self.app.logger.warning(
|
self.app.logger.warning(
|
||||||
"Couldn't get sufficient hardware information from /proc/cpuinfo"
|
"Couldn't get sufficient hardware information from /proc/cpuinfo"
|
||||||
)
|
)
|
||||||
self.app.logger.error("Unable to determine if we are on a Raspberry Pi.")
|
self.app.logger.warning("Unable to determine if we are on a Raspberry Pi.")
|
||||||
return False
|
return False
|
||||||
except IOError:
|
except IOError:
|
||||||
self.app.logger.error("Unable to open `/proc/cpuinfo`.")
|
self.app.logger.error("Unable to open `/proc/cpuinfo`.")
|
||||||
|
|||||||
Reference in New Issue
Block a user