From e3439c0bbf9d04bb9af04315844e9799f0930c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 3 Sep 2017 22:15:28 +0200 Subject: [PATCH] daca2: added search script --- tools/daca2-search.cgi | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 tools/daca2-search.cgi 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')