Get return code from cli

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
pmichelazzo
Posts: 2
Joined: Tue Sep 08, 2020 8:22 am

Get return code from cli

Post 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
mduell
Veteran User
Posts: 7192
Joined: Sat Apr 21, 2007 8:54 pm

Re: Get return code from cli

Post by mduell »

Add capture_output=True to your subprocess.run, then you can inspect the returncode.
pmichelazzo
Posts: 2
Joined: Tue Sep 08, 2020 8:22 am

Re: Get return code from cli

Post by pmichelazzo »

Thanks for the answer. I'll try it.
Best
Post Reply