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
22fa509f
Commit
22fa509f
authored
Sep 02, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transition printcore to use logging
parent
20573ab6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
printcore.py
printrun/printcore.py
+12
-12
No files found.
printrun/printcore.py
View file @
22fa509f
...
@@ -166,10 +166,10 @@ class printcore():
...
@@ -166,10 +166,10 @@ class printcore():
self
.
printer_tcp
.
settimeout
(
self
.
timeout
)
self
.
printer_tcp
.
settimeout
(
self
.
timeout
)
self
.
printer
=
self
.
printer_tcp
.
makefile
()
self
.
printer
=
self
.
printer_tcp
.
makefile
()
except
socket
.
error
as
e
:
except
socket
.
error
as
e
:
print
_
(
"Could not connect to
%
s:
%
s:"
)
%
(
hostname
,
port
)
logging
.
error
(
_
(
"Could not connect to
%
s:
%
s:"
)
%
(
hostname
,
port
)
)
self
.
printer
=
None
self
.
printer
=
None
self
.
printer_tcp
=
None
self
.
printer_tcp
=
None
print
_
(
"Socket error
%
s:"
)
%
e
.
errno
,
logging
.
error
(
_
(
"Socket error
%
s:"
)
%
e
.
errno
,)
print
e
.
strerror
print
e
.
strerror
return
return
else
:
else
:
...
@@ -180,9 +180,9 @@ class printcore():
...
@@ -180,9 +180,9 @@ class printcore():
baudrate
=
self
.
baud
,
baudrate
=
self
.
baud
,
timeout
=
0.25
)
timeout
=
0.25
)
except
SerialException
as
e
:
except
SerialException
as
e
:
print
_
(
"Could not connect to
%
s at baudrate
%
s:"
)
%
(
self
.
port
,
self
.
baud
)
logging
.
error
(
_
(
"Could not connect to
%
s at baudrate
%
s:"
)
%
(
self
.
port
,
self
.
baud
)
)
self
.
printer
=
None
self
.
printer
=
None
print
_
(
"Serial error:
%
s"
)
%
e
logging
.
error
(
_
(
"Serial error:
%
s"
)
%
e
)
return
return
self
.
stop_read_thread
=
False
self
.
stop_read_thread
=
False
self
.
read_thread
=
Thread
(
target
=
self
.
_listen
)
self
.
read_thread
=
Thread
(
target
=
self
.
_listen
)
...
@@ -215,21 +215,21 @@ class printcore():
...
@@ -215,21 +215,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
_
(
u"Can't read from printer (disconnected?) (SelectError {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
))
logging
.
error
(
_
(
u"Can't read from printer (disconnected?) (SelectError {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)
))
return
None
return
None
else
:
else
:
print
_
(
u"SelectError ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
))
logging
.
error
(
_
(
u"SelectError ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
)
))
raise
raise
except
SerialException
as
e
:
except
SerialException
as
e
:
print
_
(
u"Can't read from printer (disconnected?) (SerialException): {0}"
)
.
format
(
decode_utf8
(
str
(
e
)))
logging
.
error
(
_
(
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
_
(
u"Can't read from printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
))
logging
.
error
(
_
(
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
_
(
u"Can't read from printer (disconnected?) (OS Error {0}): {1}"
)
.
format
(
e
.
errno
,
e
.
strerror
)
logging
.
error
(
_
(
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
):
...
@@ -566,11 +566,11 @@ class printcore():
...
@@ -566,11 +566,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
_
(
u"Can't write to printer (disconnected?) (Socket error {0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
))
logging
.
error
(
_
(
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
_
(
u"Can't write to printer (disconnected?) (SerialException): {0}"
)
.
format
(
decode_utf8
(
str
(
e
)))
logging
.
error
(
_
(
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
_
(
u"Socket connection broken, disconnected. ({0}): {1}"
)
.
format
(
e
.
errno
,
decode_utf8
(
e
.
strerror
))
logging
.
error
(
_
(
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