How to check if a Git remote repository is available in python
This simple python code shows how to check if a given Git remote repository is available.
The code invokes the git command 'git ls-remote' on the remote URL path as subprocess with Popen and checks the exit code, using the communicate() method.
The command exit status is stored into the 'returncode' property.
A value not-equals to '0' means the command returned with errors.
post this code
from subprocess import Popen, PIPE, STDOUT
p = Popen(["git", "ls-remote", "git://remote_path"], stdout=PIPE)
output = p.communicate()
if p.returncode != 0:
print "Command failed ["+str(p.returncode)+"]"
If you want to be updated about similar snippets,
and follow our Channels