Page 1 of 1

Get return code from cli

Posted: Tue Sep 08, 2020 10:17 am
by pmichelazzo
Hello there,

I made a python script to run the cli and convert video files that I produce everyday. The script runs well with all files inside a folder and converting using a specific preset.

But... I would like to catch the return code to send me a message only if the script found an error but, I don't know if the return work result presented on the example below is the right one.

Code: Select all

x264 [info]: kb/s:65.51
[09:47:17] mux: track 0, 15232 frames, 4155508 bytes, 65.47 kbps, fifo 16384
[09:47:17] mux: track 1, 23804 frames, 6249284 bytes, 98.45 kbps, fifo 32768
[09:47:17] Finished work at: Tue Sep  8 09:47:17 2020

[09:47:17] libhb: work result = 0

Encode done!
HandBrake has exited.
Somebody could drive me on the right way for that?

Thanks

Re: Get return code from cli

Posted: Tue Sep 08, 2020 6:39 pm
by mduell
Add capture_output=True to your subprocess.run, then you can inspect the returncode.

Re: Get return code from cli

Posted: Wed Sep 09, 2020 9:35 am
by pmichelazzo
Thanks for the answer. I'll try it.
Best