Beispiel #1
0
def ui_search():
    """
    Search and handle forms.
    """
    hform = HashSearchForm()
    tform = FullTextSearchForm()
    mhform = MachocHashSearchForm()
    cfields = []
    i = 1
    while True:
        x = SampleMetadataType.tostring(i)
        if x == "":
            break
        cfields.append(x)
        i = i + 1

    hash_compare_results = None
    samples_results = None
    functions_results = None
    if hform.validate_on_submit():
        hneedle = hform.hneedle.data
        samples_results, functions_results = api.samplecontrol.search_hash(
            hneedle)
    if tform.validate_on_submit():
        tneedle = tform.fneedle.data
        samples_results = api.samplecontrol.search_fulltext(tneedle)
    if mhform.validate_on_submit():
        comparison_level = mhform.percent.data
        if comparison_level > 100:
            comparison_level = 100
        elif comparison_level < 1:
            comparison_level = 1
        comparison_level = float(comparison_level) / 100
        needle = mhform.mneedle.data
        hash_compare_results = api.samplecontrol.search_machoc_full_hash(
            needle, comparison_level)

    return render_template('search.html',
                           hform=hform,
                           tform=tform,
                           mhform=mhform,
                           cfields=cfields,
                           mresults=functions_results,
                           hresults=hash_compare_results,
                           results=samples_results)
Beispiel #2
0
def ui_search():
    """
    Handle search forms
    """
    hform = HashSearchForm()
    tform = FullTextSearchForm()
    mhform = MachocHashSearchForm()

    hash_compare_results = None
    samples_results = None
    functions_results = None
    if hform.validate_on_submit():
        hneedle = hform.hneedle.data
        samples_results, functions_results = api.samplecontrol.search_hash(
            hneedle)
        if len(samples_results) == 0:
            flash("Hash not found...", "error")
    if tform.validate_on_submit():
        tneedle = tform.fneedle.data
        samples_results = api.samplecontrol.search_fulltext(tneedle)
    if mhform.validate_on_submit():
        comparison_level = mhform.percent.data
        if comparison_level > 100:
            comparison_level = 100
        elif comparison_level < 1:
            comparison_level = 1
        comparison_level = float(comparison_level) / 100
        needle = mhform.mneedle.data
        hash_compare_results = api.samplecontrol.search_machoc_full_hash(
            needle, comparison_level)

    return render_template('search.html',
                           hform=hform,
                           tform=tform,
                           mhform=mhform,
                           mresults=functions_results,
                           hresults=hash_compare_results,
                           results=samples_results)
Beispiel #3
0
def ui_search():
    """
    Handle search forms
    """
    hform = HashSearchForm()
    tform = FullTextSearchForm()
    mhform = MachocHashSearchForm()

    hash_compare_results = None
    samples_results = None
    functions_results = None
    if hform.validate_on_submit():
        hneedle = hform.hneedle.data
        samples_results, functions_results = api.samplecontrol.search_hash(
            hneedle)
        if len(samples_results) == 0:
            flash("Hash not found...", "error")
    if tform.validate_on_submit():
        tneedle = tform.fneedle.data
        samples_results = api.samplecontrol.search_fulltext(tneedle)
    if mhform.validate_on_submit():
        comparison_level = mhform.percent.data
        if comparison_level > 100:
            comparison_level = 100
        elif comparison_level < 1:
            comparison_level = 1
        comparison_level = float(comparison_level) / 100
        needle = mhform.mneedle.data
        hash_compare_results = api.samplecontrol.search_machoc_full_hash(
            needle, comparison_level)

    return render_template('search.html',
                           hform=hform,
                           tform=tform,
                           mhform=mhform,
                           mresults=functions_results,
                           hresults=hash_compare_results,
                           results=samples_results)