当前位置: 首页>>代码示例>>Python>>正文


Python Election.read_value方法代码示例

本文整理汇总了Python中election.Election.read_value方法的典型用法代码示例。如果您正苦于以下问题:Python Election.read_value方法的具体用法?Python Election.read_value怎么用?Python Election.read_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在election.Election的用法示例。


在下文中一共展示了Election.read_value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import read_value [as 别名]
class SessionContext:

    def __init__(self, sessid):
        if not sessid:
            raise ValueError("Missing sessid")
        self.__key = [evcommon.IDSPOOL, sessid]
        self.__reg = Election().get_root_reg()

    def store_session(self, cert):
        self.__reg.ensure_key(self.__key)
        self.__reg.create_value(self.__key, "cert", cert)
        self.__reg.create_integer_value(self.__key, "start", int(time.time()))

    def check_session(self, cert):
        if not self.__reg.check(self.__key):
            return evcommon.EVOTE_ERROR, evmessage.EV_ERRORS.SEANSS_PUUDUB

        start = self.__reg.read_integer_value(self.__key, "start").value
        length = Election().get_session_length() * 60
        if start + length < int(time.time()):
            return evcommon.EVOTE_ERROR, evmessage.EV_ERRORS.SEANSS_PUUDUB

        if self.__reg.read_value(self.__key, "cert").value != cert:
            evlog.log_error('Sertifikaat muutus')
            return evcommon.EVOTE_CERT_ERROR, evmessage.EV_ERRORS.TEHNILINE_VIGA

        return evcommon.EVOTE_OK, None

    def kill(self):
        self.__reg.ensure_no_key(self.__key)
开发者ID:Augustyn,项目名称:evalimine,代码行数:32,代码来源:hesdisp.py

示例2: __init__

# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import read_value [as 别名]
class MobileIDContext:

    phoneno = None
    lang = None
    challenge = None
    midsess = None
    origvote = None
    votefiles = {}
    __sessid = None
    __reg = None

    def __init__(self, sessid):
        if sessid == None:
            raise Exception('Puuduv sessiooniidentifikaator')
        self.__sessid = sessid
        self.__reg = Election().get_root_reg()
        self.lang = 'EST'

    def sessid(self):
        return self.__sessid

    def kill(self):
        self.__reg.ensure_no_key([evcommon.MIDSPOOL, self.__sessid])

    def set_phone(self, phone):
        self.phoneno = phone

    def set_origvote(self, hv):
        self.origvote = hv

    def get_origvote(self):
        self.origvote = self.__reg.read_value(\
                            [evcommon.MIDSPOOL, self.__sessid], \
                                                    'origvote').value
        return self.origvote

    def add_votefile(self, filename, data):
        self.votefiles[filename] = data

    def get_votefiles(self):
        for key in self.__reg.list_keys([evcommon.MIDSPOOL, self.__sessid, \
                'votefiles']):
            self.votefiles[key] = self.__reg.read_value(\
                    [evcommon.MIDSPOOL, self.__sessid, 'votefiles'], key).value
        return self.votefiles

    def generate_challenge(self):
        self.challenge = binascii.b2a_hex(os.urandom(10))

    def verify_challenge(self, signature):
        return challenge_ok(self.certificate(), self.mychallenge(), \
                            self.ourchallenge(), signature)

    def mychallenge(self):
        return self.__reg.read_value(\
                            [evcommon.MIDSPOOL, self.__sessid], \
                                    'mychallenge').value

    def ourchallenge(self):
        return self.__reg.read_value(\
                            [evcommon.MIDSPOOL, self.__sessid], \
                                    'ourchallenge').value

    def certificate(self):
        return self.__reg.read_value(\
                            [evcommon.MIDSPOOL, self.__sessid], \
                                    'cert').value

    def set_auth_succ(self):
        self.__reg.ensure_key([evcommon.MIDSPOOL, self.__sessid, 'authsucc'])

    def auth_succ(self):
        return self.__reg.check(\
                [evcommon.MIDSPOOL, self.__sessid, 'authsucc'])

    def save_post_auth(self, rsp):

        self.__reg.reset_key([evcommon.MIDSPOOL, self.__sessid])
        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], \
                        'cert', rsp._CertificateData)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], \
                        'phone', self.phoneno)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], \
                        'midsess', rsp._Sesscode)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], \
                        'mychallenge', self.challenge)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], \
                        'ourchallenge', rsp._Challenge)

    def load_pre_sign(self):
        self.phoneno = self.__reg.read_value(\
                [evcommon.MIDSPOOL, self.__sessid], 'phone').value

    def save_post_sign(self, midsess):
        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], \
                        'midsess', midsess)
