Exemplo n.º 1
0
    def do_conf(cc):
        #pylint: disable-msg=W0702
        try:
            cc.elid = elid
            cc.voter_f = voter_f

            if not cc.prepare('CONFIGURATOR', apptype):
                return False

            if jaosk_f:
                if not cc.check_districts_file(jaosk_f):
                    return False

            if valik_f:
                if not cc.check_choices_file(valik_f):
                    return False

            if voter_f:
                if not cc.check_voters_file():
                    return False

            if not cc.do_it():
                return False
            return True

        except:
            print 'Viga valimiste failide laadimisel'
            print exception_msg.trace()
            return False
Exemplo n.º 2
0
def main_function():
    try:
        sstrings = dict([(_g, {}) for _g in GROUPS])

        llines = []
        ff = open(MSGSTRINGS_IN_FILE, 'r')
        for ii in ff.readlines():
            line = ii.strip()
            if line and line[0] != '#':
                llines.append(line)
        ff.close()

        # jagame read gruppidesse
        ii = 3
        while ii < len(llines):
            ggroup, comment, key, value = llines[ii-3:ii+1]
            if ggroup in GROUPS:
                sstrings[ggroup][key] = comment, value
            else:
                raise Exception('Vigane grupp "%s", peab kuuluma "%s"' %
                                (ggroup, str(GROUPS)))
            ii += 4

        create_msgstrings_py(sstrings)
        create_teated_example(sstrings)

    except:  # pylint: disable=W0702
        print exception_msg.trace()
        sys.exit(1)

    sys.exit(0)
Exemplo n.º 3
0
    def do_conf(cc):
        #pylint: disable-msg=W0702
        try:
            cc.elid = elid
            cc.voter_f = voter_f

            if not cc.prepare('CONFIGURATOR', apptype):
                return False

            if jaosk_f:
                if not cc.check_districts_file(jaosk_f):
                    return False

            if valik_f:
                if not cc.check_choices_file(valik_f):
                    return False

            if voter_f:
                if not cc.check_voters_file():
                    return False

            if not cc.do_it():
                return False
            return True

        except:
            print 'Viga valimiste failide laadimisel'
            print exception_msg.trace()
            return False
Exemplo n.º 4
0
def main_function():
    try:
        sstrings = dict([(_g, {}) for _g in GROUPS])

        llines = []
        ff = open(MSGSTRINGS_IN_FILE, 'r')
        for ii in ff.readlines():
            line = ii.strip()
            if line and line[0] != '#':
                llines.append(line)
        ff.close()

        # jagame read gruppidesse
        ii = 3
        while ii < len(llines):
            ggroup, comment, key, value = llines[ii - 3:ii + 1]
            if ggroup in GROUPS:
                sstrings[ggroup][key] = comment, value
            else:
                raise Exception('Vigane grupp "%s", peab kuuluma "%s"' %
                                (ggroup, str(GROUPS)))
            ii += 4

        create_msgstrings_py(sstrings)
        create_teated_example(sstrings)

    except:  # pylint: disable=W0702
        print exception_msg.trace()
        sys.exit(1)

    sys.exit(0)
Exemplo n.º 5
0
def validate_form(form, required):
    try:
        logline = ''
        invalid = get_invalid_keys(form, required)
        if len(invalid) != 0:
            logline = 'Invalid form: '
            for el in invalid:
                if len(el) == 2:
                    logline = ("%skey - %s, reason - %s;" %
                               (logline, el[0], REASONS[el[1]]))
                elif len(el) == 3:
                    logline = ("%skey - %s, reason - %s, extra - %s" %
                               (logline, el[0], REASONS[el[1]], el[2][:200]))
                else:
                    logline = "%sinternal error" % logline
            return False, logline

        if evcommon.POST_EVOTE in required:
            return validate_vote(form.getvalue(evcommon.POST_EVOTE),
                                 election.Election().get_questions())

        return True, logline
    except:
        logline = ('Invalid form: key - exception, reason - %s' %
                   exception_msg.trace())
        return False, logline
