self._write_file(newdata)
rc = 0
if post_edit_hook:
- # FIXME: what's the std way to perform shell quoting in python?
- cmd = ( post_edit_hook
- + " '" + data_dir + '/' + self.page_name
- + "' '" + remote_user()
- + "' '" + remote_host()
- + "' '" + changelog + "'"
- )
- out = os.popen(cmd)
- output = out.read()
- rc = out.close()
+ import subprocess
+ cmd = [ post_edit_hook, data_dir + '/' + self.page_name, remote_user(), remote_host(), changelog]
+ child = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
+ output = child.stdout.read()
+ rc = child.wait()
if rc:
self.msg_text += "Post-editing hook returned %d.\n" % rc
- self.msg_text += 'Command was: ' + cmd + '\n'
+ self.msg_text += 'Command was: ' + ' '.join(cmd) + '\n'
if output:
self.msg_text += 'Output follows:\n' + output
else: