mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
web config tool
This commit is contained in:
parent
8b8b2fe3fb
commit
3715ec2eaa
11 changed files with 632 additions and 0 deletions
59
util/webconfig/htdocs/cgi-bin/config.py
Executable file
59
util/webconfig/htdocs/cgi-bin/config.py
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/python
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, "../modules")
|
||||
sys.path.insert(0, "./modules")
|
||||
import blocks
|
||||
import cgi
|
||||
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
treedir = None
|
||||
|
||||
if form.has_key('freebios'):
|
||||
treedir = form['freebios'].value
|
||||
else:
|
||||
blocks.IncompleteData(form,"freebios")
|
||||
sys.exit()
|
||||
|
||||
if form.has_key('manufacturer'):
|
||||
mfr = form['manufacturer'].value
|
||||
else:
|
||||
blocks.IncompleteData(form,"manufacturer")
|
||||
sys.exit()
|
||||
|
||||
if form.has_key('motherboard'):
|
||||
mb = form['motherboard'].value
|
||||
else:
|
||||
blocks.IncompleteData(form,"motherboard")
|
||||
sys.exit()
|
||||
|
||||
blocks.PrintHeader()
|
||||
|
||||
print '<form action="build.py" method="POST">'
|
||||
|
||||
mbdir = treedir + mfr + "/" + mb + "/"
|
||||
|
||||
dir_fail = None
|
||||
try:
|
||||
os.chdir(mbdir)
|
||||
except:
|
||||
dir_fail = "TRUE"
|
||||
|
||||
if dir_fail:
|
||||
print '<p>Cannot change to motherboard directory %s</p>' % mbdir
|
||||
print '<p>Please <a href=index.py>reselect motherboard</a></p>'
|
||||
else:
|
||||
print '<p>Please fill in the following:</p>'
|
||||
print '<select name="arch">'
|
||||
print '<option selected label="i386" value="i386">i386</option>'
|
||||
print '<option label="alpha" value="alpha">alpha</option>'
|
||||
print '</select>'
|
||||
print '<select name="target">'
|
||||
|
||||
|
||||
print '<input type="submit" value="Enter">'
|
||||
# print '<input type="reset" value="Reset">'
|
||||
print '</form>'
|
||||
|
||||
blocks.PrintTrailer()
|
88
util/webconfig/htdocs/cgi-bin/config2.py
Executable file
88
util/webconfig/htdocs/cgi-bin/config2.py
Executable file
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/python
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, "../modules")
|
||||
sys.path.insert(0, "./modules")
|
||||
import blocks
|
||||
import cgi
|
||||
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
treedir = None
|
||||
|
||||
if form.has_key('freebios'):
|
||||
treedir = form['freebios'].value
|
||||
else:
|
||||
blocks.IncompleteData(form,"freebios")
|
||||
sys.exit()
|
||||
|
||||
if form.has_key('manufacturer'):
|
||||
mfr = form['manufacturer'].value
|
||||
else:
|
||||
blocks.IncompleteData(form,"manufacturer")
|
||||
sys.exit()
|
||||
|
||||
if form.has_key('motherboard'):
|
||||
mb = form['motherboard'].value
|
||||
else:
|
||||
blocks.IncompleteData(form,"motherboard")
|
||||
sys.exit()
|
||||
|
||||
blocks.PrintHeader()
|
||||
|
||||
print '<form action="build.py" method="POST">'
|
||||
|
||||
mbdir = treedir + mfr + "/" + mb + "/"
|
||||
|
||||
dir_fail = None
|
||||
try:
|
||||
os.chdir(mbdir)
|
||||
except:
|
||||
dir_fail = "TRUE"
|
||||
|
||||
if dir_fail:
|
||||
print '<p>Cannot change to motherboard directory %s</p>' % mbdir
|
||||
print '<p>Please <a href=index.py>reselect motherboard</a></p>'
|
||||
else:
|
||||
print '<p> here I am, %s</p>' % mbdir
|
||||
print '<p> Please select your options:<br>'
|
||||
LBDefOptions = [
|
||||
'CONFIGURE_L2_CACHE',
|
||||
'HAVE_FRAMEBUFFER',
|
||||
'PROTECTED_MODE_STARTUP',
|
||||
'SERIAL_CONSOLE',
|
||||
'SROM_CONSOLE',
|
||||
'UPDATE_MICROCODE',
|
||||
'USE_DOC_MIL'
|
||||
]
|
||||
LBBoolOptions = [
|
||||
'USE_CACHE_RAM',
|
||||
'USE_ELF_BOOT',
|
||||
'USE_GENERIC_ROM',
|
||||
'USE_TSUNAMI_TIGBUS_ROM'
|
||||
]
|
||||
LBHexOptions = [
|
||||
'TIG_KERNEL_START'
|
||||
]
|
||||
LBTextOptions = [
|
||||
'CMD_LINE'
|
||||
]
|
||||
for Opt in LBDefOptions:
|
||||
print '<input type="checkbox" name="%s">%s</br>' % (Opt,Opt)
|
||||
for Opt in LBBoolOptions:
|
||||
print '<input type="checkbox" name="%s">%s</br>' % (Opt,Opt)
|
||||
print '<hr>'
|
||||
for Opt in LBHexOptions:
|
||||
print '<input type="checkbox" name="%s">%s<br>' % (Opt,Opt)
|
||||
print '<input type="text" name="%s_val"><br> (enter Hex address e.g. 0x20000)<br>' % Opt
|
||||
print '<hr>'
|
||||
for Opt in LBTextOptions:
|
||||
print '<input type="checkbox" name="%s">%s<br>' % (Opt,Opt)
|
||||
print '<input type="text" name="%s_val"><br> (enter Text arguments e.g. "root=/dev/hda1")<br>' % Opt
|
||||
print '<hr>'
|
||||
|
||||
print '<input type="submit" value="Enter">'
|
||||
# print '<input type="reset" value="Reset">'
|
||||
print '</form>'
|
||||
|
||||
blocks.PrintTrailer()
|
72
util/webconfig/htdocs/cgi-bin/index.py
Executable file
72
util/webconfig/htdocs/cgi-bin/index.py
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/python
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, "../modules")
|
||||
sys.path.insert(0, "./modules")
|
||||
import blocks
|
||||
import cgi
|
||||
|
||||
blocks.PrintHeader()
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
treedir = None
|
||||
if form.has_key("freebios"):
|
||||
showtderr = "TRUE"
|
||||
treedir = form['freebios'].value
|
||||
else:
|
||||
showtderr = None
|
||||
treedir = "/usr/src/freebios/src/mainboard/"
|
||||
|
||||
mfr = None
|
||||
if form.has_key('manufacturer'):
|
||||
mfr = form['manufacturer'].value
|
||||
|
||||
if mfr:
|
||||
print '<form action="config2.py" method="POST">'
|
||||
else:
|
||||
print '<form action="index.py" method="POST">'
|
||||
|
||||
dir_fail = None
|
||||
try:
|
||||
os.chdir(treedir)
|
||||
except:
|
||||
dir_fail = "TRUE"
|
||||
|
||||
if dir_fail:
|
||||
if showtderr:
|
||||
print '<p>Cannot change to requested directory %s</p>' % treedir
|
||||
print '<p>Please re-enter the location of the tree directory:<br>'
|
||||
else:
|
||||
print '<p>Please enter path to LinuxBIOS tree directory<br>or simply click "Enter" to accept the default %s</p>' % treedir
|
||||
print '<input name="freebios" type="text" size="50" value="%s"></p>' % treedir
|
||||
else:
|
||||
print '<p>Tree directory: %s <input name="freebios" type="hidden" value="%s"></p>' % (treedir,treedir)
|
||||
if mfr:
|
||||
print '<p>Manufacturer: %s <input name="manufacturer" type="hidden" value="%s"></p>' % (mfr,mfr)
|
||||
print 'Motherboard: <select name="motherboard">'
|
||||
mblist = os.listdir(mfr)
|
||||
print '<option selected label="none" value="none">None</option>'
|
||||
for mb_item in mblist:
|
||||
if mb_item == "CVS":
|
||||
continue
|
||||
else:
|
||||
print '<option label="%s" value="%s">%s</option>' % (mb_item,mb_item,mb_item)
|
||||
print '</select><br>'
|
||||
else:
|
||||
print 'Manufacturer: <select name="manufacturer">'
|
||||
print '<option selected label="none" value="none">None</option>'
|
||||
mfrlist = os.listdir(".")
|
||||
for mfr_item in mfrlist:
|
||||
if mfr_item == "CVS":
|
||||
continue
|
||||
if mfr_item == mfr:
|
||||
print '<option selected label="%s" value="%s">%s</option>' % (mfr_item,mfr_item,mfr_item)
|
||||
else:
|
||||
print '<option label="%s" value="%s">%s</option>' % (mfr_item,mfr_item,mfr_item)
|
||||
print '</select><br>'
|
||||
|
||||
print '<input type="submit" value="Enter">'
|
||||
# print '<input type="reset" value="Reset">'
|
||||
print '</form>'
|
||||
|
||||
blocks.PrintTrailer()
|
3
util/webconfig/htdocs/cgi-bin/test.py
Executable file
3
util/webconfig/htdocs/cgi-bin/test.py
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/python
|
||||
import cgi
|
||||
cgi.test()
|
BIN
util/webconfig/htdocs/images/linuxbioslogo.jpg
Normal file
BIN
util/webconfig/htdocs/images/linuxbioslogo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
5
util/webconfig/htdocs/index.html
Normal file
5
util/webconfig/htdocs/index.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<HTML>
|
||||
<BODY>
|
||||
Go to the LinuxBIOS<a href="cgi-bin/index.py">Configuration Script</a>
|
||||
</BODY>
|
||||
</HTML>
|
75
util/webconfig/htdocs/modules/blocks.py
Executable file
75
util/webconfig/htdocs/modules/blocks.py
Executable file
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/python
|
||||
def PrintHeader():
|
||||
print """Content-type: text/html
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<title>
|
||||
LinuxBIOS: Web Configuration new
|
||||
</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<table width=600 border=0>
|
||||
|
||||
<tr>
|
||||
<td width=136>
|
||||
<img src="/images/linuxbioslogo.jpg" width=136 height=136 alt="The LinuxBIOS logo">
|
||||
</td>
|
||||
<td width=464 colspan=2 halign=left align=left valign=top bgcolor="#EEEEEE">
|
||||
<br>
|
||||
<font face=ariel,helvetica>
|
||||
<b>LinuxBIOS:</b><br>
|
||||
<font size=+3>
|
||||
Configuration
|
||||
</font>
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td halign=center align=center valign=top width=136 bgcolor="#EEEEEE">
|
||||
<font face=ariel,helvetica color="#669966">
|
||||
<br>
|
||||
<a href="/index.html"><font size=+2 color="#FF2222">home</font></a><br>
|
||||
<a href="/bogus.html">bogus</a><br>
|
||||
</font>
|
||||
</td>
|
||||
<td width=10>
|
||||
<br>
|
||||
</td>
|
||||
<td width=454 halign=left align=left valign=top>
|
||||
<br>
|
||||
"""
|
||||
|
||||
def PrintTrailer():
|
||||
print """
|
||||
<br> <br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width=136 halign=center align=center>
|
||||
<a href="http://www.linuxbios.org"><font size=-2 face=courier color="#FF2222">www.linuxbios.org</font></a>
|
||||
</td>
|
||||
<td colspan=2 halign=right align=right bgcolor="#EEEEEE">
|
||||
<a href="http://www.lanl.gov/misc/copyright.html"><font face=ariel,helvetica size=-2 color=black><b>© 1999 University of California</b></font></a> |
|
||||
<a href="http://www.lanl.gov/misc/disclaimer.html"><font face=ariel,helvetica size=-2 color=black>Disclaimer</font></a></b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
def IncompleteData(CForm,OffendingItem):
|
||||
PrintHeader()
|
||||
print "<h2><center>ERROR: Missing Data for Field %s </center></h2>" % OffendingItem
|
||||
print "<p>Dump of form data follows:</p>"
|
||||
print "<table>"
|
||||
print "<tr><th>Key</th><th>Value</th></tr>"
|
||||
for FormKey in CForm.keys():
|
||||
print "<tr><td>%s</td><td>%s</td></tr>" % (FormKey, CForm[FormKey])
|
||||
print "</table>"
|
||||
PrintTrailer()
|
BIN
util/webconfig/htdocs/modules/blocks.pyc
Normal file
BIN
util/webconfig/htdocs/modules/blocks.pyc
Normal file
Binary file not shown.
328
util/webconfig/server/pyserv.py
Executable file
328
util/webconfig/server/pyserv.py
Executable file
|
@ -0,0 +1,328 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# pyserv.py: Minimal web server for the LinuxBIOS webconfig utility
|
||||
#
|
||||
# I typically edit in vim with ":set ts=2 sw=2 ai sm"; in case
|
||||
# you're using emacs or something and this looks horrible to you,
|
||||
# you now know why.
|
||||
#
|
||||
# Copyright 2001 Robert Drzyzgula, bob@drzyzgula.org
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
#
|
||||
# Release history
|
||||
#
|
||||
# 0.1 Initial release, July 18 2001, R. Drzyzgula
|
||||
# 0.2 Fixed some typos, added environment variables, July 19 2001, R. Drzyzgula
|
||||
#
|
||||
|
||||
#
|
||||
# Need some modules
|
||||
#
|
||||
|
||||
from BaseHTTPServer import HTTPServer
|
||||
from CGIHTTPServer import CGIHTTPRequestHandler
|
||||
import cgi
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
|
||||
#
|
||||
# Print out the usage syntax
|
||||
#
|
||||
|
||||
def usage():
|
||||
print 'Usage: %s [-d] [-t] [-h] [-f freebios] [-s httpdir] [-c cgidir] \\' % sys.argv[0]
|
||||
print ' [-l logdir] [-i ipaddr] [-p port]'
|
||||
print ' %s [--debug] [--test] [--help] [--freebios=<freebios>] [--httpdir=<httpdir>] \\' % sys.argv[0]
|
||||
print ' [--cgidir=<cgidir>] [--log=<logdir>] [--ip=<ipaddr>] [--port=<port>]'
|
||||
print 'Where:'
|
||||
print ' "-d" or "--debug" enables diagnostic output'
|
||||
print ' "-t" or "--test" processes arguments but doesn\'t run the server'
|
||||
print ' "-h" or "--help" prints this message'
|
||||
print ' "freebios" is the top level of the freebios cvs tree'
|
||||
print ' default is environment variable FREEBIOS or /usr/src/freebios'
|
||||
print ' "httpdir" is the directory containing files to be served out '
|
||||
print ' default is environment variable HTTPDIR or <freebios>/util/webconfig/htdocs/'
|
||||
print ' "cgidir" is the directory containing cgi scripts to be served out '
|
||||
print ' default is environment variable CGIDIR or /cgi-bin/'
|
||||
print ' cgidir is always a subdirectory of the httpdir root'
|
||||
print ' "logdir" is the directory where the server logs should be written'
|
||||
print ' default is environment variable LOGDIR or <freebios>/util/webconfig/var/'
|
||||
print ' "ipaddr" is the ip address to bind to; it can be a hostname'
|
||||
print ' default is 127.0.0.1 (localhost)'
|
||||
print ' CAUTION: Changing this could expose this server to external traffic!'
|
||||
print ' "port" is the port number to bind to'
|
||||
print ' default is 8083'
|
||||
sys.exit()
|
||||
|
||||
#
|
||||
# sift through all the defaults, command-line arguments and envionment
|
||||
# variables to get stuff set by the rules: Command line has precedance
|
||||
# over environment, which has precedance over defaults...
|
||||
#
|
||||
|
||||
def process_args():
|
||||
#
|
||||
|
||||
debug = testrun = freebios = httpdir = cgidir = logdir = ipaddr = port = None
|
||||
|
||||
#
|
||||
# Call getopt to parse any arguments...
|
||||
#
|
||||
|
||||
try:
|
||||
optlist, tail = getopt.getopt(sys.argv[1:], 'dtf:h:c:l:i:p:', \
|
||||
['debug','test','freebios=','httpdir=','cgidir=','log=','ip=','port='])
|
||||
except (getopt.GetoptError,RuntimeError), e:
|
||||
usage()
|
||||
|
||||
#
|
||||
# Let's see what the user set...
|
||||
#
|
||||
|
||||
for option, argument in optlist:
|
||||
if option in ("-d", "--debug"):
|
||||
debug = "TRUE"
|
||||
elif option in ("-t", "--test"):
|
||||
testrun = "TRUE"
|
||||
elif option in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit()
|
||||
elif option in ("-f", "--freebios"):
|
||||
freebios = argument
|
||||
elif option in ("-s", "--httpdir"):
|
||||
httpdir = argument
|
||||
elif option in ("-c", "--cgidir"):
|
||||
cgidir = argument
|
||||
elif option in ("-l", "--log"):
|
||||
logdir = argument
|
||||
elif option in ("-i", "--ip"):
|
||||
ipaddr = argument
|
||||
elif option in ("-p", "--port"):
|
||||
port = argument
|
||||
#
|
||||
# If it ain't a listed argument, we don't have any use for it...
|
||||
#
|
||||
|
||||
if debug:
|
||||
if tail:
|
||||
sys.stderr.write("extranious arguments ignored:\n")
|
||||
sys.stderr.write(repr(tail))
|
||||
sys.stderr.write("\n")
|
||||
|
||||
#
|
||||
# set freebios; must end in /, environment has priority over default...
|
||||
#
|
||||
|
||||
if freebios == None:
|
||||
try:
|
||||
freebios = os.environ['FREEBIOS']
|
||||
except KeyError:
|
||||
freebios = "/usr/src/freebios/"
|
||||
if freebios[-1:] != "/":
|
||||
freebios = freebios + "/"
|
||||
|
||||
#
|
||||
# set httpdir; environment has priority over default,
|
||||
# if value doesn't start with "/", prefix with "freebios"
|
||||
# Note that "freebios" better be settled by now...
|
||||
#
|
||||
|
||||
if httpdir == None:
|
||||
try:
|
||||
httpdir = os.environ['HTTPDIR']
|
||||
except KeyError:
|
||||
httpdir = freebios + "util/webconfig/htdocs/"
|
||||
if httpdir[:1] != "/":
|
||||
httpdir = freebios + httpdir
|
||||
if httpdir[-1:] != "/":
|
||||
httpdir = httpdir + "/"
|
||||
|
||||
#
|
||||
# set cgidir...
|
||||
#
|
||||
|
||||
if cgidir == None:
|
||||
try:
|
||||
cgidir = os.environ['CGIDIR']
|
||||
except KeyError:
|
||||
cgidir = "/cgi-bin"
|
||||
|
||||
#
|
||||
# set logdir...
|
||||
#
|
||||
|
||||
if logdir == None:
|
||||
try:
|
||||
logdir = os.environ['LOGDIR']
|
||||
except KeyError:
|
||||
logdir = freebios + "util/webconfig/var/"
|
||||
if logdir[:1] != "/":
|
||||
logdir = freebios + logdir
|
||||
if logdir[-1:] != "/":
|
||||
logdir = logdir + "/"
|
||||
|
||||
#
|
||||
# set the IP address to bind to...
|
||||
# by default we bind only to localhost,
|
||||
# meaning that this web server should only
|
||||
# be visible from the local system.
|
||||
# setting ipaddr to be "ALL" will result in
|
||||
# the server binding to all addresses on
|
||||
# the local machine.
|
||||
#
|
||||
# WARNING: Setting this to anything but
|
||||
# localhost (127.0.0.1) will expose this
|
||||
# server to external networks -- this carries
|
||||
# additional security risks.
|
||||
#
|
||||
|
||||
if ipaddr == None:
|
||||
ipaddr = "127.0.0.1"
|
||||
|
||||
#
|
||||
# Set the port to bind to. Make sure you don't already
|
||||
# have a server on that port. Ports 80, 8000 and 8080
|
||||
# are quite commonly use, we default to 8083
|
||||
#
|
||||
|
||||
if port == None:
|
||||
port = 8083
|
||||
|
||||
#
|
||||
# send the results back on up...
|
||||
#
|
||||
|
||||
return(debug,testrun,freebios,httpdir,cgidir,logdir,ipaddr,port)
|
||||
|
||||
#
|
||||
# Main...
|
||||
#
|
||||
|
||||
(debug,testrun,freebios,httpdir,cgidir,logdir,ipaddr,port) = process_args()
|
||||
|
||||
if debug:
|
||||
sys.stderr.write("freebios = %s\n" % freebios)
|
||||
sys.stderr.write("cgidir = %s\n" % cgidir)
|
||||
sys.stderr.write("httpdir = %s\n" % httpdir)
|
||||
sys.stderr.write("logdir = %s\n" % logdir)
|
||||
sys.stderr.write("ipaddr = %s\n" % ipaddr)
|
||||
sys.stderr.write("port = %s\n" % port)
|
||||
|
||||
#
|
||||
# Stuff some stuff away in environment variables so the
|
||||
# CGI scripts can pick them up...
|
||||
#
|
||||
#
|
||||
# Actually, this doesn't work because the CGIHTTPRequestHandler
|
||||
# hand-crafts the environment according to CGI standards.
|
||||
# It could be made to work by reworking a bunch of the
|
||||
# handler code but I think that's probably a bad idea...
|
||||
#
|
||||
# os.environ['LBWC_FB'] = freebios
|
||||
# os.environ['LBWC_CD'] = cgidir
|
||||
# os.environ['LBWC_HD'] = httpdir
|
||||
# os.environ['LBWC_LD'] = logdir
|
||||
#
|
||||
#
|
||||
# We should now have everything we need to start up the web server...
|
||||
#
|
||||
|
||||
try:
|
||||
os.chdir(httpdir)
|
||||
except:
|
||||
print "Cannot change directory to %s. Exiting now." % httpdir
|
||||
sys.exit()
|
||||
|
||||
#
|
||||
# Extend the HTTPServer class
|
||||
# We do this because the default log_message function doesn't
|
||||
# flush the output after each write.
|
||||
#
|
||||
|
||||
class MyRequestHandler(CGIHTTPRequestHandler):
|
||||
logfile = sys.stderr
|
||||
def log_message(self,format, *args):
|
||||
logfile.write("%s - - [%s] %s\n" %
|
||||
(self.address_string(), self.log_date_time_string(), format%args))
|
||||
logfile.flush()
|
||||
|
||||
#
|
||||
# Instantiate the server
|
||||
#
|
||||
|
||||
if ipaddr == "ALL":
|
||||
serv = HTTPServer(("",port),MyRequestHandler)
|
||||
else:
|
||||
serv = HTTPServer((ipaddr,port),MyRequestHandler)
|
||||
|
||||
#
|
||||
# Set the cgi directory
|
||||
#
|
||||
|
||||
MyRequestHandler.cgi_directories = [cgidir]
|
||||
|
||||
#
|
||||
# Switch stdout to logdir/pyservlog
|
||||
#
|
||||
|
||||
openerror = None
|
||||
try:
|
||||
logfile = open(logdir+"pyservlog","a+")
|
||||
except:
|
||||
openerror = "TRUE"
|
||||
if openerror:
|
||||
if debug:
|
||||
sys.stderr.write("Caution: Can't create %s, logging to stdout\n" % logdir+"pyservlog")
|
||||
else:
|
||||
MyRequestHandler.logfile = logfile
|
||||
|
||||
#
|
||||
# Generate file containing this process's pid
|
||||
#
|
||||
|
||||
pid = os.getpid()
|
||||
openerror = None
|
||||
try:
|
||||
pidlog = open(logdir+"pid","w+")
|
||||
except:
|
||||
openerror = "TRUE"
|
||||
if openerror:
|
||||
if debug:
|
||||
sys.stderr.write("Caution: Can't create %s, writing to log\n" % logdir+"pid")
|
||||
print pid
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
pidlog.write("%s\n" % pid)
|
||||
pidlog.close()
|
||||
|
||||
#
|
||||
# Print a message and exit if this is just a test run...
|
||||
#
|
||||
|
||||
if testrun:
|
||||
if debug:
|
||||
sys.stderr.write("this is where we'd run serv.serve_forever()\n")
|
||||
sys.exit()
|
||||
|
||||
#
|
||||
# Start the server...
|
||||
#
|
||||
|
||||
serv.serve_forever()
|
||||
|
||||
#
|
1
util/webconfig/var/pid
Normal file
1
util/webconfig/var/pid
Normal file
|
@ -0,0 +1 @@
|
|||
12917
|
1
util/webconfig/var/pyservlog
Normal file
1
util/webconfig/var/pyservlog
Normal file
|
@ -0,0 +1 @@
|
|||
|
Loading…
Add table
Reference in a new issue