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 1QqZk6-0001Ij-Jj for garchives@archives.gentoo.org; Tue, 09 Aug 2011 00:00:23 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E972921C071; Tue, 9 Aug 2011 00:00:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 9CABB21C071 for ; Tue, 9 Aug 2011 00:00:14 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C37C41B404C for ; Tue, 9 Aug 2011 00:00:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 147D280044 for ; Tue, 9 Aug 2011 00:00:13 +0000 (UTC) From: "Andrea Arteaga" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrea Arteaga" Message-ID: Subject: [gentoo-commits] proj/auto-numerical-bench:master commit in: / X-VCS-Repository: proj/auto-numerical-bench X-VCS-Files: PortageUtils.py benchconfig.py benchprint.py benchutils.py X-VCS-Directories: / X-VCS-Committer: spiros X-VCS-Committer-Name: Andrea Arteaga X-VCS-Revision: c6b10b2698803d97f41cc2d95c384fcae690361f Date: Tue, 9 Aug 2011 00:00:13 +0000 (UTC) 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: X-Archives-Hash: fdc4c3aaf0c17bd9fb8a0ee920960734 commit: c6b10b2698803d97f41cc2d95c384fcae690361f Author: spiros gmail com> AuthorDate: Mon Aug 8 23:59:39 2011 +0000 Commit: Andrea Arteaga gmail com> CommitDate: Mon Aug 8 23:59:39 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/auto-numerica= l-bench.git;a=3Dcommit;h=3Dc6b10b26 Added main logging. Solved issues with utils and Portage. --- PortageUtils.py | 62 ++++++++++++++++++++++++++++++-------------------= ----- benchconfig.py | 7 +++++- benchprint.py | 21 +++++++++++++++--- benchutils.py | 5 +--- 4 files changed, 58 insertions(+), 37 deletions(-) diff --git a/PortageUtils.py b/PortageUtils.py index 8280d1c..f06c53d 100644 --- a/PortageUtils.py +++ b/PortageUtils.py @@ -8,6 +8,35 @@ class InstallException(Exception): def __init__(self, command, logfile): self.command =3D command self.logfile =3D logfile + =20 +def _getEnv(root=3D'/', envAdds=3D{}): + denv =3D os.environ.copy() + + #PATH + denv['PATH'] =3D ':'.join([pjoin(root, i) for i in ('bin', 'usr/bin'= )]) + if os.environ.has_key('PATH'): + denv['PATH'] +=3D ':' + os.environ['PATH'] + denv['ROOTPATH'] =3D denv['PATH'] + #LIBRARY_PATH + denv['LIBRARY_PATH'] =3D ':'.join([pjoin(root, i) for i in \ + ('usr/lib', 'usr/lib64', 'usr/lib32')]) + if os.environ.has_key('LIBRARY_PATH'): + denv['LIBRARY_PATH'] +=3D ':' + os.environ['LIBRARY_PATH'] + #LD_LIBRARY_PATH + denv['LD_LIBRARY_PATH'] =3D ':'.join([pjoin(root, i) for i in \ + ('usr/lib', 'usr/lib64', 'usr/lib32')]) + if os.environ.has_key('LD_LIBRARY_PATH'): + denv['LD_LIBRARY_PATH'] +=3D ':' + os.environ['LD_LIBRARY_PATH'] + #INCLUDE_PATH + denv['INCLUDE_PATH'] =3D ':'.join([pjoin(root, i) for i in ('usr/inc= lude',)]) + if os.environ.has_key('INCLUDE_PATH'): + denv['INCLUDE_PATH'] +=3D ':' + os.environ['INCLUDE_PATH'] + =20 + # Adds + for k,v in envAdds.items(): + denv[k] =3D v + =20 + return denv =20 def available_packages(pattern): """Returns a list of packages matching the given pattern. @@ -51,9 +80,7 @@ def install_dependencies(package, env=3D{}, root=3D'/', logdir =3D "/var/log/benchmarks/.unordered" =20 # Adjust environment - denv =3D os.environ - for k,v in env.items(): - denv[k] =3D v + denv =3D _getEnv(root, dict(PKGDIR=3Dpkgdir)) =20 # Retrieve dependencies deps =3D get_dependencies(package, denv, False) @@ -83,31 +110,10 @@ def install_package(package, env=3D{}, root=3D'/', p= kgdir=3D'usr/portage/packages', The function has no return value and raises an exception in case of = building or emerging failure. Note: dependencies will NOT be emerged! """ - =20 - # Adjust environment - denv =3D os.environ.copy() - for k,v in env.items(): - denv[k] =3D v - denv['PKGDIR'] =3D pkgdir =20 - #PATH - denv['PATH'] =3D ':'.join([pjoin(root, i) for i in ('bin', 'usr/bin'= )]) - if os.environ.has_key('PATH'): - denv['PATH'] +=3D ':' + os.environ['PATH'] - denv['ROOTPATH'] =3D denv['PATH'] - #LIBRARY_PATH - denv['LIBRARY_PATH'] =3D ':'.join([pjoin(root, i) for i in \ - ('usr/lib', 'usr/lib64', 'usr/lib32')]) - if os.environ.has_key('LIBRARY_PATH'): - denv['LIBRARY_PATH'] +=3D ':' + os.environ['LIBRARY_PATH'] - #LD_LIBRARY_PATH - denv['LD_LIBRARY_PATH'] =3D ':'.join([pjoin(root, i) for i in \ - ('usr/lib', 'usr/lib64', 'usr/lib32')]) - if os.environ.has_key('LD_LIBRARY_PATH'): - denv['LD_LIBRARY_PATH'] +=3D ':' + os.environ['LD_LIBRARY_PATH'] - #INCLUDE_PATH - denv['INCLUDE_PATH'] =3D ':'.join([pjoin(root, i) for i in ('usr/inc= lude',)]) - if os.environ.has_key('INCLUDE_PATH'): - denv['INCLUDE_PATH'] +=3D ':' + os.environ['INCLUDE_PATH'] + envAdds =3D env.copy() + envAdds['PKGDIR'] =3D pkgdir + denv =3D _getEnv(root, envAdds) + del envAdds =20 # Retrieve package string pkg =3D normalize_cpv(package) diff --git a/benchconfig.py b/benchconfig.py index c684685..f707959 100644 --- a/benchconfig.py +++ b/benchconfig.py @@ -32,6 +32,7 @@ if needsinitialization: testsdir =3D "/var/tmp/benchmarks/tests/" rootsdir =3D "/var/tmp/benchmarks/roots/" pkgsdir =3D "/var/cache/benchmarks/packages/" + =20 reportdirb =3D "/var/cache/benchmarks/reports/" logdirb =3D "/var/log/benchmarks/"+modname+"_"+time.strftime('%Y= -%m-%d') else: @@ -42,6 +43,10 @@ if needsinitialization: logdirb =3D pjoin(os.environ['HOME'], ".benchmarks/log", modname + "_" + time.strftime('%Y-%m-%d')) =20 + bu.mkdir(testsdir) + bu.mkdir(rootsdir) + bu.mkdir(pkgsdir) + =20 # Report directory reportdirb +=3D modname + "_" + time.strftime('%Y-%m-%d') if os.path.exists(reportdirb): @@ -76,4 +81,4 @@ def makedirs(): =20 =20 =20 -inizialized =3D True \ No newline at end of file +inizialized =3D True diff --git a/benchprint.py b/benchprint.py index b91da66..e4b7e41 100644 --- a/benchprint.py +++ b/benchprint.py @@ -5,24 +5,37 @@ except NameError: =20 =20 if needsinitialization: + import benchconfig as cfg, benchutils as bu + from os.path import dirname, join as pjoin + class _Print: - def __init__(self, maxlevel=3D10): + def __init__(self, logfile, maxlevel=3D10): self._level =3D 0 self._maxlevel =3D maxlevel + bu.mkdir(dirname(logfile)) + self._logfile =3D file(logfile, 'w') =20 def __call__(self, arg): if self._level > self._maxlevel: return + =20 if self._level <=3D 0: print str(arg) + print >> self._logfile, str(arg) + self._logfile.flush() return - print (self._level-1)*" " + "-- " + str(arg) + =20 + printstr =3D (self._level-1)*" " + "-- " + str(arg) + if self._level <=3D self._maxlevel-1: + print >> self._logfile, printstr + self._logfile.flush() + print printstr =20 def up(self, n=3D1): self._level =3D max(self._level-n, 0) =20 def down(self, n=3D1): self._level =3D max(self._level+n, 0) - Print =3D _Print(3) + Print =3D _Print(pjoin(cfg.logdir, 'main.log'), 3) =20 -initialized =3D True \ No newline at end of file +initialized =3D True diff --git a/benchutils.py b/benchutils.py index 748f928..df12ee9 100644 --- a/benchutils.py +++ b/benchutils.py @@ -1,11 +1,8 @@ import os, sys -from os.path import join as pjoin, basename, dirname import subprocess as sp -import benchconfig as cfg -import benchpkgconfig as pc =20 def mkdir(dir): if not os.path.exists(dir): os.makedirs(dir) =20 -run_cmd =3D lambda c : sp.Popen(c, stdout=3Dsp.PIPE).communicate()[0] \ No newline at end of file +run_cmd =3D lambda c : sp.Popen(c, stdout=3Dsp.PIPE).communicate()[0]