Exemplo n.º 6
0
def check_ocsp():

    log = evlog.Logger()
    log.set_format(evlog.AppLogFormat('OCSPWD'))
    log.set_logs(Election().get_path(evcommon.OCSP_LOG_FILE))

    try:
        _conf = bdocconfig.BDocConfig()
        _conf.load(Election().get_bdoc_conf())
        _ocsp = _conf.get_ocsp_responders()

        for el in _ocsp:
            app = ('openssl ocsp -issuer "%s" -serial 123 -url "%s" -noverify'
                   % (_ocsp[el], el))

            pp = subprocess.Popen(app, shell=True, stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE, close_fds=True)
            is_ok = 0
            start = time.time()
            while True:
                line = pp.stdout.readline()
                if not line:
                    break
                if line.strip().find('This Update:') != -1:
                    is_ok = 1
            end = time.time()
            if is_ok:
                log.log_info(message='OCSP päringu tegemiseks kulus %5.2f sekundit' % (end - start))
            else:
                log.log_info(message='OCSP ei vasta')
    except:
        log.log_err(message=exception_msg.trace())
Exemplo n.º 7
0
def validate_form(form, required):
    try:
        logline = ''
        invalid = get_invalid_keys(form, required)
        if len(invalid) != 0:
            logline = 'Invalid form: '
            for el in invalid:
                if len(el) == 2:
                    logline = ("%skey - %s, reason - %s;" %
                               (logline, el[0], REASONS[el[1]]))
                elif len(el) == 3:
                    logline = ("%skey - %s, reason - %s, extra - %s" %
                               (logline, el[0], REASONS[el[1]], el[2][:200]))
                else:
                    logline = "%sinternal error" % logline
            return False, logline

        if evcommon.POST_EVOTE in required:
            return validate_vote(form.getvalue(evcommon.POST_EVOTE),
                                 election.Election().get_questions())

        return True, logline
    except:
        logline = ('Invalid form: key - exception, reason - %s' %
                   exception_msg.trace())
        return False, logline
Exemplo n.º 8
0
def get_cert_data_log(cert_pem, prefix = None, addlines = False):

    retval = ''

    isik = 'N/A'
    serial = 'N/A'
    certhash = 'N/A'
    org = 'N/A'
    exc = None

    my_cert_pem = cert_pem
    if addlines:
        bline = '-----BEGIN CERTIFICATE-----\n'
        eline = '\n-----END CERTIFICATE-----'
        my_cert_pem = bline + my_cert_pem + eline

    try:
        cert = M2Crypto.X509.load_cert_string(my_cert_pem)
        isik = cert.get_subject().serialNumber
        serial = cert.get_serial_number()
        certhash = hashlib.sha256(cert.as_der()).digest().encode('hex')
        org = cert.get_subject().O
    except:
        exc = exception_msg.trace()

    retval = "PC=%s, SERIAL=%s, HASH=%s, ORG=%s" % \
            (isik, serial, certhash, org)

    if exc:
        retval = retval + ", error occured"

    if prefix:
        retval = prefix + " " + retval

    return retval, exc
Exemplo n.º 9
0
def get_cert_data_log(cert_pem, prefix=None, addlines=False):

    retval = ''

    isik = 'N/A'
    serial = 'N/A'
    certhash = 'N/A'
    org = 'N/A'
    exc = None

    my_cert_pem = cert_pem
    if addlines:
        bline = '-----BEGIN CERTIFICATE-----\n'
        eline = '\n-----END CERTIFICATE-----'
        my_cert_pem = bline + my_cert_pem + eline

    try:
        cert = M2Crypto.X509.load_cert_string(my_cert_pem)
        isik = cert.get_subject().serialNumber
        serial = cert.get_serial_number()
        certhash = hashlib.sha256(cert.as_der()).digest().encode('hex')
        org = cert.get_subject().O
    except:
        exc = exception_msg.trace()

    retval = "PC=%s, SERIAL=%s, HASH=%s, ORG=%s" % \
            (isik, serial, certhash, org)

    if exc:
        retval = retval + ", error occured"

    if prefix:
        retval = prefix + " " + retval

    return retval, exc
Exemplo n.º 10
0
def check_ocsp():

    log = evlog.Logger()
    log.set_format(evlog.AppLogFormat('OCSPWD'))
    log.set_logs(Election().get_path(evcommon.OCSP_LOG_FILE))

    try:
        _conf = bdocpythonutils.BDocConfig()
        _conf.load(Election().get_bdoc_conf())
        _ocsp = _conf.get_ocsp_responders()

        for el in _ocsp:
            app = 'openssl ocsp -issuer "%s" -serial 123 -url "%s" -noverify' % \
                                                                (_ocsp[el], el)

            pp = subprocess.Popen(app, shell=True, stdin=subprocess.PIPE, \
                                        stdout=subprocess.PIPE, close_fds=True)
            is_ok = 0
            start = time.time()
            while 1:
                line = pp.stdout.readline()
                if line == '':
                    break
                if line.strip().find('This Update:') != -1:
                    is_ok = 1
            end = time.time()
            if is_ok:
                log.log_info(message='OCSP vastas %5.2f sekundiga' % (end - start))
            else:
                log.log_info(message='OCSP ei vasta')
    except:
        log.log_err(message=exception_msg.trace())
