Skip to content
Snippets Groups Projects
Commit f9a26ae9 authored by Ronald Jäpel's avatar Ronald Jäpel
Browse files

add ability to run python files and arbitrary commands from the CLI

parent 1e9d4ac0
No related branches found
No related tags found
No related merge requests found
import shlex
import subprocess
import click
from .repositories import ProjectRepo
......@@ -47,6 +50,26 @@ def fill_data_from_cadet_rdm_json(re_load=False):
repo.fill_data_from_cadet_rdm_json(re_load=re_load)
@cli.command()
@click.argument('file_name')
@click.argument('results_commit_message')
def run_python_file(file_name, results_commit_message):
repo = ProjectRepo(".")
repo.enter_context()
subprocess.run(["python", file_name])
repo.exit_context(results_commit_message)
@cli.command()
@click.argument('command')
@click.argument('results_commit_message')
def run_command(command, results_commit_message):
repo = ProjectRepo(".")
repo.enter_context()
subprocess.run(shlex.split(command))
repo.exit_context(results_commit_message)
@cli.command()
@click.option('--output_repo_name', default="output",
help='Name of the folder where the tracked output should be stored. Optional. Default: "output".')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment