Commit 26c17440 authored by kliment's avatar kliment

Continue on exceptions in callback functions

parent ea35ea0e
...@@ -80,25 +80,36 @@ class printcore(): ...@@ -80,25 +80,36 @@ class printcore():
if(len(line)>1): if(len(line)>1):
self.log+=[line] self.log+=[line]
if self.recvcb is not None: if self.recvcb is not None:
try:
self.recvcb(line) self.recvcb(line)
except:
pass
if self.loud: if self.loud:
print "RECV: ",line.rstrip() print "RECV: ",line.rstrip()
if(line.startswith('start') or line.startswith('ok')): if(line.startswith('start') or line.startswith('ok')):
self.clear=True self.clear=True
if(line.startswith('start') or line.startswith('ok') or "T:" in line): 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: if (not self.online or line.startswith('start')) and self.onlinecb is not None:
try:
self.onlinecb() self.onlinecb()
except:
pass
self.online=True self.online=True
if(line.startswith('ok')): if(line.startswith('ok')):
#self.resendfrom=-1 #self.resendfrom=-1
#put temp handling here #put temp handling here
if "T:" in line and self.tempcb is not None: if "T:" in line and self.tempcb is not None:
try:
self.tempcb(line) self.tempcb(line)
except:
pass
#callback for temp, status, whatever #callback for temp, status, whatever
elif(line.startswith('Error')): elif(line.startswith('Error')):
if self.errorcb is not None: if self.errorcb is not None:
try:
self.errorcb(line) self.errorcb(line)
except:
pass
#callback for errors #callback for errors
pass pass
if "resend" in line.lower() or "rs" in line: if "resend" in line.lower() or "rs" in line:
...@@ -172,11 +183,17 @@ class printcore(): ...@@ -172,11 +183,17 @@ class printcore():
def _print(self): def _print(self):
#callback for printing started #callback for printing started
if self.startcb is not None: if self.startcb is not None:
try:
self.startcb() self.startcb()
except:
pass
while(self.printing and self.printer and self.online): while(self.printing and self.printer and self.online):
self._sendnext() self._sendnext()
if self.endcb is not None: if self.endcb is not None:
try:
self.endcb() self.endcb()
except:
pass
#callback for printing done #callback for printing done
def _sendnext(self): def _sendnext(self):
...@@ -225,7 +242,10 @@ class printcore(): ...@@ -225,7 +242,10 @@ class printcore():
if self.loud: if self.loud:
print "SENT: ",command print "SENT: ",command
if self.sendcb is not None: if self.sendcb is not None:
try:
self.sendcb(command) self.sendcb(command)
except:
pass
self.printer.write(command+"\n") self.printer.write(command+"\n")
if __name__ == '__main__': 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