Hello, I wanted to ask if there is an opportunity...
# ask-community
a
Hello, I wanted to ask if there is an opportunity to specify the execution of commands in the terminal as a task ? I tried to create a function inside which I just call the command I need using python.
Copy code
@task(name="synchronise data")
def sync_data() -> None:
    """Sync data to remote server"""
    print("Start synchronisation")
    rsync_cmd = (
        f"rsync "
        f"-avzx "
        f"--no-perms "
        f"--progress "
        f"{my_data_folder} "
        f"{my_server}:{servers_sync_folder}"
    )

    return None
It works great and logs, but I have no way of knowing if this task has failed with an error. Or not. I can find out about this only by looking through the logs.
Copy code
rsync: [sender] write error: Broken pipe (32)
But python itself believes that the command has completed successfully )
j
that task isn't actually calling the shell command though right? its just constructing a string?
A library like sh might be helpful https://pypi.org/project/sh/ - you can capture stdout into a string and then log it
🙌 1
👍 1
a
@Joshua Greenhalgh Thank you 👍