Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kliment/Printrun.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKliment Yanev <kliment.yanev@gmail.com>2013-05-27 20:35:58 +0400
committerKliment Yanev <kliment.yanev@gmail.com>2013-05-27 20:35:58 +0400
commit1bad79fd97e794bb67b137c7f90e446b73c715b3 (patch)
treeb243e40875dfcc0ceea4fe9e8e0181d5851fd203 /printcore.py
parentb99aa3a787b66a96d10ffd699562bb679ffe8ad8 (diff)
Made IP connection errors emit the same kind of error as serial connection errors.
Diffstat (limited to 'printcore.py')
-rwxr-xr-xprintcore.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/printcore.py b/printcore.py
index 47c4b9d..c3a8521 100755
--- a/printcore.py
+++ b/printcore.py
@@ -451,21 +451,22 @@ class printcore():
if self.sendcb:
try: self.sendcb(command)
except: pass
-
+ try:
# If the printer is connected via Ethernet, use send
- if is_socket(self.printer):
- msg = str(command+"\n")
- totalsent = 0
- while totalsent < len(msg):
- sent = self.printer.send(msg[totalsent:])
- if sent == 0:
- raise RuntimeError("socket connection broken")
- totalsent = totalsent + sent
- else:
- try:
+ if is_socket(self.printer):
+ msg = str(command+"\n")
+ totalsent = 0
+ while totalsent < len(msg):
+ sent = self.printer.send(msg[totalsent:])
+ if sent == 0:
+ raise RuntimeError("socket connection broken")
+ totalsent = totalsent + sent
+ else:
self.printer.write(str(command+"\n"))
- except SerialException, e:
- print "Can't write to printer (disconnected?)."
+ except SerialException, e:
+ print "Can't write to printer (disconnected?)."
+ except RuntimeError, e:
+ print "Socket connection broken, disconnected."
if __name__ == '__main__':
baud = 115200