From 06653e2489969feaf8ec69fc449187eaf30ea525 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Wed, 8 Apr 2009 23:52:04 +0200 Subject: [PATCH] Use subprocess rather than os.popen --- geekigeeki.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/geekigeeki.py b/geekigeeki.py index cc03736..eba4467 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -779,19 +779,14 @@ class Page: 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: -- 2.25.1