I am executing a bash command (that downloads a file) inside a Python script.
def execBashCmd(bash_cmd):
process = Popen([bash_cmd], stdout=PIPE, stderr=PIPE, shell=True)
The bash command outputs a progression (refreshed) in stdout as follow:
Downloading File - 20.66 MiB/165.31 MiB
I would like to be able to call a python function at a regular interval to update the progression (that I would catch with a regex or something like this) somewhere in my python code.
cmd = "gsutil cp -n ...." # A Bash command downloading a file and displaying a status in stdout while busy.
code = utils.execBashCmd(cmd)
self.setProgress(BASH_CURRENT_PROGRESS) # This line should be asynchrone and called upon the bash command lifetime
Is there a way to achieve this?