diff --git a/tools/daca2-search.cgi b/tools/daca2-search.cgi new file mode 100755 index 000000000..b0eec9049 --- /dev/null +++ b/tools/daca2-search.cgi @@ -0,0 +1,56 @@ +#!/usr/bin/python + +# cgi-script for searching the results + +import sys +import glob +import os +import cgi +import cgitb + +def matchline(line, id): + return line.endswith('[' + id + ']') + +def doSearch(path,arguments): + id = arguments['id'].value + + files = [] + if 'folder' in arguments: + files.append(path + '/daca2-' + arguments['folder'].value + '.html') + else: + files.extend(sorted(glob.glob(path+'/daca2-?.html'))) + files.extend(sorted(glob.glob(path+'/daca2-lib?.html'))) + + for g in files: + if os.path.isfile(g): + ftp = '' + found = False + f = open(g,'rt') + for line in f.readlines(): + while len(line)>1 and (line[-1]=='\r' or line[-1]=='\n'): + line = line[:-1] + if line.startswith('ftp://'): + ftp = line + if matchline(line, id): + found = True + sys.stdout.write(ftp + '\n') + elif line.find(': note:') < 0: + found = False + if found: + sys.stdout.write(line + '\n') + f.close() + +sys.stdout.write('Content-type: text/html\r\n\r\n') + +sys.stdout.write('
\n')
+
+cgitb.enable()
+arguments = cgi.FieldStorage()
+id = arguments['id'].value
+#id = 'oppositeInnerCondition'
+print(id)
+
+doSearch('../htdocs/devinfo/daca2-report', arguments)
+#doSearch(os.path.expanduser('~/temp'), id)
+
+sys.stdout.write('
\n')