Exemplo n.º 11
0
    def do_replace(cr):
        try:
            cr.elid = elid

            if not cr.prepare('REPLACE CHOICES'):
                return False

            if not cr.check_choices_file(valik_f):
                return False

            if not cr.do_it():
                return False
            return True

        except:  # pylint: disable=W0702
            print 'Viga valikute nimekirja välja vahetamisel'
            print exception_msg.trace()
            return False
Exemplo n.º 12
0
    def do_replace(cr):
        try:
            cr.elid = elid

            if not cr.prepare('REPLACE CHOICES'):
                return False

            if not cr.check_choices_file(valik_f):
                return False

            if not cr.do_it():
                return False
            return True

        except: # pylint: disable=W0702
            print 'Viga valikute nimekirja välja vahetamisel'
            print exception_msg.trace()
            return False
Exemplo n.º 13
0
    def check_vote(self, mobid):

        try:
            bdocpython.initialize()
            conf = bdocconfig.BDocConfig()
            conf.load(Election().get_bdoc_conf())

            alines = []
            elines = []
            if mobid:
                alines, elines = regrights.analyze_signature_for_log(self._decoded_vote)
            else:
                alines, elines = regrights.analyze_vote_for_log(self._decoded_vote)

            for el in alines:
                evlog.log(el)

            for el in elines:
                evlog.log_error(el)

            res = None
            if mobid:
                res = regrights.check_vote_hes_mobid(self._decoded_vote, conf)
            else:
                res = regrights.check_vote_hes(self._decoded_vote, conf)

            if not res.result:
                self.error.log_msg = res.error
                if self.error.user_msg == "":
                    self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
                self.error.user_code = evcommon.EVOTE_ERROR

                if not res.cert_is_valid:
                    self.error.user_msg = evmessage.EV_ERRORS.SERTIFIKAAT_ON_AEGUNUD
                    self.error.user_code = evcommon.EVOTE_CERT_ERROR

                return False

            ik_ver = regrights.get_personal_code(res.subject)
            if self._ik != ik_ver:
                self.error.log_msg = "Autentija (%s) ja allkirjastaja (%s) erinevad" % (self._ik, ik_ver)
                self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
                self.error.user_code = evcommon.EVOTE_ERROR
                return False

            return True

        except:
            self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
            self.error.user_code = evcommon.EVOTE_ERROR
            self.error.log_msg = exception_msg.trace()

        finally:
            bdocpython.terminate()

        return False
Exemplo n.º 14
0
def set_hsm(token_name, priv_key, pkcs11_path):

    try:
        Election().set_hsm_token_name(token_name)
        Election().set_hsm_priv_key(priv_key)
        Election().set_pkcs11_path(pkcs11_path)
        Election().config_hsm_done()
    except:
        Election().config_hsm_done(False)
        sys.stderr.write("HSMi konfigureerimine nurjus: %s\n" % exception_msg.trace())
        sys.exit(1)
Exemplo n.º 15
0
    def check_vote(self, mobid):

        try:
            bdocpython.initialize()
            conf = bdocpythonutils.BDocConfig()
            conf.load(Election().get_bdoc_conf())

            res = None
            if mobid:
                res = regrights.check_vote_hes_mobid(self._decoded_vote, conf)
            else:
                res = regrights.check_vote_hes(self._decoded_vote, conf)

            if not res.result:
                self.error.log_msg = res.error
                if self.error.user_msg == '':
                    self.error.user_msg = evmessage.EvMessage().\
                        get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \
                            evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL)
                self.error.user_code = evcommon.EVOTE_ERROR

                if not res.cert_is_valid:
                    self.error.user_msg = evmessage.EvMessage().\
                        get_str("SERTIFIKAAT_ON_AEGUNUD", \
                            evstrings.SERTIFIKAAT_ON_AEGUNUD)
                    self.error.user_code = evcommon.EVOTE_CERT_ERROR

                return False

            ik_ver = regrights.get_personal_code(res.subject)
            if self._ik != ik_ver:
                self.error.log_msg = \
                    'Autentija (%s) ja allkirjastaja (%s) erinevad' % \
                        (self._ik, ik_ver)
                self.error.user_msg = \
                    evmessage.EvMessage().get_str("ERINEV_KASUTAJA", \
                        evstrings.ERINEV_KASUTAJA)
                self.error.user_code = evcommon.EVOTE_ERROR
                return False

            return True

        except:
            self.error.user_msg = evmessage.EvMessage().\
                get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \
                    evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL)
            self.error.user_code = evcommon.EVOTE_ERROR
            self.error.log_msg = exception_msg.trace()

        finally:
            bdocpython.terminate()

        return False
