-
Notifications
You must be signed in to change notification settings - Fork 37
/
globals.py
86 lines (67 loc) · 2.59 KB
/
globals.py
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
import os
import grp
import sys
from color_printer import COLOR_PRINTER
def checkEnv():
if not 'PRJ_HOME' in os.environ:
raise EnvironmentError('$PRJ_HOME is not defined')
checkEnv()
def defaultCliCfgFile():
cliFile = os.path.join(os.environ['PRJ_HOME'], 'bin', 'userCli.cfg')
if os.path.exists(cliFile):
return cliFile
else:
COLOR_PRINTER.write("%s doesn't exist!\n" % cliFile, fg='ri')
sys.exit(1)
def defaultBuildFile():
buildFile = os.path.join(os.environ['PRJ_HOME'], 'bin', 'build.cfg')
if os.path.exists(buildFile):
return buildFile
else:
COLOR_PRINTER.write("%s doesn't exist!\n" % buildFile, fg='ri')
sys.exit(1)
def defaultGroupFile():
groupFile = os.path.join(os.environ['PRJ_HOME'], 'bin', 'group.cfg')
if os.path.exists(groupFile):
return groupFile
else:
COLOR_PRINTER.write("%s doesn't exist!\n" % groupFile, fg='ri')
sys.exit(1)
def defaultTestListFile():
return 'test.f'
def defaultCovDir():
return 'coverage'
def defaultYasaDir():
if 'YASA_HOME' in os.environ:
return os.environ['YASA_HOME']
else :
return os.path.join(os.environ['PRJ_HOME'], 'bin', 'Yasa')
def defautlVplanDir():
return os.path.join(os.environ['PRJ_HOME'], 'etc', 'vplan')
def defaultTestDir():
if 'TEST_DIR' in os.environ:
return os.environ['TEST_DIR']
else:
return os.path.join(os.environ['PRJ_HOME'], 'testcases')
def defaultWorkDir():
if 'WORK_DIR' in os.environ:
return os.environ['WORK_DIR']
else:
return os.path.join(defaultWorkPrjDir(), 'work')
def defaultReportDir():
if 'REPORT_DIR' in os.environ:
return os.environ['REPORT_DIR']
else:
return os.path.join(defaultWorkPrjDir(), 'report')
def userSimCheck():
userSimCheckFile = os.path.join(os.environ['PRJ_HOME'], 'bin', 'userSimCheck.py')
if os.path.isfile(userSimCheckFile):
return ('userSimCheck', userSimCheckFile)
return (None, None)
def defaultWorkDir():
# if os.environ['USER'] in grp.getgrnam('sg-ic-ipdv').gr_mem:
# return os.path.join('/ic/temp/ipdv', os.environ['USER'], os.path.basename(os.environ['PRJ_HOME']))
# elif os.environ['USER'] in grp.getgrnam('sg-ic-soc').gr_mem:
# return os.path.join('/ic/temp/fe', os.environ['USER'], os.path.basename(os.environ['PRJ_HOME']))
# else : raise SystemError('You are supposed to be in sg-ic-ipdv, sg-ic-soc, sg-ic-fpga or sg-ic-socdv group, but you are not !')
return os.path.join(os.environ['PRJ_HOME'], os.path.basename(os.environ['PRJ_HOME']) + '_out')