#.........这里部分代码省略.........
开发者ID:IGBAnet,项目名称:evalimine,代码行数:103,代码来源:middisp.py

示例3: __init__

# 需要导入模块: from election import Election [as 别名]
# 或者: from election.Election import read_value [as 别名]
class MobileIDContext:

    phoneno = None
    lang = None
    challenge = None
    midsess = None
    origvote = None
    votefiles = {}
    __sessid = None
    __reg = None

    def __init__(self, sessid):
        if sessid is None:
            raise Exception("Puuduv sessiooniidentifikaator")
        self.__sessid = sessid
        self.__reg = Election().get_root_reg()
        self.lang = "EST"

    def sessid(self):
        return self.__sessid

    def kill(self):
        self.__reg.ensure_no_key([evcommon.MIDSPOOL, self.__sessid])

    def set_phone(self, phone):
        self.phoneno = phone

    def set_origvote(self, hv):
        self.origvote = hv

    def get_origvote(self):
        self.origvote = self.__reg.read_value([evcommon.MIDSPOOL, self.__sessid], "origvote").value
        return self.origvote

    def add_votefile(self, filename, data):
        self.votefiles[filename] = data

    def get_votefiles(self):
        for key in self.__reg.list_keys([evcommon.MIDSPOOL, self.__sessid, "votefiles"]):
            self.votefiles[key] = self.__reg.read_value([evcommon.MIDSPOOL, self.__sessid, "votefiles"], key).value
        return self.votefiles

    def generate_challenge(self):
        self.challenge = binascii.b2a_hex(os.urandom(10))

    def verify_challenge(self, signature):
        return challenge_ok(self.certificate(), self.mychallenge(), self.ourchallenge(), signature)

    def mychallenge(self):
        return self.__reg.read_value([evcommon.MIDSPOOL, self.__sessid], "mychallenge").value

    def ourchallenge(self):
        return self.__reg.read_value([evcommon.MIDSPOOL, self.__sessid], "ourchallenge").value

    def certificate(self):
        return self.__reg.read_value([evcommon.MIDSPOOL, self.__sessid], "cert").value

    def set_auth_succ(self):
        self.__reg.ensure_key([evcommon.MIDSPOOL, self.__sessid, "authsucc"])

    def auth_succ(self):
        return self.__reg.check([evcommon.MIDSPOOL, self.__sessid, "authsucc"])

    def check_session(self):
        if not self.__reg.check([evcommon.MIDSPOOL, self.__sessid]):
            return False
        start = self.__reg.read_integer_value([evcommon.MIDSPOOL, self.__sessid], "start").value
        length = Election().get_session_length() * 60
        return start + length >= int(time.time()) and self.auth_succ()

    def save_post_auth(self, rsp):

        self.__reg.reset_key([evcommon.MIDSPOOL, self.__sessid])
        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], "cert", rsp._CertificateData)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], "phone", self.phoneno)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], "midsess", rsp._Sesscode)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], "mychallenge", self.challenge)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], "ourchallenge", rsp._Challenge)

        self.__reg.create_integer_value([evcommon.MIDSPOOL, self.__sessid], "start", int(time.time()))

    def load_pre_sign(self):
        self.phoneno = self.__reg.read_value([evcommon.MIDSPOOL, self.__sessid], "phone").value

    def save_post_sign(self, midsess):
        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], "midsess", midsess)

        self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid], "origvote", self.origvote)

        self.__reg.ensure_key([evcommon.MIDSPOOL, self.__sessid, "votefiles"])
        for el in self.votefiles:
            self.__reg.create_value([evcommon.MIDSPOOL, self.__sessid, "votefiles"], el, self.votefiles[el])

    def load_pre_poll(self):
        self.midsess = int(self.__reg.read_value([evcommon.MIDSPOOL, self.__sessid], "midsess").value)
开发者ID:Robin--,项目名称:evalimine,代码行数:101,代码来源:middisp.py


注:本文中的election.Election.read_value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。