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
585bad62
Commit
585bad62
authored
Oct 10, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log errors using errorcb in printcore
parent
8002d268
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
21 deletions
+25
-21
printcore.py
printrun/printcore.py
+25
-21
No files found.
printrun/printcore.py
View file @
585bad62
...
...
@@ -107,6 +107,13 @@ class printcore():
self
.
z_feedrate
=
None
self
.
pronterface
=
None
def
logError
(
self
,
error
):
if
self
.
errorcb
:
try
:
self
.
errorcb
(
error
)
except
:
pass
else
:
logging
.
error
(
error
)
@
locked
def
disconnect
(
self
):
"""Disconnects from printer and pauses the print
...
...
@@ -165,7 +172,7 @@ class printcore():
self
.
printer_tcp
.
settimeout
(
self
.
timeout
)
self
.
printer
=
self
.
printer_tcp
.
makefile
()
except
socket
.
error
as
e
:
logging
.
e
rror
(
_
(
"Could not connect to
%
s:
%
s:"
)
%
(
hostname
,
port
)
+
self
.
logE
rror
(
_
(
"Could not connect to
%
s:
%
s:"
)
%
(
hostname
,
port
)
+
"
\n
"
+
_
(
"Socket error
%
s:"
)
%
e
.
errno
+
"
\n
"
+
e
.
strerror
)
self
.
printer
=
None
...
...
@@ -179,7 +186,7 @@ class printcore():
baudrate
=
self
.
baud
,
timeout
=
0.25
)
except
SerialException
as
e
:
logging
.
e
rror
(
_
(
"Could not connect to
%
s at baudrate
%
s:"
)
%
(
self
.
port
,
self
.
baud
)
+
self
.
logE
rror
(
_
(
"Could not connect to
%
s at baudrate
%
s:"
)
%
(
self
.
port
,
self
.
baud
)
+
"
\n
"
+
_
(
"Serial error:
%
s"
)
%
e
)
self
.
printer
=
None
return
...
...
@@ -214,21 +221,21 @@ class printcore():
return
line
except
SelectError
as
e
:
if
'Bad file descriptor'
in
e
.
args
[
1
]:
logging
.
e
rror
(
_
(
u"Can't read from printer (disconnected?) (SelectError {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
self
.
logE
rror
(
_
(
u"Can't read from printer (disconnected?) (SelectError {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
return
None
else
:
logging
.
e
rror
(
_
(
u"SelectError ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
self
.
logE
rror
(
_
(
u"SelectError ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
raise
except
SerialException
as
e
:
logging
.
e
rror
(
_
(
u"Can't read from printer (disconnected?) (SerialException): {0}"
)
.
format
(
decode_utf8
(
str
(
e
))))
self
.
logE
rror
(
_
(
u"Can't read from printer (disconnected?) (SerialException): {0}"
)
.
format
(
decode_utf8
(
str
(
e
))))
return
None
except
socket
.
error
as
e
:
logging
.
e
rror
(
_
(
u"Can't read from printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
self
.
logE
rror
(
_
(
u"Can't read from printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
return
None
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EAGAIN
:
# Not a real error, no data was available
return
""
logging
.
e
rror
(
_
(
u"Can't read from printer (disconnected?) (OS Error {0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
))
self
.
logE
rror
(
_
(
u"Can't read from printer (disconnected?) (OS Error {0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
))
return
None
def
_listen_can_continue
(
self
):
...
...
@@ -285,10 +292,7 @@ class printcore():
try
:
self
.
tempcb
(
line
)
except
:
pass
elif
line
.
startswith
(
'Error'
):
if
self
.
errorcb
:
#callback for errors
try
:
self
.
errorcb
(
line
)
except
:
pass
self
.
logError
(
line
)
# Teststrings for resend parsing # Firmware exp. result
# line="rs N2 Expected checksum 67" # Teacup 2
if
line
.
lower
()
.
startswith
(
"resend"
)
or
line
.
startswith
(
"rs"
):
...
...
@@ -434,7 +438,7 @@ class printcore():
else
:
self
.
priqueue
.
put_nowait
(
command
)
else
:
logging
.
e
rror
(
_
(
"Not connected to printer."
))
self
.
logE
rror
(
_
(
"Not connected to printer."
))
def
send_now
(
self
,
command
,
wait
=
0
):
"""Sends a command to the printer ahead of the command queue, without a
...
...
@@ -442,7 +446,7 @@ class printcore():
if
self
.
online
:
self
.
priqueue
.
put_nowait
(
command
)
else
:
logging
.
e
rror
(
_
(
"Not connected to printer."
))
self
.
logE
rror
(
_
(
"Not connected to printer."
))
def
_print
(
self
,
resuming
=
False
):
self
.
_stop_sender
()
...
...
@@ -451,7 +455,7 @@ class printcore():
#callback for printing started
try
:
self
.
startcb
(
resuming
)
except
:
logging
.
e
rror
(
_
(
"Print start callback failed with:"
)
+
self
.
logE
rror
(
_
(
"Print start callback failed with:"
)
+
"
\n
"
+
traceback
.
format_exc
())
while
self
.
printing
and
self
.
printer
and
self
.
online
:
self
.
_sendnext
()
...
...
@@ -462,10 +466,10 @@ class printcore():
#callback for printing done
try
:
self
.
endcb
()
except
:
logging
.
e
rror
(
_
(
"Print end callback failed with:"
)
+
self
.
logE
rror
(
_
(
"Print end callback failed with:"
)
+
"
\n
"
+
traceback
.
format_exc
())
except
:
logging
.
e
rror
(
_
(
"Print thread died due to the following error:"
)
+
self
.
logE
rror
(
_
(
"Print thread died due to the following error:"
)
+
"
\n
"
+
traceback
.
format_exc
())
finally
:
self
.
print_thread
=
None
...
...
@@ -553,8 +557,8 @@ class printcore():
# run the command through the analyzer
try
:
self
.
analyzer
.
Analyze
(
command
)
except
:
logging
.
error
(
_
(
"Warning: c
ould not analyze command
%
s:"
)
%
command
+
"
\n
"
+
traceback
.
format_exc
())
logging
.
warning
(
_
(
"C
ould not analyze command
%
s:"
)
%
command
+
"
\n
"
+
traceback
.
format_exc
())
if
self
.
loud
:
logging
.
info
(
"SENT:
%
s"
%
command
)
if
self
.
sendcb
:
...
...
@@ -565,11 +569,11 @@ class printcore():
if
self
.
printer_tcp
:
self
.
printer
.
flush
()
self
.
writefailures
=
0
except
socket
.
error
as
e
:
logging
.
e
rror
(
_
(
u"Can't write to printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
self
.
logE
rror
(
_
(
u"Can't write to printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
self
.
writefailures
+=
1
except
SerialException
as
e
:
logging
.
e
rror
(
_
(
u"Can't write to printer (disconnected?) (SerialException): {0}"
)
.
format
(
decode_utf8
(
str
(
e
))))
self
.
logE
rror
(
_
(
u"Can't write to printer (disconnected?) (SerialException): {0}"
)
.
format
(
decode_utf8
(
str
(
e
))))
self
.
writefailures
+=
1
except
RuntimeError
as
e
:
logging
.
e
rror
(
_
(
u"Socket connection broken, disconnected. ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
self
.
logE
rror
(
_
(
u"Socket connection broken, disconnected. ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)))
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