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
cc60367a
Commit
cc60367a
authored
Jul 31, 2012
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New commandline paramters : -w/--web to request web interface
Also install webinterface deps and fix bug in configfile()
parent
64fca260
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
45 deletions
+61
-45
printrun_utils.py
printrun/printrun_utils.py
+9
-6
webinterface.py
printrun/webinterface.py
+4
-4
pronsole.py
pronsole.py
+4
-1
pronterface.py
pronterface.py
+37
-34
setup.py
setup.py
+7
-0
No files found.
printrun/printrun_utils.py
View file @
cc60367a
...
...
@@ -20,15 +20,18 @@ def imagefile(filename):
else
:
return
os
.
path
.
join
(
os
.
path
.
split
(
os
.
path
.
split
(
__file__
)[
0
])[
0
],
"images"
,
filename
)
def
pixmapfile
(
filename
):
for
prefix
in
[
'/usr/local/share/pixmaps'
,
'/usr/share/pixmaps'
]
:
def
lookup_file
(
filename
,
prefixes
):
for
prefix
in
prefixes
:
candidate
=
os
.
path
.
join
(
prefix
,
filename
)
if
os
.
path
.
exists
(
candidate
):
return
candidate
return
filename
def
pixmapfile
(
filename
):
return
lookup_file
(
filename
,
[
'/usr/local/share/pixmaps'
,
'/usr/share/pixmaps'
])
def
sharedfile
(
filename
):
return
lookup_file
(
filename
,
[
'/usr/local/share/pronterface'
,
'/usr/share/pronterface'
])
def
configfile
(
filename
):
candidate
=
os
.
path
.
expanduser
(
"~/.printrun/
%
s"
%
filename
)
if
os
.
path
.
exists
(
candidate
):
return
candidate
return
filename
return
lookup_file
(
filename
,
[
os
.
path
.
expanduser
(
"~/.printrun/"
),])
printrun/webinterface.py
View file @
cc60367a
...
...
@@ -3,7 +3,7 @@ import pronterface
import
cherrypy
,
re
,
ConfigParser
,
threading
,
sys
import
os.path
from
printrun.printrun_utils
import
configfile
from
printrun.printrun_utils
import
configfile
,
imagefile
,
sharedfile
users
=
{}
...
...
@@ -363,13 +363,13 @@ def StartWebInterfaceThread(webInterface):
cherrypy
.
config
.
update
({
'engine.autoreload_on'
:
False
})
cherrypy
.
config
.
update
(
configfile
(
"http.config"
))
conf
=
{
'/css/style.css'
:
{
'tools.staticfile.on'
:
True
,
'tools.staticfile.filename'
:
os
.
path
.
join
(
current_dir
,
'css/style.css'
),
'tools.staticfile.filename'
:
sharedfile
(
'css/style.css'
),
},
'/images/control_xy.png'
:
{
'tools.staticfile.on'
:
True
,
'tools.staticfile.filename'
:
os
.
path
.
join
(
current_dir
,
'images/
control_xy.png'
),
'tools.staticfile.filename'
:
imagefile
(
'
control_xy.png'
),
},
'/images/control_z.png'
:
{
'tools.staticfile.on'
:
True
,
'tools.staticfile.filename'
:
os
.
path
.
join
(
current_dir
,
'images/
control_z.png'
),
'tools.staticfile.filename'
:
imagefile
(
'
control_z.png'
),
}}
cherrypy
.
config
.
update
(
configfile
(
"http.config"
))
cherrypy
.
quickstart
(
webInterface
,
'/'
,
config
=
conf
)
...
...
pronsole.py
View file @
cc60367a
...
...
@@ -276,6 +276,7 @@ class pronsole(cmd.Cmd):
self
.
helpdict
[
"z_feedrate"
]
=
_
(
"Feedrate for Control Panel Moves in Z (default: 200mm/min)"
)
self
.
helpdict
[
"final_command"
]
=
_
(
"Executable to run when the print is finished"
)
self
.
commandprefixes
=
'MGT$'
self
.
webrequested
=
False
def
set_temp_preset
(
self
,
key
,
value
):
if
not
key
.
startswith
(
"bed"
):
...
...
@@ -1210,11 +1211,13 @@ class pronsole(cmd.Cmd):
def
parse_cmdline
(
self
,
args
):
import
getopt
opts
,
args
=
getopt
.
getopt
(
args
,
"c:e:h
"
,
[
"conf="
,
"config="
,
"help
"
])
opts
,
args
=
getopt
.
getopt
(
args
,
"c:e:h
:w"
,
[
"conf="
,
"config="
,
"help"
,
"web
"
])
for
o
,
a
in
opts
:
#print repr((o,a))
if
o
in
(
"-c"
,
"--conf"
,
"--config"
):
self
.
load_rc
(
a
)
elif
o
in
(
"-w"
,
"--web"
):
self
.
webrequested
=
True
elif
o
in
(
"-h"
,
"--help"
):
print
"Usage: "
+
sys
.
argv
[
0
]
+
' [-c filename [-c filename2 ... ] ] [-e "command" ...]'
print
" -c | --conf | --config - override startup .pronsolerc file"
...
...
pronterface.py
View file @
cc60367a
...
...
@@ -53,16 +53,7 @@ from printrun.zbuttons import ZButtons
from
printrun.graph
import
Graph
from
printrun.printrun_utils
import
pixmapfile
,
configfile
import
pronsole
webavail
=
False
try
:
if
webavail
:
import
cherrypy
,
printrun
.
webinterface
from
threading
import
Thread
except
:
print
_
(
"CherryPy is not installed. Web Interface Disabled."
)
webavail
=
False
def
dosify
(
name
):
return
os
.
path
.
split
(
name
)[
1
]
.
split
(
"."
)[
0
][:
8
]
+
".g"
...
...
@@ -171,10 +162,21 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
cur_button
=
None
self
.
hsetpoint
=
0.0
self
.
bsetpoint
=
0.0
if
webavail
:
self
.
webInterface
=
webinterface
.
WebInterface
(
self
)
self
.
webThread
=
Thread
(
target
=
webinterface
.
StartWebInterfaceThread
,
args
=
(
self
.
webInterface
,
))
self
.
webThread
.
start
()
self
.
webInterface
=
None
if
self
.
webrequested
:
try
:
import
cherrypy
from
printrun
import
webinterface
except
:
print
_
(
"CherryPy is not installed. Web Interface Disabled."
)
try
:
self
.
webInterface
=
webinterface
.
WebInterface
(
self
)
self
.
webThread
=
threading
.
Thread
(
target
=
webinterface
.
StartWebInterfaceThread
,
args
=
(
self
.
webInterface
,
))
self
.
webThread
.
start
()
except
:
print
_
(
"Failed to start web interface"
)
traceback
.
print_exc
(
file
=
sys
.
stdout
)
self
.
webInterface
=
None
def
startcb
(
self
):
self
.
starttime
=
time
.
time
()
...
...
@@ -326,7 +328,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
print
_
(
"You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0."
)
except
Exception
,
x
:
print
_
(
"You must enter a temperature. (
%
s)"
%
(
repr
(
x
),))
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"You must enter a temperature. (
%
s)"
%
(
repr
(
x
),))
def
do_bedtemp
(
self
,
l
=
""
):
...
...
@@ -344,15 +346,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
setbedgui
(
f
)
else
:
print
_
(
"Printer is not online."
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Printer is not online."
)
else
:
print
_
(
"You cannot set negative temperatures. To turn the bed off entirely, set its temperature to 0."
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"You cannot set negative temperatures. To turn the bed off entirely, set its temperature to 0."
)
except
:
print
_
(
"You must enter a temperature."
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"You must enter a temperature."
)
def
end_macro
(
self
):
...
...
@@ -373,7 +375,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
delete_macro
(
macro_name
)
return
print
_
(
"Cancelled."
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Cancelled."
)
return
self
.
cur_macro_name
=
macro_name
...
...
@@ -393,7 +395,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
capture_skip_newline
=
True
return
wx
.
CallAfter
(
self
.
logbox
.
AppendText
,
l
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AppendLog
(
l
)
def
scanserial
(
self
):
...
...
@@ -416,7 +418,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
projectlayer
.
setframe
(
self
,
self
.
p
)
.
Show
()
else
:
print
_
(
"Printer is not online."
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Printer is not online."
)
def
popmenu
(
self
):
...
...
@@ -489,7 +491,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
old_def
=
self
.
macros
[
macro
]
elif
len
([
c
for
c
in
macro
.
encode
(
"ascii"
,
"replace"
)
if
not
c
.
isalnum
()
and
c
!=
"_"
]):
print
_
(
"Macro name may contain only ASCII alphanumeric symbols and underscores"
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Macro name may contain only alphanumeric symbols and underscores"
)
return
elif
hasattr
(
self
.
__class__
,
"do_"
+
macro
):
...
...
@@ -972,7 +974,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def
help_button
(
self
):
print
_
(
'Defines custom button. Usage: button <num> "title" [/c "colour"] command'
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
'Defines custom button. Usage: button <num> "title" [/c "colour"] command'
)
def
do_button
(
self
,
argstr
):
...
...
@@ -996,7 +998,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
command
=
argstr
.
strip
()
if
num
<
0
or
num
>=
64
:
print
_
(
"Custom button number should be between 0 and 63"
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Custom button number should be between 0 and 63"
)
return
while
num
>=
len
(
self
.
custombuttons
):
...
...
@@ -1264,7 +1266,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
cur_button
=
None
except
:
print
_
(
"event object missing"
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"event object missing"
)
self
.
cur_button
=
None
raise
...
...
@@ -1282,7 +1284,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
except
:
pass
self
.
Destroy
()
if
webavail
:
if
self
.
webInterface
:
from
printrun
import
webinterface
webinterface
.
KillWebInterfaceThread
()
def
do_monitor
(
self
,
l
=
""
):
...
...
@@ -1296,16 +1299,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx
.
CallAfter
(
self
.
monitorbox
.
SetValue
,
self
.
monitor_interval
>
0
)
except
:
print
_
(
"Invalid period given."
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Invalid period given."
)
self
.
setmonitor
(
None
)
if
self
.
monitor
:
print
_
(
"Monitoring printer."
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Monitoring printer."
)
else
:
print
_
(
"Done monitoring."
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Done monitoring."
)
...
...
@@ -1323,7 +1326,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if
not
len
(
command
):
return
wx
.
CallAfter
(
self
.
logbox
.
AppendText
,
">>>"
+
command
+
"
\n
"
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AppendLog
(
">>>"
+
command
+
"
\n
"
)
self
.
onecmd
(
str
(
command
))
self
.
commandbox
.
SetSelection
(
0
,
len
(
command
))
...
...
@@ -1487,7 +1490,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
import
shlex
param
=
self
.
expandcommand
(
self
.
settings
.
slicecommand
)
.
encode
()
print
"Slicing: "
,
param
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Slicing: "
+
param
)
pararray
=
[
i
.
replace
(
"$s"
,
self
.
filename
)
.
replace
(
"$o"
,
self
.
filename
.
replace
(
".stl"
,
"_export.gcode"
)
.
replace
(
".STL"
,
"_export.gcode"
))
.
encode
()
for
i
in
shlex
.
split
(
param
.
replace
(
"
\\
"
,
"
\\\\
"
)
.
encode
())]
#print pararray
...
...
@@ -1500,7 +1503,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
stopsf
=
1
except
:
print
_
(
"Failed to execute slicing software: "
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
"Failed to execute slicing software: "
)
self
.
stopsf
=
1
traceback
.
print_exc
(
file
=
sys
.
stdout
)
...
...
@@ -1587,7 +1590,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
Xtot
,
Ytot
,
Ztot
,
Xmin
,
Xmax
,
Ymin
,
Ymax
,
Zmin
,
Zmax
=
pronsole
.
measurements
(
self
.
f
)
print
pronsole
.
totalelength
(
self
.
f
),
_
(
"mm of filament used in this print
\n
"
)
print
_
(
"the print goes from
%
f mm to
%
f mm in X
\n
and is
%
f mm wide
\n
"
)
%
(
Xmin
,
Xmax
,
Xtot
)
if
webavail
:
if
self
.
webInterface
:
self
.
webInterface
.
AddLog
(
_
(
"the print goes from
%
f mm to
%
f mm in X
\n
and is
%
f mm wide
\n
"
)
%
(
Xmin
,
Xmax
,
Xtot
))
print
_
(
"the print goes from
%
f mm to
%
f mm in Y
\n
and is
%
f mm wide
\n
"
)
%
(
Ymin
,
Ymax
,
Ytot
)
print
_
(
"the print goes from
%
f mm to
%
f mm in Z
\n
and is
%
f mm high
\n
"
)
%
(
Zmin
,
Zmax
,
Ztot
)
...
...
@@ -1855,7 +1858,7 @@ class macroed(wx.Dialog):
self
.
callback
(
self
.
e
.
GetValue
()
.
split
(
"
\n
"
))
def
close
(
self
,
ev
):
self
.
Destroy
()
if
webavail
:
if
self
.
webInterface
:
webinterface
.
KillWebInterfaceThread
()
def
unindent
(
self
,
text
):
self
.
indent_chars
=
text
[:
len
(
text
)
-
len
(
text
.
lstrip
())]
...
...
setup.py
View file @
cc60367a
...
...
@@ -130,6 +130,13 @@ for basedir, subdirs, files in os.walk("locale"):
files
=
map
(
lambda
x
:
os
.
path
.
join
(
basedir
,
x
),
files
)
data_files
.
append
((
destpath
,
files
))
extra_data_dirs
=
[
"css"
]
for
extra_data_dir
in
extra_data_dirs
:
for
basedir
,
subdirs
,
files
in
os
.
walk
(
extra_data_dir
):
files
=
map
(
lambda
x
:
os
.
path
.
join
(
basedir
,
x
),
files
)
destpath
=
os
.
path
.
join
(
"share"
,
"pronterface"
,
basedir
)
data_files
.
append
((
destpath
,
files
))
setup
(
name
=
"Printrun"
,
description
=
"Host software for 3D printers"
,
...
...
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