Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jean-Paul Smets
slapos
Commits
6df266b4
Commit
6df266b4
authored
Jan 31, 2014
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stack-monitor: deletion of old versions of cgi scripts
parent
b0cddd71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
145 deletions
+0
-145
stack/monitor/settings.cgi.in
stack/monitor/settings.cgi.in
+0
-77
stack/monitor/status.cgi.in
stack/monitor/status.cgi.in
+0
-68
No files found.
stack/monitor/settings.cgi.in
deleted
100644 → 0
View file @
b0cddd71
#!{{ python_executable }}
import os
import cgi
import cgitb
import ConfigParser
import Cookie
cgitb.enable(display=0, logdir="/tmp/cgi.log")
form = cgi.FieldStorage()
cookie = Cookie.SimpleCookie()
print "Content-Type: text/html"
if "password" in form:
password = form['password'].value
if password == '{{ password }}' :
cookie['password'] = password
print cookie
else:
cookie_string = os.environ.get('HTTP_COOKIE')
if cookie_string:
cookie.load(cookie_string)
try:
password = cookie['password'].value
except KeyError:
password = None
else:
password = None
print
if not password or password != '{{ password }}':
print "
<html><body>
"
if password is None:
print "
<h1>
This is the monitoring interface
</h1>
"
else:
print "
<h1>
Error
</h1><p>
Wrong password
</p>
"
print """
<p>
Please enter the monitor_password in the next field to access the data
</p>
<form
action=
"/settings.cgi"
method=
"post"
>
Password :
<input
type=
"password"
name=
"password"
>
<input
type=
"submit"
value=
"Access"
>
</form></body></html>
"""
else:
config_file = "{{ config_cfg }}"
if not os.path.exists(config_file):
print "Your software does
<b>
not
</b>
embed 0-knowledge. \
This interface is useless in this case"
exit(0)
parser = ConfigParser.ConfigParser()
parser.read(config_file)
if len(form) > 1:
for name in form:
if name != 'password':
parser.set('public', name, form[name].value)
with open("{{ config_cfg }}", 'w') as file:
parser.write(file)
print "
<html><body>
"
print "
<h1>
Values that can be defined by the user :
</h1>
"
print "
<form
action=
\"/{{
this_filename
}}\"
method=
\"post\"
>
"
print "
<input
type=
\"hidden\"
name=
\"password\"
value=
\"{{
password
}}\"
>
"
for option in parser.options("public"):
print "%s :
<input
type=
\"text\"
name=
\"%s\"
\
value=
\"%s\"
><br>
"% (option, option, parser.get('public', option))
print "
<input
type=
\"submit\"
value=
\"Save\"
></form>
"
print "
<h1>
Other values :
</h1>
"
for section in parser.sections():
if section != 'public':
for option in parser.options(section):
print "
<b>
%s
</b>
: value=\"%s\"
<br>
" % (option,
parser.get(section, option))
print "
</body></html>
"
stack/monitor/status.cgi.in
deleted
100644 → 0
View file @
b0cddd71
#!{{ python_executable }}
import cgi
import cgitb
import Cookie
import json
import os
import sys
cgitb.enable(display=0, logdir="/tmp/cgi.log")
form = cgi.FieldStorage()
cookie = Cookie.SimpleCookie()
print "Content-Type: text/html"
if "password" in form:
password = form['password'].value
if password == '{{ password }}' :
cookie['password'] = password
print cookie
else:
cookie_string = os.environ.get('HTTP_COOKIE')
if cookie_string:
cookie.load(cookie_string)
try:
password = cookie['password'].value
except KeyError:
password = None
else:
password = None
print
if not password or password != '{{ password }}':
print "
<html><body>
"
if password is None:
print "
<h1>
This is the monitoring interface
</h1>
"
else:
print "
<h1>
Error
</h1><p>
Wrong password
</p>
"
print """
<p>
Please enter the monitor_password in the next field to access the data
</p>
<form
action=
"/settings.cgi"
method=
"post"
>
Password :
<input
type=
"password"
name=
"password"
>
<input
type=
"submit"
value=
"Access"
>
</form></body></html>
"""
else:
json_file = "{{ json_file }}"
result = json.load(open(json_file))
print "
<html><body>
"
print "
<h1>
Monitoring :
</h1>
"
print "
<p><em>
Last time of monitoring process : %s
</em></p>
" % (result['datetime'])
del result['datetime']
print "
<br/>
"
print "
<h2>
These scripts and promises have failed :
</h2>
"
for r in result:
if result[r] != '':
print "
<h3>
%s
</h3><p
style=
\"padding-left:30px;\"
>
%s
</p>
" % (r, result[r])
print "
<br/>
"
print "
<h2>
These scripts and promises were successful :
</h2>
"
for r in result:
if result[r] == '':
print "
<h3>
%s
</h3><p>
%s
</p>
" % (r, result[r])
print "
</body></html>
"
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