def check_districts_file(self, jaosk_f): tmp_jaosk_f = None try: if not checkfile(jaosk_f): return False print 'Kontrollin jaoskondade faili volitusi' ret = regrights.kontrolli_volitusi(self.elid, jaosk_f, 'JAOSK', \ self.conf) if not ret[0]: print 'Jaoskondade faili volituste '\ 'kontroll andis negatiivse tulemuse' print ret[1] return False tmp_jaosk_f = bdocpythonutils.get_doc_content_file(jaosk_f) self._ed = inputlists.Districts() self._ed.attach_elid(self.elid) self._ed.attach_logger(AppLog()) if not self._ed.check_format(tmp_jaosk_f, \ 'Kontrollin jaoskondade nimekirja: '): print "Jaoskondade nimekiri ei vasta nõuetele" return False print "Jaoskondade nimekiri OK" return True finally: if not tmp_jaosk_f == None: os.unlink(tmp_jaosk_f)
def check_choices_file(self, valik_f): tmp_valik_f = None try: if not checkfile(valik_f): return False print 'Kontrollin valikutefaili volitusi' ret = regrights.kontrolli_volitusi(self.elid, valik_f, 'VALIK', \ self.conf) if not ret[0]: print 'Valikute faili volituste kontroll '\ 'andis negatiivse tulemuse' print ret[1] return False tmp_valik_f = bdocpythonutils.get_doc_content_file(valik_f) self._ch = self.quest.choices_list(self._ed) self._ch.attach_elid(self.elid) self._ch.attach_logger(AppLog()) if not self._ch.check_format(tmp_valik_f, \ 'Kontrollin valikute nimekirja: '): print "Valikute nimekiri ei vasta nõuetele" return False print "Valikute nimekiri OK" return True finally: if not tmp_valik_f == None: os.unlink(tmp_valik_f)
def check_choices_file(self, valik_f): tmp_valik_f = None try: if not checkfile(valik_f): return False print 'Kontrollin valikutefaili volitusi' ret = regrights.kontrolli_volitusi(self.elid, valik_f, 'VALIK', \ self.conf) if not ret[0]: print 'Valikute faili volituste kontroll '\ 'andis negatiivse tulemuse' print ret[1] return False tmp_valik_f = bdocpythonutils.get_doc_content_file(valik_f) self._ch = self.quest.choices_list(self._ed) self._ch.attach_elid(self.elid) self._ch.attach_logger(AppLog()) if not self._ch.check_format(tmp_valik_f, \ 'Kontrollin valikute nimekirja: '): print "Valikute nimekiri ei vasta nõuetele" return False print "Valikute nimekiri OK" return True finally: if not tmp_valik_f == None: os.unlink(tmp_valik_f)
def check_districts_file(self, jaosk_f): tmp_jaosk_f = None try: if not checkfile(jaosk_f): return False print 'Kontrollin jaoskondade faili volitusi' ret = regrights.kontrolli_volitusi(self.elid, jaosk_f, 'JAOSK', \ self.conf) if not ret[0]: print 'Jaoskondade faili volituste '\ 'kontroll andis negatiivse tulemuse' print ret[1] return False tmp_jaosk_f = bdocpythonutils.get_doc_content_file(jaosk_f) self._ed = inputlists.Districts() self._ed.attach_elid(self.elid) self._ed.attach_logger(AppLog()) if not self._ed.check_format(tmp_jaosk_f, \ 'Kontrollin jaoskondade nimekirja: '): print "Jaoskondade nimekiri ei vasta nõuetele" return False print "Jaoskondade nimekiri OK" return True finally: if not tmp_jaosk_f == None: os.unlink(tmp_jaosk_f)
def tyhista_ennista(self, filename): tmp_tyhis_f = None try: bdocpython.initialize() bconf = bdocpythonutils.BDocConfig() bconf.load(Election().get_bdoc_conf()) result = regrights.kontrolli_volitusi(self._elid, filename, "TYHIS", bconf) if not result[0]: self._errmsg = "Tühistus-/ennistusnimekirja volituste " "kontroll andis negatiivse tulemuse: " self._errmsg += result[1] raise Exception(self._errmsg) _signercode = result[2] tmp_tyhis_f = bdocpythonutils.get_doc_content_file(filename) rl = revocationlists.RevocationList() rl.attach_elid(self._elid) rl.attach_logger(evlog.AppLog()) if not rl.check_format(tmp_tyhis_f, "Kontrollin tühistus-/ennistusnimekirja: "): self._errmsg = "Vigase formaadiga tühistus-/ennistusnimekiri" raise Exception(self._errmsg) g_l = None b_l = None act = "" report = [] if rl.revoke: act = "tühistamine" g_l, b_l = self.__tyhista_haaled(rl.rev_list, _signercode) else: act = "ennistamine" g_l, b_l = self.__ennista_haaled(rl.rev_list, _signercode) for el in b_l: el.append(act + " nurjus") report.append(el) for el in g_l: el.append(act + " õnnestus") report.append(el) fn = self._reg.path(["hts", "output", evcommon.REVREPORT_FILE]) self.__save_list(report, fn) ksum.store(fn) return len(rl.rev_list), len(g_l), len(b_l) finally: if tmp_tyhis_f != None: os.unlink(tmp_tyhis_f)
infile = sys.argv[2] p_time = "00:00:00" evlog.AppLog().set_app('HTS', elid) tmp_f = None try: try: s_time = time.time() evlog.AppLog().log( 'Tühistus-/ennistusnimekirja laadimine: ALGUS') bdocpython.initialize() bconf = bdocconfig.BDocConfig() bconf.load(election.Election().get_bdoc_conf()) result = regrights.kontrolli_volitusi(elid, infile, 'TYHIS', bconf) if not result[0]: errmsg = 'Tühistus-/ennistusnimekirja volituste ' \ 'kontroll andis negatiivse tulemuse: ' errmsg += result[1] raise Exception(errmsg) _signercode = result[2] tmp_f = bdocpythonutils.get_doc_content_file(infile) all_, res_a, res_u = restore_revoke(elid, tmp_f, _signercode) p_time = time.strftime("%H:%M:%S", time.gmtime(long(time.time() - s_time))) print 'Tühistamine/ennistamine' print '\tKirjeid kokku: %d' % all_
def tyhista_ennista(self, filename): tmp_tyhis_f = None try: bdocpython.initialize() bconf = bdocpythonutils.BDocConfig() bconf.load(Election().get_bdoc_conf()) result = regrights.kontrolli_volitusi(\ self._elid, filename, 'TYHIS', bconf) if not result[0]: self._errmsg = \ 'Tühistus-/ennistusnimekirja volituste ' \ 'kontroll andis negatiivse tulemuse: ' self._errmsg += result[1] raise Exception(self._errmsg) _signercode = result[2] tmp_tyhis_f = bdocpythonutils.get_doc_content_file(filename) rl = revocationlists.RevocationList() rl.attach_elid(self._elid) rl.attach_logger(evlog.AppLog()) if not rl.check_format(tmp_tyhis_f, \ 'Kontrollin tühistus-/ennistusnimekirja: '): self._errmsg = 'Vigase formaadiga tühistus-/ennistusnimekiri' raise Exception(self._errmsg) g_l = None b_l = None act = '' report = [] if rl.revoke: act = 'tühistamine' g_l, b_l = self.__tyhista_haaled(rl.rev_list, _signercode) else: act = 'ennistamine' g_l, b_l = self.__ennista_haaled(rl.rev_list, _signercode) for el in b_l: el.append(act + ' nurjus') report.append(el) for el in g_l: el.append(act + ' õnnestus') report.append(el) fn = self._reg.path(['hts', 'output', evcommon.REVREPORT_FILE]) self.__save_list(report, fn) ksum.store(fn) return len(rl.rev_list), len(g_l), len(b_l) finally: if tmp_tyhis_f != None: os.unlink(tmp_tyhis_f)