From 4117452de5b810861a877a6a4e751bebf97c1e01 Mon Sep 17 00:00:00 2001 From: Bogdano Arendartchuk Date: Fri, 17 Apr 2009 17:24:30 +0000 Subject: Use the subprocess module, as popen is deprecated on py2.6 --- BuildManager/build.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'BuildManager') diff --git a/BuildManager/build.py b/BuildManager/build.py index 8fed7b0..9279d17 100644 --- a/BuildManager/build.py +++ b/BuildManager/build.py @@ -2,10 +2,7 @@ from BuildManager.fileutil import * from BuildManager.package import * from BuildManager import * import thread -import popen2 -import select -import fcntl -import thread +import subprocess import sys, os import time import shutil @@ -204,22 +201,18 @@ def buildpkg(pkg, stage, unpack_dir, passtrough="", show_log=0, dryrun=0): logger.debug("rpmbuild command: "+cmd) if not dryrun: log = open(pkg.log, "w") - pop = popen2.Popen3(cmd) - fc = pop.fromchild - flags = fcntl.fcntl (fc.fileno(), fcntl.F_GETFL, 0) - flags = flags | os.O_NONBLOCK - fcntl.fcntl (fc.fileno(), fcntl.F_SETFL, flags) - while 1: - r,w,x = select.select([fc.fileno()], [], [], 2) - if r: - data = fc.read() - if show_log: - sys.stdout.write(data) - log.write(data) - log.flush() + pop = subprocess.Popen(cmd, shell=True, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + of = pop.stdout.fileno() + while True: status = pop.poll() - if status != -1: + if status is not None: break + data = os.read(of, 8192) + log.write(data) + log.flush() + if show_log: + sys.stdout.write(data) log.close() if status == 0: logger.info("succeeded!") -- cgit v1.2.1