From beb7ee48ccbda784a15f9e9a3f33005020007913 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 28 Dec 2008 14:29:38 +0000 Subject: [PATCH] Use subprocess instead of deprecated popen2 module --- zeroinstall/0launch-gui/compile.py | 9 +++++---- zeroinstall/gtkui/addbox.py | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/zeroinstall/0launch-gui/compile.py b/zeroinstall/0launch-gui/compile.py index a12a912..cfcf1cf 100644 --- a/zeroinstall/0launch-gui/compile.py +++ b/zeroinstall/0launch-gui/compile.py @@ -1,7 +1,7 @@ # Copyright (C) 2008, Thomas Leonard # See the README file for details, or visit http://0install.net. -import os, popen2 +import os, subprocess import gobject import dialog from logging import info @@ -19,9 +19,10 @@ class Command: def run(self, command, success): assert self.child is None self.success = success - self.child = popen2.Popen4(command) - self.child.tochild.close() - gobject.io_add_watch(self.child.fromchild, gobject.IO_IN | gobject.IO_HUP, self.got_data) + self.child = subprocess.Popen(command, + stdout = subprocess.PIPE, + stderr = subprocess.STDOUT) + gobject.io_add_watch(self.child.stdout, gobject.IO_IN | gobject.IO_HUP, self.got_data) def got_data(self, src, cond): data = os.read(src.fileno(), 100) diff --git a/zeroinstall/gtkui/addbox.py b/zeroinstall/gtkui/addbox.py index 455407e..e235bea 100644 --- a/zeroinstall/gtkui/addbox.py +++ b/zeroinstall/gtkui/addbox.py @@ -108,11 +108,12 @@ class AddBox: return self.window.set_sensitive(False) self.set_keep_above(False) - import popen2 - child = popen2.Popen4(['0launch', + import subprocess + child = subprocess.Popen(['0launch', '--gui', '--download-only', - '--', iface]) - child.tochild.close() + '--', iface], + stdout = subprocess.PIPE, + stderr = subprocess.STDOUT) errors = [''] def output_ready(src, cond): got = os.read(src.fileno(), 100) @@ -135,7 +136,7 @@ class AddBox: box.destroy() return False return True - gobject.io_add_watch(child.fromchild, + gobject.io_add_watch(child.stdout, gobject.IO_IN | gobject.IO_HUP, output_ready) elif resp == gtk.RESPONSE_OK: -- 2.11.4.GIT