Commit 26c17440 authored by kliment's avatar kliment

Continue on exceptions in callback functions

parent ea35ea0e
......@@ -80,25 +80,36 @@ class printcore():
if(len(line)>1):
self.log+=[line]
if self.recvcb is not None:
try:
self.recvcb(line)
except:
pass
if self.loud:
print "RECV: ",line.rstrip()
if(line.startswith('start') or line.startswith('ok')):
self.clear=True
if(line.startswith('start') or line.startswith('ok') or "T:" in line):
if (not self.online or line.startswith('start')) and self.onlinecb is not None:
try:
self.onlinecb()
except:
pass
self.online=True
if(line.startswith('ok')):
#self.resendfrom=-1
#put temp handling here
if "T:" in line and self.tempcb is not None:
try:
self.tempcb(line)
except:
pass
#callback for temp, status, whatever
elif(line.startswith('Error')):
if self.errorcb is not None:
try:
self.errorcb(line)
except:
pass
#callback for errors
pass
if "resend" in line.lower() or "rs" in line:
......@@ -172,11 +183,17 @@ class printcore():
def _print(self):
#callback for printing started
if self.startcb is not None:
try:
self.startcb()
except:
pass
while(self.printing and self.printer and self.online):
self._sendnext()
if self.endcb is not None:
try:
self.endcb()
except:
pass
#callback for printing done
def _sendnext(self):
......@@ -225,7 +242,10 @@ class printcore():
if self.loud:
print "SENT: ",command
if self.sendcb is not None:
try:
self.sendcb(command)
except:
pass
self.printer.write(command+"\n")
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment