コード例 #1
0
    def create_actions(self):
        max_votes_per_voter = None
        if Election().get_root_reg().check(['common', 'max_votes_per_voter']):
            max_votes_per_voter = \
                Election().get_root_reg().read_integer_value(\
                    ['common'], 'max_votes_per_voter').value

        for el in self.questions:
            _hts = hts.HTS(el[0])
            voter = _hts.talletaja(self.signercode)
            dsc = ''
            try:
                dsc = Election().get_sub_reg(\
                    el[0]).read_string_value(['common'], 'description').value
            except:
                dsc = el[0]
            if voter == None:
                self.user_msg = EvMessage().get_str("POLE_LUBATUD_HAALETADA", \
                    evstrings.POLE_LUBATUD_HAALETADA) % (self.signercode, dsc)
                self.log_msg = self.user_msg
                raise HTSStoreException, evcommon.EVOTE_ERROR
            if max_votes_per_voter:
                if self._count_votes(el[0]) >= max_votes_per_voter:
                    self.user_msg = EvMessage().get_str(\
            "TEHNILINE_VIGA_MAX_HAALTE_ARV_PER_HAALETAJA_ON_ULETATUD", \
            evstrings.TEHNILINE_VIGA_MAX_HAALTE_ARV_PER_HAALETAJA_ON_ULETATUD)

                    self.log_msg = self.user_msg
                    raise HTSStoreException, evcommon.EVOTE_ERROR

            self.actions.append([_hts, voter, el[1]])
コード例 #2
0
    def yleminek_tyhistusperioodi(self, pref=''):
        p_time = "00:00:00"

        try:
            try:
                s_time = time.time()
                AppLog().log('Üleminek tühistusperioodi: ALGUS')
                if ElectionState().get() == election.ETAPP_TYHISTUS:
                    _hts = hts.HTS(self._elid)
                    all_, rev, res = _hts.tyhistusperioodi()
                    p_time = time.strftime("%H:%M:%S", \
                            time.gmtime(long(time.time() - s_time)))

                    print '%sVastuvõetud häälte koguarv: %d' % (pref, all_)
                    print '%sTühistatud korduvate häälte arv: %d' % \
                        (pref, rev)
                    print \
                        '%sHääletanute nimekirja kantud kirjete arv: %d' % \
                            (pref, res)
                    print '\nAega kulus: %s' % p_time

                else:
                    mess = \
                        'Antud funktsioon on lubatud vaid tühistusperioodil'
                    print mess
                    AppLog().log_error(mess)
            except:
                print 'Üleminek tühistusperioodi ebaõnnestus'
                AppLog().log_exception()
        finally:
            AppLog().log(\
                'Üleminek tühistusperioodi (%s): LÕPP' % p_time)
コード例 #3
0
    def loendamisele_minevad_haaled(self, pref=''):
        p_time = "00:00:00"

        try:
            try:
                s_time = time.time()
                AppLog().log(\
                    'Loendamisele minevate ' \
                        'häälte nimekirja koostamine: ALGUS')
                if ElectionState().get() == election.ETAPP_LUGEMINE:
                    _hts = hts.HTS(self._elid)
                    g_v, b_v = _hts.lugemisperioodi()
                    p_time = time.strftime("%H:%M:%S", \
                            time.gmtime(long(time.time() - s_time)))

                    print '%sLoendamisele minevate häälte arv: %d' % \
                        (pref, g_v)
                    print '%sAvalduse alusel tühistatud häälte arv: %d' % \
                            (pref, b_v)
                    print '\nAega kulus: %s' % p_time
                else:
                    mess = 'Antud funktsioon on lubatud vaid lugemisperioodil'
                    print mess
                    AppLog().log_error(mess)
            except:
                print 'Loendamisele minevate häälte nimekirja ' \
                    'koostamine ebaõnnestus'
                AppLog().log_exception()
        finally:
            AppLog().log(\
                'Loendamisele minevate häälte nimekirja ' \
                'koostamine (%s): LÕPP' % p_time)
コード例 #4
0
ファイル: htsdisp.py プロジェクト: ono4ji/evalimine
def start_tabulation(elid):
    AppLog().set_app('HTS', elid)
    p_time = "00:00:00"

    try:
        try:
            s_time = time.time()
            AppLog().log('Loendamisele minevate ' \
                    'häälte nimekirja koostamine: ALGUS')
            _hts = hts.HTS(elid)
            g_v, r_v, a_v, b_v = _hts.lugemisperioodi()
            p_time = time.strftime("%H:%M:%S", \
                    time.gmtime(long(time.time() - s_time)))
            print '\tLoendamisele minevate häälte arv: %d' % g_v
            print '\tAvalduse alusel tühistatud häälte arv: %d' % r_v
            print '\tKorduvate häälte arv: %d' % a_v
            if (b_v > 0):
                print '\tProbleemsete häälte arv: %d' % b_v
            print '\nAega kulus: %s' % p_time
        except:
            print 'Loendamisele minevate häälte nimekirja ' \
                'koostamine ebaõnnestus'
            AppLog().log_exception()
    finally:
        AppLog().log('Loendamisele minevate häälte nimekirja ' \
            'koostamine (%s): LÕPP' % p_time)
