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
54e208a1
Commit
54e208a1
authored
Jul 04, 2011
by
kliment
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #32 from k-eex/master
command line parsing, add -c and -e
parents
24e671fc
6f4ea3ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
22 deletions
+46
-22
.pronsolerc
.pronsolerc
+1
-0
pronsole.py
pronsole.py
+42
-21
pronterface.py
pronterface.py
+3
-1
No files found.
.pronsolerc
View file @
54e208a1
# Sample .pronsolerc file - copy this into your home directory
# Sample .pronsolerc file - copy this into your home directory
!print "Loaded " + self.rc_filename
macro up move Z 10
macro up move Z 10
macro loud !self.p.loud = 1
macro loud !self.p.loud = 1
macro quiet !self.p.loud = 0
macro quiet !self.p.loud = 0
pronsole.py
View file @
54e208a1
...
@@ -85,7 +85,9 @@ class pronsole(cmd.Cmd):
...
@@ -85,7 +85,9 @@ class pronsole(cmd.Cmd):
self
.
percentdone
=
0
self
.
percentdone
=
0
self
.
tempreadings
=
""
self
.
tempreadings
=
""
self
.
macros
=
{}
self
.
macros
=
{}
self
.
rc_loaded
=
False
self
.
processing_rc
=
False
self
.
processing_rc
=
False
self
.
processing_args
=
False
self
.
settings
=
Settings
()
self
.
settings
=
Settings
()
self
.
settings
.
_port_list
=
self
.
scanserial
self
.
settings
.
_port_list
=
self
.
scanserial
self
.
settings
.
_temperature_abs_cb
=
self
.
set_temp_preset
self
.
settings
.
_temperature_abs_cb
=
self
.
set_temp_preset
...
@@ -167,14 +169,15 @@ class pronsole(cmd.Cmd):
...
@@ -167,14 +169,15 @@ class pronsole(cmd.Cmd):
if
not
self
.
processing_rc
:
if
not
self
.
processing_rc
:
print
"Macro '"
+
self
.
cur_macro_name
+
"' defined"
print
"Macro '"
+
self
.
cur_macro_name
+
"' defined"
# save it
# save it
macro_key
=
"macro "
+
self
.
cur_macro_name
if
not
self
.
processing_args
:
macro_def
=
macro_key
macro_key
=
"macro "
+
self
.
cur_macro_name
if
"
\n
"
in
self
.
cur_macro_def
:
macro_def
=
macro_key
macro_def
+=
"
\n
"
if
"
\n
"
in
self
.
cur_macro_def
:
else
:
macro_def
+=
"
\n
"
macro_def
+=
" "
else
:
macro_def
+=
self
.
cur_macro_def
macro_def
+=
" "
self
.
save_in_rc
(
macro_key
,
macro_def
)
macro_def
+=
self
.
cur_macro_def
self
.
save_in_rc
(
macro_key
,
macro_def
)
else
:
else
:
print
"Empty macro - cancelled"
print
"Empty macro - cancelled"
del
self
.
cur_macro
,
self
.
cur_macro_name
,
self
.
cur_macro_def
del
self
.
cur_macro
,
self
.
cur_macro_name
,
self
.
cur_macro_def
...
@@ -195,7 +198,7 @@ class pronsole(cmd.Cmd):
...
@@ -195,7 +198,7 @@ class pronsole(cmd.Cmd):
delattr
(
self
.
__class__
,
"do_"
+
macro_name
)
delattr
(
self
.
__class__
,
"do_"
+
macro_name
)
del
self
.
macros
[
macro_name
]
del
self
.
macros
[
macro_name
]
print
"Macro '"
+
macro_name
+
"' removed"
print
"Macro '"
+
macro_name
+
"' removed"
if
not
self
.
processing_rc
:
if
not
self
.
processing_rc
and
not
self
.
processing_args
:
self
.
save_in_rc
(
"macro "
+
macro_name
,
""
)
self
.
save_in_rc
(
"macro "
+
macro_name
,
""
)
else
:
else
:
print
"Macro '"
+
macro_name
+
"' is not defined"
print
"Macro '"
+
macro_name
+
"' is not defined"
...
@@ -243,7 +246,7 @@ class pronsole(cmd.Cmd):
...
@@ -243,7 +246,7 @@ class pronsole(cmd.Cmd):
try
:
try
:
t
=
type
(
getattr
(
self
.
settings
,
var
))
t
=
type
(
getattr
(
self
.
settings
,
var
))
value
=
self
.
settings
.
_set
(
var
,
str
)
value
=
self
.
settings
.
_set
(
var
,
str
)
if
not
self
.
processing_rc
:
if
not
self
.
processing_rc
and
not
self
.
processing_args
:
self
.
save_in_rc
(
"set "
+
var
,
"set
%
s
%
s"
%
(
var
,
value
))
self
.
save_in_rc
(
"set "
+
var
,
"set
%
s
%
s"
%
(
var
,
value
))
except
AttributeError
:
except
AttributeError
:
print
"Unknown variable '
%
s'"
%
var
print
"Unknown variable '
%
s'"
%
var
...
@@ -282,24 +285,29 @@ class pronsole(cmd.Cmd):
...
@@ -282,24 +285,29 @@ class pronsole(cmd.Cmd):
self
.
p
.
disconnect
()
self
.
p
.
disconnect
()
cmd
.
Cmd
.
postloop
(
self
)
cmd
.
Cmd
.
postloop
(
self
)
def
load_rc
(
self
,
rc_filename
=
".pronsolerc"
):
def
load_rc
(
self
,
rc_filename
):
self
.
processing_rc
=
True
self
.
processing_rc
=
True
try
:
try
:
try
:
rc
=
open
(
rc_filename
)
self
.
rc_filename
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
"~"
),
rc_filename
)
self
.
rc_filename
=
os
.
path
.
abspath
(
rc_filename
)
rc
=
open
(
self
.
rc_filename
)
except
IOError
:
rc
=
open
(
rc_filename
)
self
.
rc_filename
=
os
.
path
.
abspath
(
rc_filename
)
for
rc_cmd
in
rc
:
for
rc_cmd
in
rc
:
if
not
rc_cmd
.
lstrip
()
.
startswith
(
"#"
):
if
not
rc_cmd
.
lstrip
()
.
startswith
(
"#"
):
self
.
onecmd
(
rc_cmd
)
self
.
onecmd
(
rc_cmd
)
rc
.
close
()
rc
.
close
()
if
hasattr
(
self
,
"cur_macro"
):
self
.
end_macro
()
self
.
rc_loaded
=
True
finally
:
self
.
processing_rc
=
False
def
load_default_rc
(
self
,
rc_filename
=
".pronsolerc"
):
try
:
try
:
self
.
load_rc
(
os
.
path
.
join
(
os
.
path
.
expanduser
(
"~"
),
rc_filename
))
except
IOError
:
self
.
load_rc
(
rc_filename
)
except
IOError
:
except
IOError
:
pass
pass
if
hasattr
(
self
,
"cur_macro"
):
self
.
end_macro
()
self
.
processing_rc
=
False
def
save_in_rc
(
self
,
key
,
definition
):
def
save_in_rc
(
self
,
key
,
definition
):
"""
"""
...
@@ -351,7 +359,8 @@ class pronsole(cmd.Cmd):
...
@@ -351,7 +359,8 @@ class pronsole(cmd.Cmd):
del
rci
,
rco
del
rci
,
rco
def
preloop
(
self
):
def
preloop
(
self
):
self
.
load_rc
()
if
not
self
.
rc_loaded
:
self
.
load_default_rc
()
print
"Welcome to the printer console! Type
\"
help
\"
for a list of available commands."
print
"Welcome to the printer console! Type
\"
help
\"
for a list of available commands."
cmd
.
Cmd
.
preloop
(
self
)
cmd
.
Cmd
.
preloop
(
self
)
...
@@ -1017,10 +1026,22 @@ class pronsole(cmd.Cmd):
...
@@ -1017,10 +1026,22 @@ class pronsole(cmd.Cmd):
print
"home xyz - homes all axes (Using G1 and G92)"
print
"home xyz - homes all axes (Using G1 and G92)"
print
"home xyze - homes all axes and zeroes the extruder (Using G1 and G92)"
print
"home xyze - homes all axes and zeroes the extruder (Using G1 and G92)"
def
parse_cmdline
(
self
,
args
):
import
getopt
opts
,
args
=
getopt
.
getopt
(
args
,
"c:e:"
,
[
"conf="
,
"config="
])
for
o
,
a
in
opts
:
#print repr((o,a))
if
o
in
(
"-c"
,
"--conf"
,
"--config"
):
self
.
load_rc
(
a
)
elif
o
==
"-e"
:
self
.
processing_args
=
True
self
.
onecmd
(
a
)
self
.
processing_args
=
False
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
interp
=
pronsole
()
interp
=
pronsole
()
interp
.
parse_cmdline
(
sys
.
argv
[
1
:])
try
:
try
:
interp
.
cmdloop
()
interp
.
cmdloop
()
except
:
except
:
...
...
pronterface.py
View file @
54e208a1
...
@@ -83,7 +83,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
...
@@ -83,7 +83,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
]
]
self
.
custombuttons
=
[]
self
.
custombuttons
=
[]
self
.
btndict
=
{}
self
.
btndict
=
{}
self
.
load_rc
(
".pronsolerc"
)
self
.
parse_cmdline
(
sys
.
argv
[
1
:])
if
not
self
.
rc_loaded
:
self
.
load_default_rc
(
".pronsolerc"
)
customdict
=
{}
customdict
=
{}
try
:
try
:
execfile
(
"custombtn.txt"
,
customdict
)
execfile
(
"custombtn.txt"
,
customdict
)
...
...
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