Reading the return value of external command(subprocess.call))
#1
I am trying to make a script that uses external program to check the status of the system(mythshutdow --status to check the status of mythbackend). However I am not able to get the return value from the program when I run it as a addon, but if I run the same pease of code outside of xbmc then it works.

For example if I run this pease of code on command prompt.
Code:
import subprocess
retVal = subprocess.call("exit 2", shell=True)
print retVal
I get the right output
Code:
python2 default.py
2

But when I run the same pease of code inside xbmc python addon, the retValue is 0. So how can I get the return value of the program?
Reply
#2
Did you find any solution to this problem? I'm facing the exact same issue right now, i. e.
getting the correct returncode when executing a command via subprocess.Popen outside
of xbmc but getting 0 (zero) when executing it inside of xbmc.

Evaluating the return code would be very beneficial as this should be its purpose...

Reply
#3
I do this when I want to chek out what is going on:

Code:
#for debugging, grab the process output....
            #output, result = subprocess.Popen(exe, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=False).communicate()
            #log("$$$$$$$$$$$$$$$ " + str(output))
            #log("$$$$$$$$$$$$$$$ " + str(result))

           #actual process kick off code
            slaveProcess = subprocess.Popen(exe, shell=False)
           #or for windows to prevent shell
           slaveProcess = subprocess.Popen(exe, creationflags=0x08000000,  shell=False)

(the commented stuff lets you grab the output of the program)
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply

Logout Mark Read Team Forum Stats Members Help
Reading the return value of external command(subprocess.call))0