I'm trying to run 'svn update' on a given directory as a subprocess in python. I need to redirect the output of this process (svn update) to a file called updste.txt. And if 'svn update' fails, I'm trying to send out a mail to myself with the file content as message body. Please let me know how can i do that.
Following is the method which i call from my main() as
svn_update('<some absolute path>')
def svn_update(path): os.chdir(path) # execute the 'svn update' and pipe the result to a string test = "svn update --username mallik --password mallik" process = subprocess.Popen(test, shell=True, stdout=subprocess.PIPE) # give it time to respond process.wait() # check (0 --> success) if process.returncode == 0: print "successfully updated avm folder : ", path else: print "svn update failed for folder : ", path msg = open("update.txt") server.sendmail(FROM, TO, msg.read()) server.quit() sys.exit("Exiting...")
Please reply me soon...