示例#1
0
    def execute(self, task):

        response = self.empty_response(task)

        # READING OF SERVER OBJECT LIST
        if task['name'] == const.__SPL_F_GET_OBJECTS__:
            response['data'] = Framework.getObjects()
            response['result'] = True

        # READING OF SERVER WIDGETS LIST
        if task['name'] == const.__SPL_F_GET_WIDGETS__:
            response['data'] = {}
            response['result'] = True

        # READING OF SERVER SELFTEST RESULTS
        if task['name'] == const.__SPL_F_GET_SELFTEST__:
            response['data'] = True
            response['result'] = True

        # READING OF SERVER INFORMATIONS
        if task['name'] == const.__SPL_F_GET_INFOS__:
            response['data'] = Framework.getClientInfo().get()
            response['result'] = True

        return response
示例#2
0
    def execute(self, task):
        """Execute Objects Actions"""
        response = self.empty_response(task)

        # READING OF SERVER OBJECT LIST
        if task['name'] == const.__SPL_F_OBJECTS__:
            response['data'] = Framework.getObjects()
            response['result'] = True
            return response

        # Validate Received Task
        if not self.isValidTask(task):
            return response

        # Execute Admin Actions
        if task['name'] in [
                const.__SPL_F_DESC__, const.__SPL_F_FIELDS__,
                const.__SPL_F_LIST__
        ]:
            return self.doAdminActions(task)

        # Execute Sync Actions
        if task['name'] in [
                const.__SPL_F_GET__, const.__SPL_F_SET__, const.__SPL_F_DEL__
        ]:
            return self.doSyncActions(task)

        # Wrong Request Task
        Framework.log().error("Object Router - Requested task not found => " +
                              task['name'])

        return response
示例#3
0
    def isValidTask(task):
        """Verify Received Task"""
        # Verify Requested Object Type is Available
        if not hasattr(task["params"], '__iter__'):
            return Framework.log().error(
                "Object Router - Missing Task Parameters... ")
        # Verify Requested Object Type is Available
        if 'type' not in task["params"]:
            return Framework.log().error(
                "Object Router - Missing Object Type... ")
        # Verify Requested Object Type is Valid
        if not task["params"]['type'] in Framework.getObjects():
            return Framework.log().error(
                "Object Router - Object Type is Invalid... ")

        return True
示例#4
0
    def get_file(self, path, md5):
        # Walk for File on All Registered Objects
        for object_type in Framework.getObjects():
            object_class = Framework.getObject(object_type)
            file = object_class.getFile(path, md5)
            # Verify File was Found
            if file is None or not isinstance(file, dict):
                continue
            # Verify File Md5
            if file['md5'] != md5:
                continue

            return file

        Framework.log().error("File Not Found")

        return None