示例#1
0
def results():
    request.vars.zipped_files.file.seek(0)
    el152, el155, el68a = extractLogs([request.vars.zipped_files.file])
    del request.vars.zipped_files

    # create parsed logs and delete files...
    p_el152 = p_el155 = p_el68a = None
    if el152:
        p_el152 = AuditLog(el152)
        del el152
    if el155 and el68a:
        p_el68a = EL68A(el68a)
        del el68a
        p_el155 = BallotImage(el155, p_el152, p_el68a)
        del el155
    elif el155 and not el68a:
        p_el155 = BallotImage(el155, p_el152)
        del el155
     
    # parsed logs are passed to dispatcher
    dictionary = dispatcher(el152=p_el152, el155=p_el155, el68a=p_el68a)

    if dictionary['message'] != 'LOLCAT':
        generateImageIDs(dictionary['results'])
        generateTags(dictionary['results'])
        
    return dictionary
示例#2
0
def readData(fha):
    import os, sys
    cmd_folder = os.getenv('HOME') + '/audit-bear/modules'
    if cmd_folder not in sys.path:
        sys.path.insert(0, cmd_folder)

    from auditLog import AuditLog

    parsedLog = AuditLog(fha)

    return parsedLog
示例#3
0
def index():
    form = FORM('Zipped File:', INPUT(_name='zipped_files', _type='file'),
                INPUT(_type='submit'))

    if form.accepts(request.vars, session) and form.vars.zipped_files != '':
        form.vars.zipped_files.file.seek(0)
        try:
            el152, el155, el68a = extractLogs([form.vars.zipped_files.file],
                                              request.folder)
        except InvalidFilesException as e:
            session.file_error = str(e)
            redirect(URL('error'))
        finally:
            del form.vars.zipped_files

        # file name is in el152.name etc.
        # create parsed logs and delete files...
        p_el152 = p_el155 = p_el68a = None
        if el152:
            p_el152 = AuditLog(el152)
            os.unlink(os.path.join(request.folder, 'uploads', el152.name))
            del el152
        if el155 and el68a:
            p_el68a = EL68A(el68a)
            os.unlink(os.path.join(request.folder, 'uploads', el68a.name))
            del el68a
            p_el155 = BallotImage(el155, p_el152, p_el68a)
            os.unlink(os.path.join(request.folder, 'uploads', el155.name))
            del el155
        elif el155 and not el68a:
            p_el155 = BallotImage(el155, p_el152)
            os.unlink(os.path.join(request.folder, 'uploads', el155.name))
            del el155

        # parsed logs are passed to dispatcher
        dictionary = dispatcher(el152=p_el152, el155=p_el155, el68a=p_el68a)

        if dictionary['message'] != 'LOLCAT':
            generateImageIDs(dictionary['results'])
            generateTags(dictionary['results'])

        session.results = dictionary
        redirect(URL('results'))

    return dict(message=None, form=form)
示例#4
0
    sys.path.insert(0, cmd_folder)

from auditLog import AuditLog  #imports audit log class
from ballotImage import BallotImage  #imports ballot image class
import dateMod
import el68a
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

#import random as rnd
path = sys.argv[1]
path2 = sys.argv[2]
path3 = sys.argv[3]

parsedLog = AuditLog(open(path, 'r'))
parsedEL68A = el68a.EL68A(open(path3, 'r'))
parsedBallotImage = BallotImage(open(path2, 'r'), parsedLog, parsedEL68A)

# first generate list of valid machines
dateModObject = dateMod.DateMod(parsedLog, parsedEL68A.electionDate)
times, a = dateMod.timeopen(parsedLog, dateModObject.eday)
mmap = dateMod.timecheck(times)
validMachines = mmap.keys()
pollOpenLate = analysis_places_open_late2.open_late(parsedLog,
                                                    parsedBallotImage,
                                                    validMachines)
mapMachA, mapMachB, lTV, pA, pB = consecutiveVotes(parsedLog,
                                                   parsedBallotImage,
                                                   validMachines, pollOpenLate)
#for key, value in sorted(pA.iteritems(), key=lambda (k,v): (v,k), reverse = False):
示例#5
0
cmd_folder = os.getenv(
    'HOME') + '/audit-bear/web2py/applications/audit_bear/modules'
if cmd_folder not in sys.path:
    sys.path.insert(0, cmd_folder)

from auditLog import AuditLog
from ballotImage import BallotImage
import dateMod
import el68a

path = sys.argv[1]
path2 = sys.argv[2]
path3 = sys.argv[3]

parsedLog = AuditLog(open(path, "r"))
parsedEL68A = el68a.EL68A(open(path3, 'r'))
parsedBallotImage = BallotImage(open(path2, 'r'), parsedLog, parsedEL68A)

dateModObject = dateMod.DateMod(parsedLog, parsedEL68A.electionDate)

#dateModObject = dateMod.DateMod(parsedLog, parsedEL68A.electionDate)
#times, a = dateMod.timeopen(parsedLog, dateModObject.eday)
#mmap = dateMod.timecheck(times)
validMachines = dateModObject.D1.keys()

mapOpenLateTime = analysis_places_open_late2.open_late(parsedLog,
                                                       parsedBallotImage,
                                                       validMachines)
#FORMAT OUTPUT
now = datetime.datetime.now()
                PEBs[precinctNumMap[line[0]]].append(non_master)
        else:
            continue

    for location in PEBs:
        print location, PEBs[location]
    pMaster = {}
    pNonMaster = {}
    return
    #return (pMaster, pNonMaster)


import os, sys

cmd_folder = os.getenv('HOME') + '/audit-bear/modules'
if cmd_folder not in sys.path:
    sys.path.insert(0, cmd_folder)

from auditLog import AuditLog  #imports audit log class
from ballotImage import BallotImage  #imports ballot image class
import dateMod

path = sys.argv[1]
path2 = sys.argv[2]
path3 = sys.argv[3]

parsedLog = AuditLog(open(path, 'r'))
parsedBallotImage = BallotImage(open(path2, 'r'), AuditLog(open(path, 'r')),
                                open(path3, 'r'))
closeNM_PEB(parsedLog, parsedBallotImage)
#!/usr/bin/python
import os, sys
cmd_folder = os.getenv('HOME') + '/audit-bear/modules'
if cmd_folder not in sys.path:
    sys.path.insert(0, cmd_folder)

from auditLog import AuditLog
import math

VOTE_EVENT = '0001510'
WORKER_VOTE_EVENT = '0001511'

#parsedLog = parse(open('audit_log.txt', 'r'))
parsedLog = AuditLog(open(sys.argv[1], 'r'))
machineVotes = {}
totalVotes = 0
for line in parsedLog:
    if not line[0] in machineVotes:
        machineVotes[line[0]] = 0
    if line[4] in (VOTE_EVENT, WORKER_VOTE_EVENT):
        machineVotes[line[0]] += 1
        totalVotes += 1

for machine in sorted(machineVotes):
    print "Machine " + machine + " has " + str(
        machineVotes[machine]) + " votes."

print "Total votes", totalVotes
print "Number of machines", len(machineVotes)

# Graph it