00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 import sys
00023 import os.path
00024
00025
00026 def process_file(cap_file):
00027 h = open(cap_file, 'r')
00028 data = h.readlines()
00029 d = {}
00030
00031 for l in data:
00032 (k, v) = l[0:-1].split(":")
00033 if v == "SUPPORTED":
00034 d[k] = True
00035 else:
00036 d[k] = False
00037 return os.path.basename(cap_file), d
00038
00039
00040 def create_html(data):
00041 print \
00042 '''
00043 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
00044 <html>
00045 <head>
00046 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
00047 <title>Array support</title>
00048 <script type='text/javascript' src='https://www.google.com/jsapi'></script>
00049 <script type='text/javascript'>
00050
00051 google.load('visualization', '1', {packages:['table']});
00052 google.setOnLoadCallback(drawTable);
00053 function drawTable() {
00054 var data = new google.visualization.DataTable(); '''
00055
00056 array_vendors = [x for x, v in data]
00057
00058 cap_keys = data[0][1].keys()
00059 cap_keys.sort()
00060
00061 print '''data.addColumn('string', 'Capability/Feature');'''
00062
00063
00064 for a in array_vendors:
00065 print "data.addColumn('boolean', '" + a + "');"
00066
00067
00068 print "data.addRows(["
00069
00070
00071 for c in cap_keys:
00072 line = "['%s'" % c
00073
00074 for v, d in data:
00075 line += ",%s" % str(d[c]).lower()
00076
00077 line += "],"
00078 print line
00079 print "]);"
00080
00081 print \
00082 '''
00083 var table = new google.visualization.Table(document.getElementById('table_div'));
00084 table.draw(data, {showRowNumber: false});
00085 }
00086 </script>
00087 </head>
00088
00089 <body>
00090 <h2>Supported API calls for each plug-in </h2>
00091
00092 <h3>Notes</h3>
00093 <ul>
00094 <li> This data is generated from querying the capabilities of the plug-in.
00095 <li> Plug-in must pass rudimentary tests for each advertised feature to be included here.
00096 <li> At this time all plug-ins listed are included in the install packages as they are all open source.
00097 <li> Columns are sort-able, click header to sort.
00098 </ul>
00099
00100 <div id='table_div'></div>
00101 </body>
00102 </html>
00103 '''
00104
00105 if __name__ == '__main__':
00106 arrays = []
00107
00108 if len(sys.argv) < 2:
00109 print 'syntax: web_cap.py <array_cap_1.txt> <array_cap_N.txt>\n\n'
00110 print 'HOWTO: \n' \
00111 '1. Take the output of lsmcli --capabilities <system>\n' \
00112 '2. Dump to a file for 1 or more arrays. \n' \
00113 '3. Then supply each file name on the command line for this \n' \
00114 ' utility and the html output will be dumped to STDOUT\n\n'
00115 print 'Note: The file name is used as the column header for output.'
00116 for f in sys.argv[1:]:
00117 arrays.append(process_file(f))
00118
00119 if len(arrays):
00120 create_html(arrays)