Skip to content

Order script configurations #474

@Gamma-Software

Description

@Gamma-Software

I needed to organize my runners/scripts.json; so I added folders into the runners’ folder such as:

- conf
    - runners
        - run.json
        - run2.json
        - folder1
            - run_in_folder.json
            - run2_in_folder.json
        - folder2
            - run_in_folder2.json
            - run2_in_folder2.json

By default, Script-server does not handle recursive search of runners so I ended up modifying "src/config/config_service.py" and updating the _visit_script_configs method with:

def _visit_script_configs(self, visitor):
        configs_dir = self._script_configs_folder
        files = list()
        for (dirpath, dirnames, filenames) in os.walk(configs_dir):
            files += [os.path.join(dirpath, file) for file in filenames]

        configs = [file for file in files if file.lower().endswith(".json")]

        result = []

        for config_path in configs:

            try:
                content = file_utils.read_file(config_path)

                visit_result = visitor(config_path, content)
                if visit_result is not None:
                    result.append(visit_result)

            except StopIteration as e:
                if e.value is not None:
                    result.append(e.value)

            except:
                LOGGER.exception("Couldn't read the file: " + config_path)

        return result

What do you think of the idea ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions