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
df0265d4
Commit
df0265d4
authored
Jan 09, 2013
by
Chris Olah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make prompt dynamically generated.
Prompt is now generated by a promptf() call for every cmdloop iteration.
parent
6fa47668
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
+20
-4
pronsole.py
pronsole.py
+20
-4
No files found.
pronsole.py
View file @
df0265d4
...
...
@@ -192,6 +192,7 @@ class pronsole(cmd.Cmd):
self
.
p
.
recvcb
=
self
.
recvcb
self
.
recvlisteners
=
[]
self
.
prompt
=
"PC>"
self
.
in_macro
=
False
self
.
p
.
onlinecb
=
self
.
online
self
.
f
=
None
self
.
listing
=
0
...
...
@@ -231,6 +232,19 @@ class pronsole(cmd.Cmd):
self
.
web_config
=
None
self
.
web_auth_config
=
None
def
promptf
(
self
):
"""A function to generate prompts so that we can do dynamic prompts. """
if
self
.
in_macro
:
return
"..>"
else
:
return
"PC>"
def
postcmd
(
self
,
stop
,
line
):
""" A hook we override to generate prompts after
each command is executed, for the next prompt."""
self
.
prompt
=
self
.
promptf
()
return
stop
def
set_temp_preset
(
self
,
key
,
value
):
if
not
key
.
startswith
(
"bed"
):
self
.
temps
[
"pla"
]
=
str
(
self
.
settings
.
temperature_pla
)
...
...
@@ -258,7 +272,7 @@ class pronsole(cmd.Cmd):
def
online
(
self
):
print
"Printer is now online"
sys
.
stdout
.
write
(
self
.
prompt
)
sys
.
stdout
.
write
(
self
.
prompt
f
()
)
sys
.
stdout
.
flush
()
def
help_help
(
self
,
l
):
...
...
@@ -290,7 +304,8 @@ class pronsole(cmd.Cmd):
def
end_macro
(
self
):
if
self
.
__dict__
.
has_key
(
"onecmd"
):
del
self
.
onecmd
# remove override
self
.
prompt
=
"PC>"
self
.
in_macro
=
False
self
.
prompt
=
self
.
promptf
()
if
self
.
cur_macro_def
!=
""
:
self
.
macros
[
self
.
cur_macro_name
]
=
self
.
cur_macro_def
macro
=
self
.
compile_macro
(
self
.
cur_macro_name
,
self
.
cur_macro_def
)
...
...
@@ -342,7 +357,8 @@ class pronsole(cmd.Cmd):
self
.
cur_macro_name
=
macro_name
self
.
cur_macro_def
=
""
self
.
onecmd
=
self
.
hook_macro
# override onecmd temporarily
self
.
prompt
=
"..>"
self
.
in_macro
=
False
self
.
prompt
=
self
.
promptf
()
def
delete_macro
(
self
,
macro_name
):
if
macro_name
in
self
.
macros
.
keys
():
...
...
@@ -816,7 +832,7 @@ class pronsole(cmd.Cmd):
tstring
=
l
.
rstrip
()
if
(
tstring
!=
"ok"
and
not
tstring
.
startswith
(
"ok T"
)
and
not
tstring
.
startswith
(
"T:"
)
and
not
self
.
listing
and
not
self
.
monitoring
):
print
tstring
sys
.
stdout
.
write
(
self
.
prompt
)
sys
.
stdout
.
write
(
self
.
prompt
f
()
)
sys
.
stdout
.
flush
()
for
i
in
self
.
recvlisteners
:
i
(
l
)
...
...
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