From c1dc172112cf362f5936c6e8be4ee47bdef5aca8 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 2 Mar 2010 21:11:13 +0000 Subject: Move imports to the top and use writemsg_stdout instead of print(). (trunk r15508) svn path=/main/branches/2.1.7/; revision=15706 --- pym/portage/package/ebuild/doebuild.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'pym') diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 184dc46dc..e316c808b 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -2,19 +2,21 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -from __future__ import print_function - __all__ = ['doebuild', 'doebuild_environment', 'spawn', 'spawnebuild'] +import array import codecs import errno +import fcntl from itertools import chain import logging import os as _os import re +import select import shutil import stat import sys +import tempfile from textwrap import wrap import time @@ -523,8 +525,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, # so that there's no need for locking and it can be used even if the # user isn't in the portage group. if mydo in ("info",): - from tempfile import mkdtemp - tmpdir = mkdtemp() + tmpdir = tempfile.mkdtemp() tmpdir_orig = mysettings["PORTAGE_TMPDIR"] mysettings["PORTAGE_TMPDIR"] = tmpdir @@ -620,8 +621,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, noiselevel=-1) return 1 else: - from tempfile import NamedTemporaryFile - fd = NamedTemporaryFile(prefix="exectest-", dir=checkdir) + fd = tempfile.NamedTemporaryFile(prefix="exectest-", dir=checkdir) os.chmod(fd.name, 0o755) if not os.access(fd.name, os.X_OK): writemsg(_("Can not execute files in %s\n" @@ -1002,7 +1002,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, myebuild=mysettings["EBUILD"], mytree=tree, mydbapi=mydbapi, vartree=vartree, prev_mtimes=prev_mtimes) else: - print(_("!!! Unknown mydo: %s") % mydo) + writemsg_stdout(_("!!! Unknown mydo: %s\n") % mydo, noiselevel=-1) return 1 return retval @@ -1188,7 +1188,6 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero # process might have already exited and closed slave_fd so we # have to keep it open in order to avoid FreeBSD potentially # generating an EAGAIN exception). - import fcntl fcntl.fcntl(master_fd, fcntl.F_SETFL, fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK) @@ -1248,7 +1247,6 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero iwtd = [master_file] owtd = [] ewtd = [] - import array, select buffsize = 65536 eof = False while not eof: -- cgit v1.2.3-1-g7c22