Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
53af87bf
Commit
53af87bf
authored
May 30, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Harden against network errors
parent
9632556c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
printcore.py
printcore.py
+8
-2
No files found.
printcore.py
View file @
53af87bf
...
@@ -89,7 +89,10 @@ class printcore():
...
@@ -89,7 +89,10 @@ class printcore():
self
.
stop_read_thread
=
True
self
.
stop_read_thread
=
True
self
.
read_thread
.
join
()
self
.
read_thread
.
join
()
self
.
read_thread
=
None
self
.
read_thread
=
None
try
:
self
.
printer
.
close
()
self
.
printer
.
close
()
except
socket
.
error
:
pass
self
.
printer
=
None
self
.
printer
=
None
self
.
online
=
False
self
.
online
=
False
self
.
printing
=
False
self
.
printing
=
False
...
@@ -156,7 +159,7 @@ class printcore():
...
@@ -156,7 +159,7 @@ class printcore():
try
:
try
:
line
=
self
.
printer
.
readline
()
line
=
self
.
printer
.
readline
()
if
self
.
printer_tcp
and
not
line
:
if
self
.
printer_tcp
and
not
line
:
raise
OSError
(
"Read EOF from socket"
)
raise
OSError
(
-
1
,
"Read EOF from socket"
)
except
socket
.
timeout
:
except
socket
.
timeout
:
return
""
return
""
...
@@ -177,6 +180,9 @@ class printcore():
...
@@ -177,6 +180,9 @@ class printcore():
except
SerialException
as
e
:
except
SerialException
as
e
:
print
"Can't read from printer (disconnected?) (SerialException {0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
print
"Can't read from printer (disconnected?) (SerialException {0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
return
None
return
None
except
socket
.
error
as
e
:
print
"Can't read from printer (disconnected?) (Socket error {0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
return
None
except
OSError
as
e
:
except
OSError
as
e
:
print
"Can't read from printer (disconnected?) (OS Error {0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
print
"Can't read from printer (disconnected?) (OS Error {0}): {1}"
.
format
(
e
.
errno
,
e
.
strerror
)
return
None
return
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment