コード例 #1
0
        def load_script(path, content):
            try:
                json_object = json.loads(content)
                short_config = script_config.read_short(path, json_object)

                if short_config is None:
                    return None

                if not conf_service._can_access_script(user, short_config):
                    return None

                return short_config
            except:
                LOGGER.exception('Could not load script: ' + path)
コード例 #2
0
ファイル: config_service.py プロジェクト: bugy/script-server
        def load_script(path, content):
            try:
                json_object = json.loads(content)
                short_config = script_config.read_short(path, json_object)

                if short_config is None:
                    return None

                if not conf_service._can_access_script(user, short_config):
                    return None

                return short_config
            except:
                LOGGER.exception('Could not load script: ' + path)
コード例 #3
0
        def find_and_load(path, content):
            try:
                json_object = json.loads(content)
                short_config = script_config.read_short(path, json_object)

                if short_config is None:
                    return None
            except:
                LOGGER.exception('Could not load script config: ' + path)
                return None

            if short_config.name != name.strip():
                return None

            raise StopIteration((short_config, path, json_object))
コード例 #4
0
ファイル: config_service.py プロジェクト: bugy/script-server
        def find_and_load(path, content):
            try:
                json_object = json.loads(content)
                short_config = script_config.read_short(path, json_object)

                if short_config is None:
                    return None
            except:
                LOGGER.exception('Could not load script config: ' + path)
                return None

            if short_config.name != name:
                return None

            raise StopIteration((short_config, path, json_object))
コード例 #5
0
    def update_config(self, user, config, filename, uploaded_script):
        self._check_admin_access(user)

        _preprocess_incoming_config(config)

        if is_blank(filename):
            raise InvalidConfigException('Script filename should be specified')

        original_file_path = os.path.join(self._script_configs_folder,
                                          filename)

        if not os.path.exists(original_file_path):
            raise InvalidFileException(
                original_file_path,
                'Failed to find script path: ' + original_file_path)

        with open(original_file_path, 'r') as f:
            original_config_json = json.load(f)
            short_original_config = script_config.read_short(
                original_file_path, original_config_json)

        name = config['name']

        search_result = self._find_config(name)
        if (search_result is not None) and (os.path.basename(
                search_result.path) != filename):
            raise InvalidConfigException(
                'Another script found with the same name: ' + name)

        if not self._can_edit_script(user, short_original_config):
            raise ConfigNotAllowedException(
                str(user) + ' is not allowed to modify ' +
                short_original_config.name)

        self._preprocess_script_fields(config, original_config_json,
                                       uploaded_script, user)

        LOGGER.info('Updating script config "' + name + '" in ' +
                    original_file_path)
        self._save_config(config, original_file_path)