From: "Andrea Arteaga" <andyspiros@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/auto-numerical-bench:master commit in: /
Date: Tue, 9 Aug 2011 00:00:13 +0000 (UTC) [thread overview]
Message-ID: <c6b10b2698803d97f41cc2d95c384fcae690361f.spiros@gentoo> (raw)
commit: c6b10b2698803d97f41cc2d95c384fcae690361f
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Mon Aug 8 23:59:39 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Mon Aug 8 23:59:39 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=c6b10b26
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 = command
self.logfile = logfile
+
+def _getEnv(root='/', envAdds={}):
+ denv = os.environ.copy()
+
+ #PATH
+ denv['PATH'] = ':'.join([pjoin(root, i) for i in ('bin', 'usr/bin')])
+ if os.environ.has_key('PATH'):
+ denv['PATH'] += ':' + os.environ['PATH']
+ denv['ROOTPATH'] = denv['PATH']
+ #LIBRARY_PATH
+ denv['LIBRARY_PATH'] = ':'.join([pjoin(root, i) for i in \
+ ('usr/lib', 'usr/lib64', 'usr/lib32')])
+ if os.environ.has_key('LIBRARY_PATH'):
+ denv['LIBRARY_PATH'] += ':' + os.environ['LIBRARY_PATH']
+ #LD_LIBRARY_PATH
+ denv['LD_LIBRARY_PATH'] = ':'.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'] += ':' + os.environ['LD_LIBRARY_PATH']
+ #INCLUDE_PATH
+ denv['INCLUDE_PATH'] = ':'.join([pjoin(root, i) for i in ('usr/include',)])
+ if os.environ.has_key('INCLUDE_PATH'):
+ denv['INCLUDE_PATH'] += ':' + os.environ['INCLUDE_PATH']
+
+ # Adds
+ for k,v in envAdds.items():
+ denv[k] = v
+
+ return denv
def available_packages(pattern):
"""Returns a list of packages matching the given pattern.
@@ -51,9 +80,7 @@ def install_dependencies(package, env={}, root='/',
logdir = "/var/log/benchmarks/.unordered"
# Adjust environment
- denv = os.environ
- for k,v in env.items():
- denv[k] = v
+ denv = _getEnv(root, dict(PKGDIR=pkgdir))
# Retrieve dependencies
deps = get_dependencies(package, denv, False)
@@ -83,31 +110,10 @@ def install_package(package, env={}, root='/', pkgdir='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!
"""
-
- # Adjust environment
- denv = os.environ.copy()
- for k,v in env.items():
- denv[k] = v
- denv['PKGDIR'] = pkgdir
- #PATH
- denv['PATH'] = ':'.join([pjoin(root, i) for i in ('bin', 'usr/bin')])
- if os.environ.has_key('PATH'):
- denv['PATH'] += ':' + os.environ['PATH']
- denv['ROOTPATH'] = denv['PATH']
- #LIBRARY_PATH
- denv['LIBRARY_PATH'] = ':'.join([pjoin(root, i) for i in \
- ('usr/lib', 'usr/lib64', 'usr/lib32')])
- if os.environ.has_key('LIBRARY_PATH'):
- denv['LIBRARY_PATH'] += ':' + os.environ['LIBRARY_PATH']
- #LD_LIBRARY_PATH
- denv['LD_LIBRARY_PATH'] = ':'.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'] += ':' + os.environ['LD_LIBRARY_PATH']
- #INCLUDE_PATH
- denv['INCLUDE_PATH'] = ':'.join([pjoin(root, i) for i in ('usr/include',)])
- if os.environ.has_key('INCLUDE_PATH'):
- denv['INCLUDE_PATH'] += ':' + os.environ['INCLUDE_PATH']
+ envAdds = env.copy()
+ envAdds['PKGDIR'] = pkgdir
+ denv = _getEnv(root, envAdds)
+ del envAdds
# Retrieve package string
pkg = 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 = "/var/tmp/benchmarks/tests/"
rootsdir = "/var/tmp/benchmarks/roots/"
pkgsdir = "/var/cache/benchmarks/packages/"
+
reportdirb = "/var/cache/benchmarks/reports/"
logdirb = "/var/log/benchmarks/"+modname+"_"+time.strftime('%Y-%m-%d')
else:
@@ -42,6 +43,10 @@ if needsinitialization:
logdirb = pjoin(os.environ['HOME'], ".benchmarks/log",
modname + "_" + time.strftime('%Y-%m-%d'))
+ bu.mkdir(testsdir)
+ bu.mkdir(rootsdir)
+ bu.mkdir(pkgsdir)
+
# Report directory
reportdirb += modname + "_" + time.strftime('%Y-%m-%d')
if os.path.exists(reportdirb):
@@ -76,4 +81,4 @@ def makedirs():
-inizialized = True
\ No newline at end of file
+inizialized = 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:
if needsinitialization:
+ import benchconfig as cfg, benchutils as bu
+ from os.path import dirname, join as pjoin
+
class _Print:
- def __init__(self, maxlevel=10):
+ def __init__(self, logfile, maxlevel=10):
self._level = 0
self._maxlevel = maxlevel
+ bu.mkdir(dirname(logfile))
+ self._logfile = file(logfile, 'w')
def __call__(self, arg):
if self._level > self._maxlevel:
return
+
if self._level <= 0:
print str(arg)
+ print >> self._logfile, str(arg)
+ self._logfile.flush()
return
- print (self._level-1)*" " + "-- " + str(arg)
+
+ printstr = (self._level-1)*" " + "-- " + str(arg)
+ if self._level <= self._maxlevel-1:
+ print >> self._logfile, printstr
+ self._logfile.flush()
+ print printstr
def up(self, n=1):
self._level = max(self._level-n, 0)
def down(self, n=1):
self._level = max(self._level+n, 0)
- Print = _Print(3)
+ Print = _Print(pjoin(cfg.logdir, 'main.log'), 3)
-initialized = True
\ No newline at end of file
+initialized = 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
def mkdir(dir):
if not os.path.exists(dir):
os.makedirs(dir)
-run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
\ No newline at end of file
+run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
next reply other threads:[~2011-08-09 0:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-09 0:00 Andrea Arteaga [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-09-02 11:41 [gentoo-commits] proj/auto-numerical-bench:master commit in: / Andrea Arteaga
2012-08-11 18:00 Andrea Arteaga
2012-08-04 1:11 Andrea Arteaga
2012-04-09 22:58 Andrea Arteaga
2012-03-05 15:48 Andrea Arteaga
2012-02-28 19:20 Andrea Arteaga
2012-02-24 17:22 Andrea Arteaga
2011-08-22 18:15 Andrea Arteaga
2011-08-16 23:38 Andrea Arteaga
2011-08-15 21:57 Andrea Arteaga
2011-08-14 12:59 Andrea Arteaga
2011-08-14 12:35 Andrea Arteaga
2011-08-12 22:56 Andrea Arteaga
2011-08-09 0:00 Andrea Arteaga
2011-07-17 0:21 Andrea Arteaga
2011-07-13 21:48 Andrea Arteaga
2011-06-15 23:25 Andrea Arteaga
2011-06-15 12:56 Andrea Arteaga
2011-06-13 23:53 Andrea Arteaga
2011-06-13 14:12 Andrea Arteaga
2011-06-10 1:02 Andrea Arteaga
2011-06-10 0:52 Andrea Arteaga
2011-06-06 20:05 Andrea Arteaga
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c6b10b2698803d97f41cc2d95c384fcae690361f.spiros@gentoo \
--to=andyspiros@gmail.com \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox