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
016cb3e2
Commit
016cb3e2
authored
Aug 30, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decode utf8 errors in printcore
parent
f2d6dd3c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
printcore.py
printrun/printcore.py
+9
-9
No files found.
printrun/printcore.py
View file @
016cb3e2
...
@@ -32,7 +32,7 @@ import re
...
@@ -32,7 +32,7 @@ import re
from
functools
import
wraps
from
functools
import
wraps
from
collections
import
deque
from
collections
import
deque
from
printrun.GCodeAnalyzer
import
GCodeAnalyzer
from
printrun.GCodeAnalyzer
import
GCodeAnalyzer
from
printrun.printrun_utils
import
install_locale
from
printrun.printrun_utils
import
install_locale
,
decode_utf8
install_locale
(
'pronterface'
)
install_locale
(
'pronterface'
)
def
locked
(
f
):
def
locked
(
f
):
...
@@ -212,21 +212,21 @@ class printcore():
...
@@ -212,21 +212,21 @@ class printcore():
return
line
return
line
except
SelectError
as
e
:
except
SelectError
as
e
:
if
'Bad file descriptor'
in
e
.
args
[
1
]:
if
'Bad file descriptor'
in
e
.
args
[
1
]:
print
_
(
"Can't read from printer (disconnected?) (SelectError {0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
)
print
_
(
u"Can't read from printer (disconnected?) (SelectError {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)
)
return
None
return
None
else
:
else
:
print
_
(
"SelectError ({0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
)
print
_
(
u"SelectError ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)
)
raise
raise
except
SerialException
as
e
:
except
SerialException
as
e
:
print
_
(
"Can't read from printer (disconnected?) (SerialException): {0}"
)
.
format
(
e
)
print
_
(
u"Can't read from printer (disconnected?) (SerialException): {0}"
)
.
format
(
decode_utf8
(
str
(
e
))
)
return
None
return
None
except
socket
.
error
as
e
:
except
socket
.
error
as
e
:
print
_
(
"Can't read from printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
)
print
_
(
u"Can't read from printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)
)
return
None
return
None
except
OSError
as
e
:
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EAGAIN
:
# Not a real error, no data was available
if
e
.
errno
==
errno
.
EAGAIN
:
# Not a real error, no data was available
return
""
return
""
print
_
(
"Can't read from printer (disconnected?) (OS Error {0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
)
print
_
(
u
"Can't read from printer (disconnected?) (OS Error {0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
)
return
None
return
None
def
_listen_can_continue
(
self
):
def
_listen_can_continue
(
self
):
...
@@ -563,11 +563,11 @@ class printcore():
...
@@ -563,11 +563,11 @@ class printcore():
if
self
.
printer_tcp
:
self
.
printer
.
flush
()
if
self
.
printer_tcp
:
self
.
printer
.
flush
()
self
.
writefailures
=
0
self
.
writefailures
=
0
except
socket
.
error
as
e
:
except
socket
.
error
as
e
:
print
_
(
"Can't write to printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
)
print
_
(
u"Can't write to printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)
)
self
.
writefailures
+=
1
self
.
writefailures
+=
1
except
SerialException
as
e
:
except
SerialException
as
e
:
print
_
(
"Can't write to printer (disconnected?) (SerialException): {0}"
)
.
format
(
e
)
print
_
(
u"Can't write to printer (disconnected?) (SerialException): {0}"
)
.
format
(
decode_utf8
(
str
(
e
))
)
self
.
writefailures
+=
1
self
.
writefailures
+=
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
_
(
"Socket connection broken, disconnected. ({0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
)
print
_
(
u"Socket connection broken, disconnected. ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)
)
self
.
writefailures
+=
1
self
.
writefailures
+=
1
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