Exemplo n.º 16
0
    def check_vote(self, mobid):

        try:
            bdocpython.initialize()
            conf = bdocpythonutils.BDocConfig()
            conf.load(Election().get_bdoc_conf())

            res = None
            if mobid:
                res = regrights.check_vote_hes_mobid(self._decoded_vote, conf)
            else:
                res = regrights.check_vote_hes(self._decoded_vote, conf)

            if not res.result:
                self.error.log_msg = res.error
                if self.error.user_msg == '':
                    self.error.user_msg = evmessage.EvMessage().\
                        get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \
                            evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL)
                self.error.user_code = evcommon.EVOTE_ERROR

                if not res.cert_is_valid:
                    self.error.user_msg = evmessage.EvMessage().\
                        get_str("SERTIFIKAAT_ON_AEGUNUD", \
                            evstrings.SERTIFIKAAT_ON_AEGUNUD)
                    self.error.user_code = evcommon.EVOTE_CERT_ERROR

                return False

            ik_ver = regrights.get_personal_code(res.subject)
            if self._ik != ik_ver:
                self.error.log_msg = \
                    'Autentija (%s) ja allkirjastaja (%s) erinevad' % \
                        (self._ik, ik_ver)
                self.error.user_msg = \
                    evmessage.EvMessage().get_str("ERINEV_KASUTAJA", \
                        evstrings.ERINEV_KASUTAJA)
                self.error.user_code = evcommon.EVOTE_ERROR
                return False

            return True

        except:
            self.error.user_msg = evmessage.EvMessage().\
                get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \
                    evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL)
            self.error.user_code = evcommon.EVOTE_ERROR
            self.error.log_msg = exception_msg.trace()

        finally:
            bdocpython.terminate()

        return False
Exemplo n.º 17
0
def set_hsm(token_name, priv_key, pkcs11_path):

    try:
        Election().set_hsm_token_name(token_name)
        Election().set_hsm_priv_key(priv_key)
        Election().set_pkcs11_path(pkcs11_path)
        Election().config_hsm_done()
    except:
        Election().config_hsm_done(False)
        sys.stderr.write("HSMi konfigureerimine nurjus: %s\n" %
                         exception_msg.trace())
        sys.exit(1)
Exemplo n.º 18
0
def main_function():
    if not len(sys.argv) == 4:
        usage()

    if not int(sys.argv[2]) in evcommon.G_TYPES:
        usage()

    try:
        execute(sys.argv[1], sys.argv[2], sys.argv[3])
    except: # pylint: disable=W0702
        sys.stderr.write('Viga initsialiseerimisel: ' +
            exception_msg.trace() + '\n')
        sys.exit(1)
Exemplo n.º 19
0
def main_function():
    if not len(sys.argv) == 4:
        usage()

    if not int(sys.argv[2]) in evcommon.G_TYPES:
        usage()

    try:
        execute(sys.argv[1], sys.argv[2], sys.argv[3])
    except:  # pylint: disable=W0702
        sys.stderr.write('Viga initsialiseerimisel: ' + exception_msg.trace() +
                         '\n')
        sys.exit(1)
Exemplo n.º 20
0
def main_function():
    try:
        sstrings = {}
        for _g in GROUPS:
            sstrings[_g] = {}

        llines = []
        ff = open(MSGSTRINGS_IN_FILE, 'r')
        for ii in ff.readlines():
            line = ii.strip()
            if len(line) > 0:
                if line[0] == '#':
                    continue
                llines.append(line)
        ff.close()

        #jagame read gruppidesse
        ii = 3
        while ii < len(llines):
            ggroup = llines[ii - 3]
            comment = llines[ii - 2]
            key = llines[ii - 1]
            value = llines[ii]
            if ggroup in GROUPS:
                sstrings[ggroup][key] = (comment, value)
            else:
                raise Exception('Vigane grupp "%s", peab kuuluma "%s"' % \
                    (ggroup, str(GROUPS)))
            ii += 4

        create_msgstrings_py(sstrings)
        create_teated_example(sstrings)

    except: # pylint: disable=W0702
        print exception_msg.trace()
        sys.exit(1)

    sys.exit(0)
