コード例 #1
0
    def single_whorl_uniqueness(whorl_name, whorl_value):
        print "here"
        db = Db()
        db.connect()

        md5_whorl_value = FingerprintHelper.value_or_md5(
            {whorl_name: whorl_value})[whorl_name]

        try:
            count = db.get_whorl_value_count(whorl_name, md5_whorl_value,
                                             config.epoched)
        except TypeError:
            return {
                'status':
                "Error: that value has not yet been recorded for '" +
                whorl_name + "'"
            }

        total = db.get_total_count(config.epoched)

        uniqueness = {
            'bits': round(-log(count / float(total), 2), 2),
            'one_in_x': round(float(total) / count, 2)
        }

        return uniqueness
コード例 #2
0
    def _fetch_counts(whorls, whorl_names):
        db = Db()
        db.connect()

        # result dict. 'total' is the total number of entries, 'sig_matches' is
        # the number matching signature in whorls, other keys are variables in
        # signature.
        counts = {}

        # query an incrementally updated totals table which has an index on
        # unique (variable, value)
        md5_whorls = FingerprintHelper.value_or_md5(whorls)
        try:
            for i in whorl_names:
                counts[i] = db.get_whorl_value_count(i, md5_whorls[i],
                                                     config.epoched)

            total = db.get_total_count(config.epoched)

            matching = db.get_signature_matches_count(whorls['signature'],
                                                      config.epoched)
        finally:
            db.close()

        return counts, total, matching
コード例 #3
0
    def single_whorl_uniqueness(whorl_name, whorl_value):
        print "here"
        db = Db()
        db.connect()

        md5_whorl_value = FingerprintHelper.value_or_md5({whorl_name: whorl_value})[whorl_name]

        try:
            count = db.get_whorl_value_count(whorl_name, md5_whorl_value, config.epoched)
        except TypeError:
            return {"status": "Error: that value has not yet been recorded for '" + whorl_name + "'"}

        total = db.get_total_count(config.epoched)

        uniqueness = {"bits": round(-log(count / float(total), 2), 2), "one_in_x": round(float(total) / count, 2)}

        return uniqueness
コード例 #4
0
    def _fetch_counts(whorls):
        db = Db()
        db.connect()

        # result dict. 'total' is the total number of entries, 'sig_matches' is
        # the number matching signature in whorls, other keys are variables in
        # signature.
        counts = {}

        # query an incrementally updated totals table which has an index on
        # unique (variable, value)
        md5_whorls = FingerprintHelper.value_or_md5(whorls)
        for i in FingerprintHelper.whorl_names:
            counts[i] = db.get_whorl_value_count(i, md5_whorls[i], config.epoched)

        total = db.get_total_count(config.epoched)

        matching = db.get_signature_matches_count(whorls["signature"], config.epoched)

        return counts, total, matching