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
8fb1bb0b
Commit
8fb1bb0b
authored
Sep 03, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve printcore logging
parent
22fa509f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
printcore.py
printrun/printcore.py
+13
-14
No files found.
printrun/printcore.py
View file @
8fb1bb0b
...
@@ -22,7 +22,6 @@ from select import error as SelectError
...
@@ -22,7 +22,6 @@ from select import error as SelectError
from
threading
import
Thread
,
Lock
from
threading
import
Thread
,
Lock
from
Queue
import
Queue
,
Empty
as
QueueEmpty
from
Queue
import
Queue
,
Empty
as
QueueEmpty
import
time
import
time
import
sys
import
platform
import
platform
import
os
import
os
import
traceback
import
traceback
...
@@ -170,7 +169,7 @@ class printcore():
...
@@ -170,7 +169,7 @@ class printcore():
self
.
printer
=
None
self
.
printer
=
None
self
.
printer_tcp
=
None
self
.
printer_tcp
=
None
logging
.
error
(
_
(
"Socket error
%
s:"
)
%
e
.
errno
,)
logging
.
error
(
_
(
"Socket error
%
s:"
)
%
e
.
errno
,)
print
e
.
strerror
logging
.
error
(
e
.
strerror
)
return
return
else
:
else
:
disable_hup
(
self
.
port
)
disable_hup
(
self
.
port
)
...
@@ -211,7 +210,7 @@ class printcore():
...
@@ -211,7 +210,7 @@ class printcore():
if
self
.
recvcb
:
if
self
.
recvcb
:
try
:
self
.
recvcb
(
line
)
try
:
self
.
recvcb
(
line
)
except
:
pass
except
:
pass
if
self
.
loud
:
print
"RECV:"
,
line
.
rstrip
(
)
if
self
.
loud
:
logging
.
info
(
"RECV:
%
s"
%
line
.
rstrip
()
)
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
]:
...
@@ -435,7 +434,7 @@ class printcore():
...
@@ -435,7 +434,7 @@ class printcore():
else
:
else
:
self
.
priqueue
.
put_nowait
(
command
)
self
.
priqueue
.
put_nowait
(
command
)
else
:
else
:
print
"Not connected to printer."
logging
.
error
(
_
(
"Not connected to printer."
))
def
send_now
(
self
,
command
,
wait
=
0
):
def
send_now
(
self
,
command
,
wait
=
0
):
"""Sends a command to the printer ahead of the command queue, without a
"""Sends a command to the printer ahead of the command queue, without a
...
@@ -443,7 +442,7 @@ class printcore():
...
@@ -443,7 +442,7 @@ class printcore():
if
self
.
online
:
if
self
.
online
:
self
.
priqueue
.
put_nowait
(
command
)
self
.
priqueue
.
put_nowait
(
command
)
else
:
else
:
print
"Not connected to printer."
logging
.
error
(
_
(
"Not connected to printer."
))
def
_print
(
self
,
resuming
=
False
):
def
_print
(
self
,
resuming
=
False
):
self
.
_stop_sender
()
self
.
_stop_sender
()
...
@@ -452,8 +451,8 @@ class printcore():
...
@@ -452,8 +451,8 @@ class printcore():
#callback for printing started
#callback for printing started
try
:
self
.
startcb
(
resuming
)
try
:
self
.
startcb
(
resuming
)
except
:
except
:
print
"Print start callback failed with:"
logging
.
error
(
_
(
"Print start callback failed with:"
)
+
traceback
.
print_exc
(
file
=
sys
.
stdout
)
"
\n
"
+
traceback
.
format_exc
()
)
while
self
.
printing
and
self
.
printer
and
self
.
online
:
while
self
.
printing
and
self
.
printer
and
self
.
online
:
self
.
_sendnext
()
self
.
_sendnext
()
self
.
sentlines
=
{}
self
.
sentlines
=
{}
...
@@ -463,11 +462,11 @@ class printcore():
...
@@ -463,11 +462,11 @@ class printcore():
#callback for printing done
#callback for printing done
try
:
self
.
endcb
()
try
:
self
.
endcb
()
except
:
except
:
print
"Print end callback failed with:"
logging
.
error
(
_
(
"Print end callback failed with:"
)
+
traceback
.
print_exc
(
file
=
sys
.
stdout
)
"
\n
"
+
traceback
.
format_exc
()
)
except
:
except
:
print
"Print thread died due to the following error:"
logging
.
error
(
_
(
"Print thread died due to the following error:"
)
+
traceback
.
print_exc
(
file
=
sys
.
stdout
)
"
\n
"
+
traceback
.
format_exc
()
)
finally
:
finally
:
self
.
print_thread
=
None
self
.
print_thread
=
None
self
.
_start_sender
()
self
.
_start_sender
()
...
@@ -554,10 +553,10 @@ class printcore():
...
@@ -554,10 +553,10 @@ class printcore():
# run the command through the analyzer
# run the command through the analyzer
try
:
self
.
analyzer
.
Analyze
(
command
)
try
:
self
.
analyzer
.
Analyze
(
command
)
except
:
except
:
print
"Warning: could not analyze command
%
s:"
%
command
logging
.
error
(
_
(
"Warning: could not analyze command
%
s:"
)
%
command
+
traceback
.
print_exc
(
file
=
sys
.
stdout
)
"
\n
"
+
traceback
.
format_exc
()
)
if
self
.
loud
:
if
self
.
loud
:
print
"SENT:"
,
command
logging
.
info
(
"SENT:
%
s"
%
command
)
if
self
.
sendcb
:
if
self
.
sendcb
:
try
:
self
.
sendcb
(
command
)
try
:
self
.
sendcb
(
command
)
except
:
pass
except
:
pass
...
...
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