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
9692593f
Commit
9692593f
authored
May 31, 2012
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Authentication and updated status xml format
parent
376bb068
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
7 deletions
+62
-7
README.md
README.md
+2
-1
auth.config
auth.config
+3
-0
http.config
http.config
+0
-3
webinterface.py
webinterface.py
+57
-3
No files found.
README.md
View file @
9692593f
...
@@ -13,7 +13,8 @@ command prompt there and running python setup.py install. You can also download
...
@@ -13,7 +13,8 @@ command prompt there and running python setup.py install. You can also download
## Webinterface Configuration
## Webinterface Configuration
*
The Web interface port / ip is configurable in http.config
*
The Web interface port / ip is configurable in http.config
*
The Default User / Password can be set in auth.config
## Webinterface Styling
## Webinterface Styling
*
css/style.css can be modified to change the style of the Web Interface.
*
css/style.css can be modified to change the style of the Web Interface.
...
...
auth.config
0 → 100644
View file @
9692593f
[
user
]
user
=
admin
pass
=
password
\ No newline at end of file
http.config
View file @
9692593f
...
@@ -2,6 +2,3 @@
...
@@ -2,6 +2,3 @@
server
.
socket_host
:
"localhost"
server
.
socket_host
:
"localhost"
server
.
socket_port
:
8080
server
.
socket_port
:
8080
[/
css
/
style
.
css
]
tools
.
staticfile
.
on
=
True
tools
.
staticfile
.
filename
=
"C:\Printrun-web\Printrun\css\style.css"
webinterface.py
View file @
9692593f
#!/usr/bin/python
#!/usr/bin/python
import
cherrypy
,
pronterface
,
re
import
cherrypy
,
pronterface
,
re
,
ConfigParser
,
io
import
os.path
import
os.path
users
=
{}
def
PrintHeader
():
def
PrintHeader
():
return
'<html>
\n
<head>
\n
<title>Pronterface-Web</title>
\n
<link rel="stylesheet" type="text/css" href="/css/style.css" type="text/css"></link>
\n
</head>
\n
<body>
\n
'
return
'<html>
\n
<head>
\n
<title>Pronterface-Web</title>
\n
<link rel="stylesheet" type="text/css" href="/css/style.css" type="text/css"></link>
\n
</head>
\n
<body>
\n
'
...
@@ -14,6 +16,9 @@ def PrintFooter():
...
@@ -14,6 +16,9 @@ def PrintFooter():
def
ReloadPage
(
action
):
def
ReloadPage
(
action
):
return
"<html><head><meta http-equiv='refresh' content='0;url=/'></head><body>"
+
action
+
"</body></html>"
return
"<html><head><meta http-equiv='refresh' content='0;url=/'></head><body>"
+
action
+
"</body></html>"
def
clear_text
(
mypass
):
return
mypass
gPronterPtr
=
0
gPronterPtr
=
0
gWeblog
=
""
gWeblog
=
""
gLogRefresh
=
5
gLogRefresh
=
5
...
@@ -65,13 +70,21 @@ class ConnectButton(object):
...
@@ -65,13 +70,21 @@ class ConnectButton(object):
gPronterPtr
.
connect
(
0
)
gPronterPtr
.
connect
(
0
)
return
ReloadPage
(
"Connect..."
)
return
ReloadPage
(
"Connect..."
)
index
.
exposed
=
True
index
.
exposed
=
True
index
.
_cp_config
=
{
'tools.basic_auth.on'
:
True
,
'tools.basic_auth.realm'
:
'My Print Server'
,
'tools.basic_auth.users'
:
users
,
'tools.basic_auth.encrypt'
:
clear_text
}
class
DisconnectButton
(
object
):
class
DisconnectButton
(
object
):
def
index
(
self
):
def
index
(
self
):
#handle connect push, then reload page
#handle connect push, then reload page
gPronterPtr
.
disconnect
(
0
)
gPronterPtr
.
disconnect
(
0
)
return
ReloadPage
(
"Disconnect..."
)
return
ReloadPage
(
"Disconnect..."
)
index
.
exposed
=
True
index
.
exposed
=
True
index
.
_cp_config
=
{
'tools.basic_auth.on'
:
True
,
'tools.basic_auth.realm'
:
'My Print Server'
,
'tools.basic_auth.users'
:
users
,
'tools.basic_auth.encrypt'
:
clear_text
}
class
ResetButton
(
object
):
class
ResetButton
(
object
):
def
index
(
self
):
def
index
(
self
):
...
@@ -79,6 +92,10 @@ class ResetButton(object):
...
@@ -79,6 +92,10 @@ class ResetButton(object):
gPronterPtr
.
reset
(
0
)
gPronterPtr
.
reset
(
0
)
return
ReloadPage
(
"Reset..."
)
return
ReloadPage
(
"Reset..."
)
index
.
exposed
=
True
index
.
exposed
=
True
index
.
_cp_config
=
{
'tools.basic_auth.on'
:
True
,
'tools.basic_auth.realm'
:
'My Print Server'
,
'tools.basic_auth.users'
:
users
,
'tools.basic_auth.encrypt'
:
clear_text
}
class
PrintButton
(
object
):
class
PrintButton
(
object
):
def
index
(
self
):
def
index
(
self
):
...
@@ -86,6 +103,10 @@ class PrintButton(object):
...
@@ -86,6 +103,10 @@ class PrintButton(object):
gPronterPtr
.
printfile
(
0
)
gPronterPtr
.
printfile
(
0
)
return
ReloadPage
(
"Print..."
)
return
ReloadPage
(
"Print..."
)
index
.
exposed
=
True
index
.
exposed
=
True
index
.
_cp_config
=
{
'tools.basic_auth.on'
:
True
,
'tools.basic_auth.realm'
:
'My Print Server'
,
'tools.basic_auth.users'
:
users
,
'tools.basic_auth.encrypt'
:
clear_text
}
class
PauseButton
(
object
):
class
PauseButton
(
object
):
def
index
(
self
):
def
index
(
self
):
...
@@ -93,16 +114,49 @@ class PauseButton(object):
...
@@ -93,16 +114,49 @@ class PauseButton(object):
gPronterPtr
.
pause
(
0
)
gPronterPtr
.
pause
(
0
)
return
ReloadPage
(
"Pause..."
)
return
ReloadPage
(
"Pause..."
)
index
.
exposed
=
True
index
.
exposed
=
True
index
.
_cp_config
=
{
'tools.basic_auth.on'
:
True
,
'tools.basic_auth.realm'
:
'My Print Server'
,
'tools.basic_auth.users'
:
users
,
'tools.basic_auth.encrypt'
:
clear_text
}
class
XMLstatus
(
object
):
class
XMLstatus
(
object
):
def
index
(
self
):
def
index
(
self
):
#handle connect push, then reload page
#handle connect push, then reload page
return
'<?xml version="1.0"?>
\n
<xml>
\n
<status>'
+
gPronterPtr
.
status
.
GetStatusText
()
+
'</status>
\n
</xml>'
;
txt
=
'<?xml version="1.0"?>
\n
<pronterface>
\n
'
txt
=
txt
+
'<file>'
+
str
(
gPronterPtr
.
filename
)
+
'</file>
\n
'
txt
=
txt
+
'<status>'
+
str
(
gPronterPtr
.
status
.
GetStatusText
())
+
'</status>
\n
'
try
:
temp
=
str
(
float
(
filter
(
lambda
x
:
x
.
startswith
(
"T:"
),
gPronterPtr
.
tempreport
.
split
())[
0
]
.
split
(
":"
)[
1
]))
txt
=
txt
+
'<hotend>'
+
temp
+
'</hotend>
\n
'
except
:
txt
=
txt
+
'<hotend>NA</hotend>
\n
'
pass
try
:
temp
=
str
(
float
(
filter
(
lambda
x
:
x
.
startswith
(
"B:"
),
gPronterPtr
.
tempreport
.
split
())[
0
]
.
split
(
":"
)[
1
]))
txt
=
txt
+
'<bed>'
+
temp
+
'</bed>
\n
'
except
:
txt
=
txt
+
'<bed>NA</bed>
\n
'
pass
if
gPronterPtr
.
sdprinting
:
fractioncomplete
=
float
(
gPronterPtr
.
percentdone
/
100.0
)
txt
+=
_
(
"<progress>
%04.2
f
%%
"
)
%
(
gPronterPtr
.
percentdone
,)
txt
+=
"</progress>
\n
"
elif
gPronterPtr
.
p
.
printing
:
fractioncomplete
=
float
(
gPronterPtr
.
p
.
queueindex
)
/
len
(
gPronterPtr
.
p
.
mainqueue
)
txt
+=
_
(
"<progress>
%04.2
f
%%
|"
)
%
(
100
*
float
(
gPronterPtr
.
p
.
queueindex
)
/
len
(
gPronterPtr
.
p
.
mainqueue
),)
txt
+=
"</progress>
\n
"
else
:
txt
+=
"<progress>NA</progress>
\n
"
txt
+=
'</pronterface>'
return
txt
index
.
exposed
=
True
index
.
exposed
=
True
class
WebInterface
(
object
):
class
WebInterface
(
object
):
def
__init__
(
self
,
pface
):
def
__init__
(
self
,
pface
):
config
=
ConfigParser
.
SafeConfigParser
(
allow_no_value
=
True
)
config
.
read
(
'auth.config'
)
users
[
config
.
get
(
"user"
,
"user"
)]
=
config
.
get
(
"user"
,
"pass"
)
self
.
pface
=
pface
self
.
pface
=
pface
global
gPronterPtr
global
gPronterPtr
global
gWeblog
global
gWeblog
...
...
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