示例#1
0
    def getLanguages(self):
        sects = self.config.sections()

        ret_map = {}
        try:
            for id,sect in enumerate(sects):
                name = self.config.get(sect, 'Name',None)
                ret_map[id] = (sect, unicode(name.decode('utf8')))
        except Exception, err:
            print err
            raise Exception(MESSAGES.get(105,'Config file corrupted!'))
示例#2
0
    def close_session(cls):
        if not Config.getSessionID():
            return

        iface = cls.get_interface('FABLIK_BASE')

        inputVar = iface.create_variable('RequestCloseSession', session_id=Config.getSessionID())

        result = iface.call('closeSession', inputVar)

        if result.ret_code != 0:
            message = MESSAGES.get(result.ret_code, result.ret_message)
            raise Exception(message)
示例#3
0
    def load_interfaces(cls, base_iface):
        inputVar = base_iface.create_variable('RequestGetInterfaces', session_id=Config.getSessionID())

        result = base_iface.call('getInterfaces', inputVar)

        if result.ret_code != 0:
            message = MESSAGES.get(result.ret_code, result.ret_message)
            raise Exception(message)

        if len(result.interface_list) == 0:
            return

        for interface in result.interface_list.interface:
            cls.interfaces[interface.sid] = interface.url
示例#4
0
    def authenticate(cls, username, password):
        iface = cls.get_interface('FABLIK_BASE')
        inputVar = iface.create_variable('RequestAuthenticate', login=username, password=password)

        result = iface.call('authenticate', inputVar)

        if result.ret_code != 0:
            message = MESSAGES.get(result.ret_code, result.ret_message)
            raise Exception(message)

        Config.setSessionID( result.session_id )
        Config.USER_NAME = username
        Config.USER_PASSWORD = password

        Config.ismod = True
        Config.save_config()

        cls.load_interfaces(iface)
示例#5
0
 def getLanguage(self, lang_sid):
     try:
         name = self.config.get(lang_sid, 'Name',None)
         filename = self.config.get(lang_sid, 'TranslateFile',None)
     except Exception, err:
         raise Exception(MESSAGES.get(105,'Config file corrupted!'))