From a300fb8eb20fbd0ee2a9c1df1e850b18ae2af1a3 Mon Sep 17 00:00:00 2001 From: Andrew Dalgleish Date: Fri, 29 Jun 2012 01:23:52 +1000 Subject: [PATCH] Add online check to printcore send() similar to send_now() --- printcore.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/printcore.py b/printcore.py index e1c7de0..f0a2ccb 100755 --- a/printcore.py +++ b/printcore.py @@ -198,20 +198,23 @@ class printcore(): """Adds a command to the checksummed main command queue if printing, or sends the command immediately if not printing """ - if(self.printing): - self.mainqueue+=[command] + if(self.online): + if(self.printing): + self.mainqueue+=[command] + else: + while not self.clear: + time.sleep(0.001) + if (wait == 0 and self.wait > 0): + wait = self.wait + if (wait > 0) + self.clear=False + self._send(command,self.lineno,True) + self.lineno+=1 + while ((wait > 0) and not self.clear): + time.sleep(0.001) + wait-=1 else: - while not self.clear: - time.sleep(0.001) - if (wait == 0 and self.wait > 0): - wait = self.wait - if (wait > 0) - self.clear=False - self._send(command,self.lineno,True) - self.lineno+=1 - while ((wait > 0) and not self.clear): - time.sleep(0.001) - wait-=1 + print "Not connected to printer." def send_now(self,command,wait=0):