-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtgfInit.py
More file actions
70 lines (58 loc) · 2.11 KB
/
Copy pathtgfInit.py
File metadata and controls
70 lines (58 loc) · 2.11 KB
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
#!/usr/bin/env python
# Import sys. Need this to get arguments to this script.
import sys
#
import subprocess
# Import method environ
from os import environ
# Import methods isdir
from os.path import isdir
#-----------------------------------------------------------------------------------------------------------------------
def reportError(message):
print ""
if len(message)>0:
print "### ERROR: %s" % message
else:
print "### ERROR: Undefined error"
print ""
#-----------------------------------------------------------------------------------------------------------------------
def reportErrorAndExit(message):
reportError(message)
sys.exit(1)
#-----------------------------------------------------------------------------------------------------------------------
# Define fall-back path to TGF
TGF_PATH="/lib"
if "READCONFIG_ADDR" in environ:
TGF_LIB_DIR=""
TGF_MAIN_FILE=""
#===========================================
# Find path to TGF library directory
#===========================================
lastCmd="readConfig -query \"key='TEST_GENERATOR_FRAMEWORK_LIB_DIR'\" -f \"%path/%name\""
try:
TMP_DIR_PATH=subprocess.check_output(lastCmd, shell=True)
TGF_LIB_DIR=TMP_DIR_PATH.strip()
if not isdir(TGF_LIB_DIR):
reportErrorAndExit("Test Generator Framework library path does not exist.")
except subprocess.CalledProcessError, e:
errMsg="The readConfig command (%s) failed.\n" % lastCmd
if len(e.output)>0:
errMsg+="\n"
errMsg+=" The readConfig command output:\n"
errMsg+=" ------------------------------\n"
errMsg+=e.output
else:
errMsg+="\n"
errMsg+=" No readConfig command output.\n"
reportErrorAndExit(errMsg)
elif isdir(TGF_PATH):
TGF_LIB_DIR=TGF_PATH
environ["TGF_HOME"]=TGF_PATH
else:
reportErrorAndExit("No active readConfig session.")
#===========================================
# Initiate TFG and set environment variable
#===========================================
environ["TGF_LIB_DIR"]=TGF_LIB_DIR
sys.path.append(TGF_LIB_DIR)
import GPmain as tgf