Exemplo n.º 21
0
def validate_vote(vote, questions):
    try:
        logline = ''
        res, why = is_well_formed_vote(vote, questions)
        if res:
            return True, logline

        if len(why) == 2:
            logline = ('Invalid vote: key - %s, reason - %s' %
                       (why[0], REASONS[why[1]]))
        elif len(why) == 3:
            logline = ('Invalid vote: key - %s, reason - %s, extra - %s' %
                       (why[0], REASONS[why[1]], why[2][:200]))
        else:
            logline = 'Invalid vote: internal error'

        return False, logline
    except:
        logline = ('Invalid vote: key - exception, reason - %s' %
                   exception_msg.trace())
        return False, logline
Exemplo n.º 22
0
def validate_vote(vote, questions):
    try:
        logline = ''
        res, why = is_well_formed_vote(vote, questions)
        if res:
            return True, logline

        if len(why) == 2:
            logline = ('Invalid vote: key - %s, reason - %s' %
                       (why[0], REASONS[why[1]]))
        elif len(why) == 3:
            logline = ('Invalid vote: key - %s, reason - %s, extra - %s' %
                       (why[0], REASONS[why[1]], why[2][:200]))
        else:
            logline = 'Invalid vote: internal error'

        return False, logline
    except:
        logline = ('Invalid vote: key - exception, reason - %s' %
                   exception_msg.trace())
        return False, logline
Exemplo n.º 23
0
def main_function():
    if len(sys.argv) < 2:
        usage()

    if sys.argv[1] == 'get' or sys.argv[1] == 'set':

        if sys.argv[1] == 'get':
            try:
                hts_ip = Election().get_hts_ip()
            except:
                hts_ip = NOT_DEFINED_STR

            try:
                hts_path = Election().get_hts_path()
            except:
                hts_path = NOT_DEFINED_STR

            try:
                hts_verify = Election().get_hts_path()
            except:
                hts_verify = NOT_DEFINED_STR

            print "HTS IP: %s" % hts_ip
            print "HTS path: %s" % hts_path
            print "HTS verification path: %s" % hts_verify
        else:
            try:
                if len(sys.argv) != 5:
                    usage()
                execute(sys.argv[2], sys.argv[3], sys.argv[4])
            except:
                Election().config_hth_done(False)
                sys.stderr.write("HTSi konfigureerimine nurjus: %s\n" \
                    % exception_msg.trace())
                sys.exit(1)
    else:
        print 'Operatsioon ei ole teostatav'
        sys.exit(1)
Exemplo n.º 24
0
def main_function():
    if len(sys.argv) < 2:
        usage()

    if sys.argv[1] == 'get' or sys.argv[1] == 'set':

        if sys.argv[1] == 'get':
            try:
                hts_ip = Election().get_hts_ip()
            except:
                hts_ip = NOT_DEFINED_STR

            try:
                hts_path = Election().get_hts_path()
            except:
                hts_path = NOT_DEFINED_STR

            try:
                hts_verify = Election().get_hts_verify_path()
            except:
                hts_verify = NOT_DEFINED_STR

            print "HTS IP: %s" % hts_ip
            print "HTS path: %s" % hts_path
            print "HTS verification path: %s" % hts_verify
        else:
            try:
                if len(sys.argv) != 5:
                    usage()
                execute(sys.argv[2], sys.argv[3], sys.argv[4])
            except:
                Election().config_hth_done(False)
                sys.stderr.write("HTSi konfigureerimine nurjus: %s\n" \
                    % exception_msg.trace())
                sys.exit(1)
    else:
        print 'Operatsioon ei ole teostatav'
        sys.exit(1)
