checking the return code using python (MAC)

Posted by cyberbemon on Stack Overflow See other posts from Stack Overflow or by cyberbemon
Published on 2012-08-30T15:27:40Z Indexed on 2012/08/30 15:38 UTC
Read the original article Hit count: 145

Filed under:
|
|

I have written a script that checks if an SVN Repo is up and running, the result is based on the return value.

import subprocess

url = " validurl"


def check_svn_status():
    subprocess.call(['svn info'+url],shell=True)

def get_status():
    subprocess.call('echo $?',shell=True)



def main():
    check_svn_status()
    get_status()


if __name__ == '__main__':
    main()

The problem I'm facing is that if I change the url to something that does't exist I still get the return value as 0, but if I were to run this outside the script, i.e go to the terminal type svn info wrong url and then do a echo $? I get a return value of 1. But I can't re-create this in the python. Any guidelines ?

© Stack Overflow or respective owner

Related posts about python

Related posts about svn