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
c942bc6e
Commit
c942bc6e
authored
Jun 11, 2013
by
D1plo1d
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring pronsole logging so that prontserve can send useful errors over websockets
parent
03295e11
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
58 deletions
+67
-58
pronsole.py
pronsole.py
+57
-54
prontserve.py
prontserve.py
+10
-4
No files found.
pronsole.py
View file @
c942bc6e
This diff is collapsed.
Click to expand it.
prontserve.py
View file @
c942bc6e
...
...
@@ -196,11 +196,10 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
try
:
if
cmd
==
"set"
:
cmd
=
"construct_set"
response
=
getattr
(
prontserve
,
"do_
%
s"
%
cmd
)(
*
args
,
**
kwargs
)
print
response
if
response
is
not
None
:
self
.
write_message
(
response
)
except
:
self
.
write_message
({
"ack"
:
response
})
except
Exception
as
ex
:
print
traceback
.
format_exc
()
self
.
write_message
({
"error"
:
"bad command."
})
self
.
write_message
({
"error"
:
str
(
ex
)
})
else
:
self
.
write_message
({
"error"
:
"
%
s command does not exist."
%
cmd
})
...
...
@@ -253,6 +252,7 @@ class EventEmitter(object):
class
Prontserve
(
pronsole
.
pronsole
,
EventEmitter
):
def
__init__
(
self
,
**
kwargs
):
self
.
initializing
=
True
pronsole
.
pronsole
.
__init__
(
self
)
EventEmitter
.
__init__
(
self
)
self
.
settings
.
sensor_names
=
{
'T'
:
'extruder'
,
'B'
:
'bed'
}
...
...
@@ -273,6 +273,7 @@ class Prontserve(pronsole.pronsole, EventEmitter):
self
.
_sensor_update_received
=
True
self
.
init_mdns
()
self
.
jobs
.
listeners
.
add
(
self
)
self
.
initializing
=
False
def
init_mdns
(
self
):
sdRef
=
pybonjour
.
DNSServiceRegister
(
name
=
None
,
...
...
@@ -458,6 +459,11 @@ class Prontserve(pronsole.pronsole, EventEmitter):
print
msg
self
.
fire
(
"log"
,
{
'msg'
:
msg
,
'level'
:
"debug"
})
def
logError
(
self
,
*
msg
):
print
u""
.
join
(
unicode
(
i
)
for
i
in
msg
)
if
self
.
initializing
==
False
:
raise
Exception
(
u""
.
join
(
unicode
(
i
)
for
i
in
msg
))
def
write_prompt
(
self
):
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