Exemplo n.º 25
0
http://creativecommons.org/licenses/by-nc-nd/3.0/.
"""

import sys
import evcommon
import exception_msg
import hesdisp


def check_consistency():
    hes = hesdisp.HESDispatcher()
    res, msg = hes.hts_consistency_check()
    if res == evcommon.EVOTE_CONSISTENCY_YES:
        print 'HES ja HTS on kooskõlalised'
    elif res == evcommon.EVOTE_CONSISTENCY_NO:
        print 'HES ja HTS ei ole kooskõlalised'
    else:
        print 'Viga HES ja HTS kooskõlalisuse kontrollil (%s)' % msg


if __name__ == '__main__':
    #pylint: disable-msg=W0702
    try:
        check_consistency()
    except:
        sys.stderr.write('Viga HES ja HTS kooskõlalisuse kontrollil:' +
                         exception_msg.trace() + '\n')
        sys.exit(1)

# vim:set ts=4 sw=4 et fileencoding=utf8:
Exemplo n.º 26
0
    def check_vote(self, mobid):

        try:
            bdocpython.initialize()
            conf = bdocconfig.BDocConfig()
            conf.load(Election().get_bdoc_conf())

            alines = []
            elines = []
            if mobid:
                alines, elines = \
                    regrights.analyze_signature_for_log(self._decoded_vote)
            else:
                alines, elines = \
                    regrights.analyze_vote_for_log(self._decoded_vote)

            for el in alines:
                evlog.log(el)

            for el in elines:
                evlog.log_error(el)

            res = None
            if mobid:
                res = regrights.check_vote_hes_mobid(self._decoded_vote, conf)
            else:
                res = regrights.check_vote_hes(self._decoded_vote, conf)

            if not res.result:
                self.error.log_msg = res.error
                if self.error.user_msg == '':
                    self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
                self.error.user_code = evcommon.EVOTE_ERROR

                if not res.cert_is_valid:
                    self.error.user_msg =\
                        evmessage.EV_ERRORS.SERTIFIKAAT_ON_AEGUNUD
                    self.error.user_code = evcommon.EVOTE_CERT_ERROR

                return False

            ik_ver = regrights.get_personal_code(res.subject)
            if self._ik != ik_ver:
                self.error.log_msg = \
                    'Autentija (%s) ja allkirjastaja (%s) erinevad' % \
                    (self._ik, ik_ver)
                self.error.user_msg = \
                    evmessage.EV_ERRORS.TEHNILINE_VIGA
                self.error.user_code = evcommon.EVOTE_ERROR
                return False

            return True

        except:
            self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
            self.error.user_code = evcommon.EVOTE_ERROR
            self.error.log_msg = exception_msg.trace()

        finally:
            bdocpython.terminate()

        return False
Exemplo n.º 27
0
Attribution-NonCommercial-NoDerivs 3.0 Unported License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-nd/3.0/.
"""

import sys
import evcommon
import exception_msg
import hesdisp

def check_consistency():
    hes = hesdisp.HESDispatcher()
    res, msg = hes.hts_consistency_check()
    if res == evcommon.EVOTE_CONSISTENCY_YES:
        print 'HES ja HTS on kooskõlalised'
    elif res == evcommon.EVOTE_CONSISTENCY_NO:
        print 'HES ja HTS ei ole kooskõlalised'
    else:
        print 'Viga HES ja HTS kooskõlalisuse kontrollil (%s)' % msg

if __name__ == '__main__':
    #pylint: disable-msg=W0702
    try:
        check_consistency()
    except:
        sys.stderr.write('Viga HES ja HTS kooskõlalisuse kontrollil:' +
            exception_msg.trace() + '\n')
        sys.exit(1)

# vim:set ts=4 sw=4 et fileencoding=utf8:
Exemplo n.º 28
0
 def log_exception(self):
     self.log_error(exception_msg.trace())
Exemplo n.º 29
0
        for el in qlist:
            print el
            htsdisp.start_revocation(el)
    elif _state == election.ETAPP_LUGEMINE:
        qlist = election.Election().get_questions()
        for el in qlist:
            print el
            htsdisp.start_tabulation(el)
    else:
        pass


def usage():
    sys.stderr.write('Kasutamine: %s\n' % sys.argv[0])
    sys.exit(1)


if __name__ == '__main__':

    if len(sys.argv) != 1:
        usage()

    try:
        execute()
    except:  # pylint: disable=W0702
        sys.stderr.write(\
            'Viga etapivahetusel: ' + exception_msg.trace() + '\n')
        sys.exit(1)

# vim:set ts=4 sw=4 et fileencoding=utf8:
Exemplo n.º 30
0
 def log_exception(self):
     self.log_error(exception_msg.trace())
