#!/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python
# -*- coding: Latin-1 -*-

# ***** include the biocase.lib directory in the python sys path for importing *****
import os, sys
execfile( os.path.abspath(os.path.join(os.path.dirname( __file__ ), os.path.pardir, os.path.pardir, 'lib', 'biocase', 'adjustpath.py' ) ) )


import cgitb; cgitb.enable()
import string, inspect

	
print 'Content-Type: text/html'
print # Blank line marking end of HTTP headers

print '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Webserver ENVIRONMENT</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../resources/css/biocase.css" rel="stylesheet" type="text/css">
<link rel="SHORTCUT ICON" href="../resources/images/favicon.ico">
</head>

<body>

<!-- HEADER -->
<div id="Header">
Webserver Environment Variables
</div>
<div id="NavBar"><a href="../index.cgi">Start</a> <span class="breadcrumbSeparator">&raquo;</span> <a href="index.html">Utilities</a> <span class="breadcrumbSeparator">&raquo;</span><strong> Environment Variables</strong> </div>
'''

vars = {}
vars['os.getcwd()'] = os.getcwd()
vars['__file__']  = str(__file__)
vars['os.path.dirname( __file__ )'] = os.path.dirname( __file__ )
vars['os.path.abspath( __file__ )'] = os.path.abspath(  __file__ )
vars['inspect.getfile( lambda:None )'] = inspect.getfile( lambda:None )
vars['os.path.abspath( inspect.getfile( lambda:None ) )'] = os.path.abspath( inspect.getfile( lambda:None ) )
vars['Python Sys Path'] = str(sys.path)

try:
	from biocase.wrapper.static_functions import getAbsoluteCWDirectory
	vars['biocase.wrapper.functions.getAbsoluteCWDirectory()'] = getAbsoluteCWDirectory()
except:
	vars['biocase.wrapper.functions.getAbsoluteCWDirectory()'] = 'PyWrapper libraries not installed !'

print '''
<h2>Assorted Python variables</h2>
<table>
 <tr>
  <th>Variable</th>
  <th>Value</th>
 </tr>
'''

for k in vars:
	print "<tr><td class='label'>%s</td> <td>%s</td></tr>" %(k, vars[k])



print '''
</table>
<br>
<h2>Webserver Environment</h2>
<table>
 <tr>
  <th>Variable</th>
  <th>Value</th>
 </tr>
'''

envkeys = os.environ.keys()
envkeys.sort()
for k in envkeys:
	print "<tr><td class='label'>%s</td> <td>%s</td></tr>" %(k, os.environ[k])


print '''
</table>
<br>
<br>

<div id="Footer"> 
  <a href="http://www.biocase.org"><img src="../resources/images/biocase_powered.gif" width="112" height="34"></a> 
</div>

</body>
</html>
'''