Exemple #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
Exemple #2
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)
Exemple #3
0
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):
#print "%3s                 %s" % (key, value)
                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)
Exemple #5
0
#!/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  #imports audit log class
from ballotImage import BallotImage  #imports ballot image class
from el68a import EL68A
from closeNonMasterPEB import close_nm_PEB
path = sys.argv[1]
path2 = sys.argv[2]
path3 = sys.argv[3]

parsedLog = AuditLog(open(path, 'r'))
parsedBallotImage = BallotImage(open(path2, 'r'))
parsed68 = EL68A(open(path3, 'r'))

masterPEBs, nonMasterPEBs = close_nm_PEB(parsedLog, parsedBallotImage)
pebToPrecinctCount = parsed68.pebToPrecinctCountMap

strippedMasterPEBsList = []
strippedNonMasterPEBsList = []
allPEBsList = []

for key in masterPEBs:
    peb = masterPEBs[key][0]
    if not peb in strippedMasterPEBsList:
        strippedMasterPEBsList.append(peb)
        allPEBsList.append(peb)