Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create helper function to wrap subprocess.run #204

Open
dafyddstephenson opened this issue Dec 20, 2024 · 1 comment
Open

Create helper function to wrap subprocess.run #204

dafyddstephenson opened this issue Dec 20, 2024 · 1 comment
Assignees
Labels
good first issue Good for newcomers internals non-user-facing changes jira-story Auto-create a corresponding story on JIRA

Comments

@dafyddstephenson
Copy link
Contributor

Currently, the following pattern:

        sp_cmd = 'echo 'Hello World"'
        sp_run = subprocess.run(sp_cmd, shell=True, text=True, capture_output=True)
        if sp_run.returncode != 0:
            raise RuntimeError(f"Command {sp_cmd} failed: {sp_run.stderr.strip()}")
        hw = sp_run.stdout.strip()

Can be found all over the place in C-Star.
It would be fairly straightforward to wrap this behaviour in a helper function, reducing each such block to, e.g.:

hw = run_subprocess('echo "Hello World"')

@dafyddstephenson dafyddstephenson added good first issue Good for newcomers internals non-user-facing changes jira-story Auto-create a corresponding story on JIRA labels Dec 20, 2024
@dafyddstephenson dafyddstephenson self-assigned this Dec 20, 2024
Copy link

github-actions bot commented Dec 20, 2024

This issue has been linked to Jira story CW-592.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers internals non-user-facing changes jira-story Auto-create a corresponding story on JIRA
Projects
None yet
Development

No branches or pull requests

1 participant