#!/usr/bin/python3 import cgi, analyzebenchmarks, base64 form = cgi.FieldStorage() if 'csvFile' in form: csvFileText = form['csvFile'].value.decode('utf-8') options = {'title': 'Benchmark analysis of %s' % form['csvFile'].filename, 'firstTime': True} print("Content-type: text/html\n") analyzebenchmarks.analyzefile(csvFileText.split('\n'), options) else: filecontents = base64.b64decode(form['filecontents'].value).decode('utf-8').split('\n') options = {} for opt in list(form.keys()): if opt != 'filecontents': options[opt] = form[opt].value if 'ctree_mincriterion' in options: try: options['ctree_mincriterion'] = float(options['ctree_mincriterion']) if (options['ctree_mincriterion'] < 0.0 or options['ctree_mincriterion'] > 1.0): del options['ctree_mincriterion'] except ValueError: del options['ctree_mincriterion'] for name in ['num_multiple_trials', 'decisiontree_height', 'decisiontree_width', 'boxplot_height', 'boxplot_width']: if name in options: try: options[name] = int(options[name]) if options[name] <= 0: del options[name] except ValueError: del options[name] for name in ['sort_keys']: if name in options: options[name] = True else: options[name] = False if 'separator' in options and options['separator'] == '': del options['separator'] print("Content-type: text/html\n") analyzebenchmarks.analyzefile(filecontents, options)