From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1MsL0c-0001aS-EO for garchives@archives.gentoo.org; Mon, 28 Sep 2009 18:31:40 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F207FE0826; Mon, 28 Sep 2009 18:31:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 78247E0826 for ; Mon, 28 Sep 2009 18:31:37 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id AA8DD67925 for ; Mon, 28 Sep 2009 18:31:36 +0000 (UTC) Received: from grobian by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1MsL0a-0004zw-CH for gentoo-commits@lists.gentoo.org; Mon, 28 Sep 2009 18:31:36 +0000 To: gentoo-commits@lists.gentoo.org From: "Fabian Groffen (grobian)" Subject: [gentoo-commits] portage r14456 - in main/branches/prefix: bin pym/_emerge pym/portage pym/portage/dbapi pym/portage/tests/bin X-VCS-Repository: portage X-VCS-Revision: 14456 X-VCS-Files: main/branches/prefix/bin/dispatch-conf main/branches/prefix/pym/_emerge/actions.py main/branches/prefix/pym/_emerge/depgraph.py main/branches/prefix/pym/portage/__init__.py main/branches/prefix/pym/portage/dbapi/__init__.py main/branches/prefix/pym/portage/tests/bin/setup_env.py main/branches/prefix/pym/portage/tests/bin/test_dobin.py main/branches/prefix/pym/portage/tests/bin/test_dodir.py X-VCS-Directories: bin pym/_emerge pym/portage pym/portage/dbapi pym/portage/tests/bin X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen Content-Type: text/plain; charset=UTF-8 Message-Id: Sender: Fabian Groffen Date: Mon, 28 Sep 2009 18:31:36 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 6c322c5d-656c-4c91-b250-8e9249f191a9 X-Archives-Hash: 531cce16774f47e7a7dca9ec760b804f Author: grobian Date: 2009-09-28 18:31:35 +0000 (Mon, 28 Sep 2009) New Revision: 14456 Modified: main/branches/prefix/bin/dispatch-conf main/branches/prefix/pym/_emerge/actions.py main/branches/prefix/pym/_emerge/depgraph.py main/branches/prefix/pym/portage/__init__.py main/branches/prefix/pym/portage/dbapi/__init__.py main/branches/prefix/pym/portage/tests/bin/setup_env.py main/branches/prefix/pym/portage/tests/bin/test_dobin.py main/branches/prefix/pym/portage/tests/bin/test_dodir.py Log: Merged from trunk -r14442:14455 | 14445 | Use mkdtemp() instead of hardcoded = | | zmedico | pym/portage/tests/bin/root directory. = | =20 | 14446 | Use explicit imports instead of *. = | | zmedico | = | =20 | 14447 | Fix binTestsInit() to use correct values for = | | zmedico | PORTAGE_BIN_PATH and PORTAGE_PYM_PATH. = | =20 | 14448 | Use catsplit() instead of a regex to generate = | | zmedico | dbapi._categories. Thanks to Marat Radchenko = | | | for this patch. = | =20 | 14449 | Make _test_pty_eof() use non-blocking IO, required for = | | zmedico | Darwin kernel. = | =20 | 14450 | Fix TypeError in clear_screen() in dispatch-conf which = | | arfrever | occurs when Python 3 is used (bug #286682). = | =20 | 14451 | Make _test_pty_eof() fork when writing to the slave_fd, = | | zmedico | since otherwise it would block on some platforms such as = | | | Darwin. = | =20 | 14452 | In _test_pty_eof(), call waitpid on the child process onl= y | | zmedico | after reading all the data from the pty. = | =20 | 14453 | Try to avoid blocking on Darwin in _test_pty_eof() by usi= ng | | zmedico | slave_fd directly instead of fdopen. = | =20 | 14454 | Make _test_pty_eof() call process.spawn() instead of = | | zmedico | os.fork(). = | =20 | 14455 | Fix breakage in file path -> package lookup code. = | | zmedico | = | Modified: main/branches/prefix/bin/dispatch-conf =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/bin/dispatch-conf 2009-09-28 01:50:14 UTC (rev 1= 4455) +++ main/branches/prefix/bin/dispatch-conf 2009-09-28 18:31:35 UTC (rev 1= 4456) @@ -36,6 +36,7 @@ =20 from portage import os from portage import dispatch_conf +from portage import _unicode_decode from portage.process import find_binary from portage.const import EPREFIX =20 @@ -399,7 +400,7 @@ import curses try: curses.setupterm() - sys.stdout.write(curses.tigetstr("clear")) + sys.stdout.write(_unicode_decode(curses.tigetstr("clear"))) sys.stdout.flush() return except curses.error: Modified: main/branches/prefix/pym/_emerge/actions.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/_emerge/actions.py 2009-09-28 01:50:14 UTC (= rev 14455) +++ main/branches/prefix/pym/_emerge/actions.py 2009-09-28 18:31:35 UTC (= rev 14456) @@ -2319,7 +2319,7 @@ for x in lookup_owners: if not search_for_multiple and os.path.isdir(x): search_for_multiple =3D True - relative_paths.append(x[len(root):]) + relative_paths.append(x[len(root)-1:]) =20 owners =3D set() for pkg, relative_path in \ Modified: main/branches/prefix/pym/_emerge/depgraph.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/_emerge/depgraph.py 2009-09-28 01:50:14 UTC = (rev 14455) +++ main/branches/prefix/pym/_emerge/depgraph.py 2009-09-28 18:31:35 UTC = (rev 14456) @@ -1578,7 +1578,7 @@ for x in lookup_owners: if not search_for_multiple and os.path.isdir(x): search_for_multiple =3D True - relative_paths.append(x[len(myroot):]) + relative_paths.append(x[len(myroot)-1:]) =20 owners =3D set() for pkg, relative_path in \ Modified: main/branches/prefix/pym/portage/__init__.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/__init__.py 2009-09-28 01:50:14 UTC = (rev 14455) +++ main/branches/prefix/pym/portage/__init__.py 2009-09-28 18:31:35 UTC = (rev 14456) @@ -3762,7 +3762,7 @@ Raises an EnvironmentError from openpty() if it fails. """ =20 - import array, pty, termios + import array, fcntl, pty, select, termios test_string =3D 2 * "blah blah blah\n" test_string =3D _unicode_decode(test_string, encoding=3D'utf_8', errors=3D'strict') @@ -3770,8 +3770,9 @@ # may raise EnvironmentError master_fd, slave_fd =3D pty.openpty() =20 - master_file =3D os.fdopen(master_fd, 'rb') - slave_file =3D os.fdopen(slave_fd, 'wb') + # Non-blocking mode is required for Darwin kernel. + fcntl.fcntl(master_fd, fcntl.F_SETFL, + fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK) =20 # Disable post-processing of output since otherwise weird # things like \n -> \r\n transformations may occur. @@ -3780,16 +3781,33 @@ termios.tcsetattr(slave_fd, termios.TCSANOW, mode) =20 # Simulate a subprocess writing some data to the - # slave end of the pipe, and then exiting. - slave_file.write(_unicode_encode(test_string, - encoding=3D'utf_8', errors=3D'strict')) - slave_file.close() + # slave end of the pipe, and then exiting. Do a + # real fork here since otherwise os.close(slave_fd) + # would block on some platforms such as Darwin. + pids =3D process.spawn_bash(_unicode_encode("echo -n '%s'" % test_strin= g, + encoding=3D'utf_8', errors=3D'strict'), env=3Dos.environ, + fd_pipes=3D{0:sys.stdin.fileno(), 1:slave_fd, 2:slave_fd}, + returnpid=3DTrue) + if isinstance(pids, int): + os.close(master_fd) + os.close(slave_fd) + raise EnvironmentError('spawn failed') + os.close(slave_fd) =20 + master_file =3D os.fdopen(master_fd, 'rb') eof =3D False data =3D [] + iwtd =3D [master_file] + owtd =3D [] + ewtd =3D [] =20 while not eof: =20 + events =3D select.select(iwtd, owtd, ewtd) + if not events[0]: + eof =3D True + break + buf =3D array.array('B') try: buf.fromfile(master_file, 1024) @@ -3805,6 +3823,7 @@ data.append(_unicode_decode(buf.tostring(), encoding=3D'utf_8', errors=3D'strict')) =20 + os.waitpid(pids[0], 0) master_file.close() =20 return test_string =3D=3D ''.join(data) Modified: main/branches/prefix/pym/portage/dbapi/__init__.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/dbapi/__init__.py 2009-09-28 01:50:1= 4 UTC (rev 14455) +++ main/branches/prefix/pym/portage/dbapi/__init__.py 2009-09-28 18:31:3= 5 UTC (rev 14456) @@ -12,7 +12,7 @@ 'portage.locks:unlockfile', 'portage.output:colorize', 'portage.util:cmp_sort_key,writemsg', - 'portage.versions:catpkgsplit,vercmp', + 'portage.versions:catsplit,catpkgsplit,vercmp', ) =20 from portage import os @@ -39,11 +39,8 @@ """ if self._categories is not None: return self._categories - categories =3D set() - cat_pattern =3D re.compile(r'(.*)/.*') - for cp in self.cp_all(): - categories.add(cat_pattern.match(cp).group(1)) - self._categories =3D tuple(sorted(categories)) + self._categories =3D tuple(sorted(set(catsplit(x)[0] \ + for x in self.cp_all()))) return self._categories =20 def close_caches(self): Modified: main/branches/prefix/pym/portage/tests/bin/setup_env.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/tests/bin/setup_env.py 2009-09-28 01= :50:14 UTC (rev 14455) +++ main/branches/prefix/pym/portage/tests/bin/setup_env.py 2009-09-28 18= :31:35 UTC (rev 14456) @@ -3,34 +3,45 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ =20 +import tempfile + from portage import os from portage import shutil from portage.tests import TestCase from portage.process import spawn -from portage.const import PORTAGE_BIN_PATH =20 -bindir =3D os.path.join(os.path.dirname(os.path.dirname( +basepath =3D os.path.join(os.path.dirname(os.path.dirname( os.path.abspath(__file__))), - "..", "..", "..", "bin", "ebuild-helpers") -basedir =3D os.path.join(os.path.dirname(os.path.dirname( - os.path.abspath(__file__))), "bin", "root") -os.environ["D"] =3D os.path.join(basedir, "image") -os.environ["T"] =3D os.path.join(basedir, "temp") -os.environ["S"] =3D os.path.join(basedir, "workdir") -os.environ["PF"] =3D "portage-tests-0.09-r1" -os.environ["PATH"] =3D bindir + ":" + os.environ["PATH"] -os.environ["PORTAGE_BIN_PATH"] =3D PORTAGE_BIN_PATH + "..", "..", "..") +bindir =3D os.path.join(basepath, "bin") +pymdir =3D os.path.join(basepath, "pym") +basedir =3D None +env =3D None =20 def binTestsCleanup(): + global basedir + if basedir is None: + return if os.access(basedir, os.W_OK): shutil.rmtree(basedir) + basedir =3D None + def binTestsInit(): binTestsCleanup() - os.mkdir(basedir) - os.mkdir(os.environ["D"]) - os.mkdir(os.environ["T"]) - os.mkdir(os.environ["S"]) - os.chdir(os.environ["S"]) + global basedir, env + basedir =3D tempfile.mkdtemp() + env =3D os.environ.copy() + env["D"] =3D os.path.join(basedir, "image") + env["T"] =3D os.path.join(basedir, "temp") + env["S"] =3D os.path.join(basedir, "workdir") + env["PF"] =3D "portage-tests-0.09-r1" + env["PATH"] =3D bindir + ":" + env["PATH"] + env["PORTAGE_BIN_PATH"] =3D bindir + env["PORTAGE_PYM_PATH"] =3D pymdir + os.mkdir(env["D"]) + os.mkdir(env["T"]) + os.mkdir(env["S"]) + os.chdir(env["S"]) =20 class BinTestCase(TestCase): def __init__(self, methodName): @@ -43,7 +54,7 @@ =20 def _exists_in_D(path): # Note: do not use os.path.join() here, we assume D to end in / - return os.access(os.environ["D"] + path, os.W_OK) + return os.access(env["D"] + path, os.W_OK) def exists_in_D(path): if not _exists_in_D(path): raise TestCase.failureException @@ -54,9 +65,10 @@ def portage_func(func, args, exit_status=3D0): # we don't care about the output of the programs, # just their exit value and the state of $D + global env f =3D open('/dev/null', 'wb') fd_pipes =3D {0:0,1:f.fileno(),2:f.fileno()} - spawn(func+" "+args, env=3Dos.environ, fd_pipes=3Dfd_pipes) + spawn([func] + args.split(), env=3Denv, fd_pipes=3Dfd_pipes) f.close() =20 def create_portage_wrapper(bin): @@ -66,9 +78,10 @@ return portage_func(*newargs) return derived_func =20 -for bin in os.listdir(bindir): +for bin in os.listdir(os.path.join(bindir, "ebuild-helpers")): if bin.startswith("do") or \ bin.startswith("new") or \ bin.startswith("prep") or \ bin in ["ecompress","ecompressdir","fowners","fperms"]: - globals()[bin] =3D create_portage_wrapper(bin) + globals()[bin] =3D create_portage_wrapper( + os.path.join(bindir, "ebuild-helpers", bin)) Modified: main/branches/prefix/pym/portage/tests/bin/test_dobin.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/tests/bin/test_dobin.py 2009-09-28 0= 1:50:14 UTC (rev 14455) +++ main/branches/prefix/pym/portage/tests/bin/test_dobin.py 2009-09-28 1= 8:31:35 UTC (rev 14456) @@ -3,7 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ =20 -from portage.tests.bin.setup_env import * +from portage.tests.bin.setup_env import BinTestCase, dobin, xexists_in_D =20 class DoBin(BinTestCase): def testDoBin(self): Modified: main/branches/prefix/pym/portage/tests/bin/test_dodir.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/tests/bin/test_dodir.py 2009-09-28 0= 1:50:14 UTC (rev 14455) +++ main/branches/prefix/pym/portage/tests/bin/test_dodir.py 2009-09-28 1= 8:31:35 UTC (rev 14456) @@ -3,7 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ =20 -from portage.tests.bin.setup_env import * +from portage.tests.bin.setup_env import BinTestCase, dodir, exists_in_D =20 class DoDir(BinTestCase): def testDoDir(self):