blob: f5f30d4356e625f0fdd7bf2abddd655993b98ff1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
import sys, os, time
from os.path import join as pjoin
import subprocess as sp
#from benchutils import mkdir
import benchutils as bu
try:
needsinitialization = not initialized
except NameError:
needsinitialization = True
if needsinitialization:
isroot = os.getuid() == 0
try:
modname = sys.argv[1]
except:
modname = ''
# Script directories
curdir = os.path.abspath('.')
scriptdir = os.path.dirname(os.path.realpath(__file__))
if os.environ.has_key('BTLDIR'):
btldir = os.environ['BTLDIR']
else:
btldir = '/usr/include/btl'
# Library directory (lib32 vs. lib64)
libdir = sp.Popen \
('ABI=$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI`/', \
stdout=sp.PIPE, shell=True).communicate()[0].strip()
# roots, tests, packages directories -- report, logs base directories
if isroot:
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:
testsdir = os.environ['HOME'] + "/.benchmarks/tests/"
rootsdir = os.environ['HOME'] + "/.benchmarks/roots/"
pkgsdir = os.environ['HOME'] + "/.benchmarks/packages/"
reportdirb = os.environ['HOME'] + "/.benchmarks/reports/"
logdirb = pjoin(os.environ['HOME'], ".benchmarks/log/")
# Report directory
reportdirb += modname + "_" + time.strftime('%Y-%m-%d')
if os.path.exists(reportdirb):
n = 1
while True:
reportdir = reportdirb + "_%i" % n
if not os.path.exists(reportdir):
break
n += 1
else:
reportdir = reportdirb
del reportdirb
# Logs directory
logdirb += modname + "_" + time.strftime('%Y-%m-%d')
if os.path.exists(logdirb):
n = 1
while True:
logdir = logdirb + "_%i"%n
if not os.path.exists(logdir):
break
n += 1
else:
logdir = logdirb
del logdirb
def makedirs():
bu.mkdir(rootsdir)
bu.mkdir(testsdir)
bu.mkdir(pkgsdir)
bu.mkdir(reportdir)
bu.mkdir(logdir)
def purgedirs():
bu.rmdir(rootsdir)
bu.rmdir(testsdir)
bu.rmdir(pkgsdir)
bu.rmdir(pjoin(reportdir, '..'))
bu.rmdir(pjoin(logdir, '..'))
inizialized = True
|