Exemplo n.º 31
0
            if Election().is_config_session_done():
                print '\tSeansi konfiguratsioon - olemas'
                display_session_conf()
            else:
                print '\tSeansi konfiguratsioon - puudu'

        if Election().is_hts():
            if Election().is_config_verification_done():
                print '\tKontrollitavuse konfiguratsioon - olemas'
                display_verification_conf()
            else:
                print '\tKontrollitavuse konfiguratsioon - puudu'

        if Election().is_hlr():
            if Election().is_config_hsm_done():
                print '\tHSMi konfiguratsioon - olemas'
            else:
                print '\tHSMi konfiguratsioon - puudu'
            for elid in Election().get_questions():
                if Election().is_config_hlr_input_elid_done(elid):
                    print '\t"%s" imporditud häälte fail - olemas' % elid
                else:
                    print '\t"%s" imporditud häälte fail - puudu' % elid

    except:
        sys.stderr.write("Sätete kuvamine nurjus: %s\n" %
                         exception_msg.trace())
        sys.exit(1)

# vim:set ts=4 sw=4 et fileencoding=utf8:
Exemplo n.º 32
0
        for el in qlist:
            print el
            htsdisp.start_revocation(el)
    elif _state == election.ETAPP_LUGEMINE:
        qlist = election.Election().get_questions()
        for el in qlist:
            print el
            htsdisp.start_tabulation(el)
    else:
        pass


def usage():
    sys.stderr.write('Kasutamine: %s\n' % sys.argv[0])
    sys.exit(1)


if __name__ == '__main__':

    if len(sys.argv) != 1:
        usage()

    try:
        execute()
    except: # pylint: disable=W0702
        sys.stderr.write(
            'Viga etapivahetusel: ' + exception_msg.trace() + '\n')
        sys.exit(1)

# vim:set ts=4 sw=4 et fileencoding=utf8:
Exemplo n.º 33
0
             else:
                 print '\tSeansi konfiguratsioon - puudu'

         if Election().is_hts():
             if Election().is_config_verification_done():
                 print '\tKontrollitavuse konfiguratsioon - olemas'
                 display_verification_conf()
             else:
                 print '\tKontrollitavuse konfiguratsioon - puudu'

         if Election().is_hlr():
             if Election().is_config_hsm_done():
                 print '\tHSMi konfiguratsioon - olemas'
             else:
                 print '\tHSMi konfiguratsioon - puudu'
             for elid in Election().get_questions():
                 if Election().is_config_hlr_input_elid_done(elid):
                     print '\t"%s" imporditud häälte fail - olemas' % elid
                 else:
                     print '\t"%s" imporditud häälte fail - puudu' % elid



    except:
        sys.stderr.write("Sätete kuvamine nurjus: %s\n"
            % exception_msg.trace())
        sys.exit(1)


# vim:set ts=4 sw=4 et fileencoding=utf8:
Exemplo n.º 34
0
import sys
import exception_msg
from election import Election


def usage():
    print "Kasutamine: " + sys.argv[0] + " <hts> <htspath> <htsverifypath>"
    sys.exit(1)


def execute(ip, path, verify):
    Election().set_hts_ip(ip)
    Election().set_hts_path(path)
    Election().set_hts_verify_path(verify)
    Election().config_hth_done()


if __name__ == "__main__":
    if len(sys.argv) != 4:
        usage()

    try:
        execute(*sys.argv[1:])
    except:
        Election().config_hth_done(False)
        sys.stderr.write("HTSi konfigureerimine nurjus: %s\n" % exception_msg.trace())
        sys.exit(1)


# vim:set ts=4 sw=4 et fileencoding=utf8:
Exemplo n.º 35
0
        for el in qlist:
            print el
            htsdisp.start_revocation(el)
    elif _state == election.ETAPP_LUGEMINE:
        qlist = election.Election().get_questions()
        for el in qlist:
            print el
            htsdisp.start_tabulation(el)
    else:
        pass


def usage():
    sys.stderr.write('Kasutamine: %s\n' % sys.argv[0])
    sys.exit(1)


if __name__ == '__main__':

    if len(sys.argv) != 1:
        usage()

    try:
        execute()
    except:  # pylint: disable=W0702
        sys.stderr.write('Viga etapivahetusel: ' + exception_msg.trace() +
                         '\n')
        sys.exit(1)

# vim:set ts=4 sw=4 et fileencoding=utf8: