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
2a943374
Commit
2a943374
authored
Jan 19, 2013
by
kliment
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #319 from colah/dynamic-prompt
Fancy configurable prompts!
parents
92821f7e
29c97003
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
7 deletions
+32
-7
pronsole.py
pronsole.py
+32
-7
No files found.
pronsole.py
View file @
2a943374
...
...
@@ -261,20 +261,45 @@ class pronsole(cmd.Cmd):
self
.
webrequested
=
False
self
.
web_config
=
None
self
.
web_auth_config
=
None
self
.
promptstrs
=
{
"offline"
:
"
%(bold)
suninitialized>
%(normal)
s "
,
"fallback"
:
"
%(bold)
sPC>
%(normal)
s "
,
"macro"
:
"
%(bold)
s..>
%(normal)
s "
,
"online"
:
"
%(bold)
sT:
%(extruder_temp_fancy)
s
%(progress_fancy)
s >
%(normal)
s "
}
def
promptf
(
self
):
"""A function to generate prompts so that we can do dynamic prompts. """
if
self
.
in_macro
:
return
"..>"
promptstr
=
self
.
promptstrs
[
"macro"
]
elif
not
self
.
p
.
online
:
return
"uninitialized>"
elif
self
.
status
.
extruder_enabled
and
self
.
dynamic_temp
:
promptstr
=
self
.
promptstrs
[
"offline"
]
elif
self
.
status
.
extruder_enabled
:
promptstr
=
self
.
promptstrs
[
"online"
]
else
:
promptstr
=
self
.
promptstrs
[
"fallback"
]
if
not
"
%
"
in
promptstr
:
return
promptstr
else
:
specials
=
{}
specials
[
"extruder_temp"
]
=
str
(
int
(
self
.
status
.
extruder_temp
))
specials
[
"extruder_temp_target"
]
=
str
(
int
(
self
.
status
.
extruder_temp_target
))
if
self
.
status
.
extruder_temp_target
==
0
:
return
"T:
%
s>"
%
self
.
status
.
extruder_temp
specials
[
"extruder_temp_fancy"
]
=
str
(
int
(
self
.
status
.
extruder_temp
))
else
:
specials
[
"extruder_temp_fancy"
]
=
"
%
s/
%
s"
%
(
str
(
int
(
self
.
status
.
extruder_temp
)),
str
(
int
(
self
.
status
.
extruder_temp_target
)))
if
self
.
p
.
printing
:
progress
=
int
(
1000
*
float
(
self
.
p
.
queueindex
)
/
len
(
self
.
p
.
mainqueue
))
/
10
elif
self
.
sdprinting
:
progress
=
self
.
percentdone
else
:
return
"T:
%
s/
%
s>"
%
(
self
.
status
.
extruder_temp
,
self
.
status
.
extruder_temp_target
)
progress
=
0.0
specials
[
"progress"
]
=
str
(
progress
)
if
self
.
p
.
printing
or
self
.
sdprinting
:
specials
[
"progress_fancy"
]
=
str
(
progress
)
+
"
%
"
else
:
return
"printer>"
specials
[
"progress_fancy"
]
=
"?
%
"
specials
[
"bold"
]
=
"
\033
[01m"
specials
[
"normal"
]
=
"
\033
[00m"
return
promptstr
%
specials
def
postcmd
(
self
,
stop
,
line
):
""" A hook we override to generate prompts after
...
...
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