コード例 #5
0
ファイル: apply_changes.py プロジェクト: limbail/evalimine
def create_tokend_file(tokend, reg, elid):

    outf = None

    try:
        import hts
        hh = hts.HTS(elid)

        fn = 'tokend.'
        fn += time.strftime('%Y%m%d%H%M%S')

        out = ''

        for el in tokend:
            if hh.haaletanud(el):
                out += el
                out += '\t'
                out += '\t'.join(tokend[el])
                out += '\n'

        if out:
            out = elid + '\n' + out
            out = '1\n' + out
            filename = reg.path(['hts', 'output', fn])
            outf = file(filename, 'w')
            outf.write(out)
            outf.close()
            ksum.store(filename)
            outf = None

    finally:
        if outf is not None:
            outf.close()
コード例 #6
0
    def create_actions(self):
        max_votes_per_voter = None
        if Election().get_root_reg().check(['common', 'max_votes_per_voter']):
            max_votes_per_voter = \
                Election().get_root_reg().read_integer_value(\
                    ['common'], 'max_votes_per_voter').value

        for el in self.questions:
            _hts = hts.HTS(el[0])
            voter = _hts.talletaja(self.signercode)
            dsc = ''
            try:
                dsc = Election().get_sub_reg(\
                    el[0]).read_string_value(['common'], 'description').value
            except:
                dsc = el[0]
            if voter == None:
                self.user_msg = EV_ERRORS.POLE_VALIJA
                self.log_msg = "Pole valija %s, %s" % (self.signercode, dsc)
                raise HTSStoreException, evcommon.EVOTE_ERROR
            if max_votes_per_voter:
                if self._count_votes(el[0]) >= max_votes_per_voter:
                    self.user_msg = EV_ERRORS.TEHNILINE_VIGA

                    self.log_msg = self.user_msg
                    raise HTSStoreException, evcommon.EVOTE_ERROR

            self.actions.append([_hts, voter, el[1]])
コード例 #7
0
def restore_revoke(elid, rfile, operator):

    the_hts = hts.HTS(elid)
    rl = revocationlists.RevocationList()
    rl.attach_elid(elid)
    rl.attach_logger(evlog.AppLog())
    if not rl.check_format(rfile, 'Kontrollin tühistus-/ennistusnimekirja: '):
        errmsg = 'Vigase formaadiga tühistus-/ennistusnimekiri'
        raise Exception(errmsg)

    g_l = None
    b_l = None
    act = ''

    report = []

    newtime = time.localtime()
    if rl.revoke:
        act = 'tühistamine'
        evlog.log('Tühistusavalduse import')
        g_l, b_l = the_hts.load_revoke(rl.rev_list, operator)

        report.append(['------------------------------'])
        report.append(['TÜHISTAMINE (%s)' % \
                time.strftime("%Y%m%d%H%M%S", newtime)])
        report.append(['%d õnnestumist, %d ebaõnnestumist' % \
                (len(g_l), len(b_l))])
        report.append(['Operaator %s, fail %s ' % (operator, rfile)])

    else:
        act = 'ennistamine'
        evlog.log('Ennistusavalduse import')
        g_l, b_l = the_hts.load_restore(rl.rev_list, operator)

        report.append(['------------------------------'])
        report.append(['ENNISTAMINE (%s)' % \
                time.strftime("%Y%m%d%H%M%S", newtime)])
        report.append(['%d õnnestumist, %d ebaõnnestumist' % \
                (len(g_l), len(b_l))])
        report.append(['Operaator %s, fail %s ' % (operator, rfile)])


    for el in b_l:
        el.append(act + ' nurjus')
        report.append(el)

    for el in g_l:
        el.append(act + ' õnnestus')
        report.append(el)

    report.append(['------------------------------'])

    the_hts.save_revocation_report(report)
    return len(rl.rev_list), len(g_l), len(b_l)
コード例 #8
0
ファイル: htsdisp.py プロジェクト: ono4ji/evalimine
def start_revocation(elid):
    AppLog().set_app('HTS', elid)
    p_time = "00:00:00"

    try:
        try:
            s_time = time.time()
            AppLog().log('Üleminek tühistusperioodi: ALGUS')
            _hts = hts.HTS(elid)
            all_, rev, res = _hts.tyhistusperioodi()
            p_time = time.strftime("%H:%M:%S", \
                    time.gmtime(long(time.time() - s_time)))

            print '\tVastuvõetud häälte koguarv: %d' % all_
            print '\tTühistatud korduvate häälte arv: %d' % rev
            print '\tHääletanute nimekirja kantud kirjete arv: %d' % res
            print '\nAega kulus: %s' % p_time

        except:
            print 'Üleminek tühistusperioodi ebaõnnestus'
            AppLog().log_exception()
    finally:
        AppLog().log('Üleminek tühistusperioodi (%s): LÕPP' % p_time)