I have to run a "commit" command through python script and print a message based on its exit or return status.
code is as follows:
import subprocess
msg = 'summary about commit'
commitCommand = 'hg commit -m "{}"'.format(msg)
p = subprocess.Popen(commitCommand, stdout=subprocess.PIPE)
output = p.communicate()[0]
if p.returncode:
print 'commit failed'
sys.exit()
else:
print 'Commit done'
This is giving me following error:
Traceback (most recent call last):
File "script.py", line 66, in <module>
p = subprocess.Popen(commitCommand, stdout=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
how to correct this error?