summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-03-20 17:45:11 +0000
committerRichard Purdie <richard@openedhand.com>2006-03-20 17:45:11 +0000
commitb26a945734ce271aa7d443ff9e96fe2851b21138 (patch)
treef540b8d58a7411cf0cabe5c8f4ad40f9f597352a /bitbake/lib/bb/utils.py
parent3cd47ad235d54a9c539ae6fe4a5a2b4b5f7e5621 (diff)
downloadpoky-b26a945734ce271aa7d443ff9e96fe2851b21138.tar.gz
Update to latest bitbake
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@309 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py73
1 files changed, 70 insertions, 3 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index e2319aa123..5b3cb38d81 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -86,10 +86,77 @@ def explode_deps(s):
86 j = [] 86 j = []
87 if flag: 87 if flag:
88 j.append(i) 88 j.append(i)
89 if i.endswith(')'): 89 else:
90 r.append(i)
91 if flag and i.endswith(')'):
90 flag = False 92 flag = False
91 # Ignore version 93 # Ignore version
92 #r[-1] += ' ' + ' '.join(j) 94 #r[-1] += ' ' + ' '.join(j)
93 else:
94 r.append(i)
95 return r 95 return r
96
97
98
99def _print_trace(body, line):
100 """
101 Print the Environment of a Text Body
102 """
103 import bb
104
105 # print the environment of the method
106 bb.error("Printing the environment of the function")
107 min_line = max(1,line-4)
108 max_line = min(line+4,len(body)-1)
109 for i in range(min_line,max_line+1):
110 bb.error("\t%.4d:%s" % (i, body[i-1]) )
111
112
113def better_compile(text, file, realfile):
114 """
115 A better compile method. This method
116 will print the offending lines.
117 """
118 try:
119 return compile(text, file, "exec")
120 except Exception, e:
121 import bb,sys
122
123 # split the text into lines again
124 body = text.split('\n')
125 bb.error("Error in compiling: ", realfile)
126 bb.error("The lines resulting into this error were:")
127 bb.error("\t%d:%s:'%s'" % (e.lineno, e.__class__.__name__, body[e.lineno-1]))
128
129 _print_trace(body, e.lineno)
130
131 # exit now
132 sys.exit(1)
133
134def better_exec(code, context, text, realfile):
135 """
136 Similiar to better_compile, better_exec will
137 print the lines that are responsible for the
138 error.
139 """
140 import bb,sys
141 try:
142 exec code in context
143 except:
144 (t,value,tb) = sys.exc_info()
145
146 if t in [bb.parse.SkipPackage, bb.build.FuncFailed]:
147 raise
148
149 # print the Header of the Error Message
150 bb.error("Error in executing: ", realfile)
151 bb.error("Exception:%s Message:%s" % (t,value) )
152
153 # let us find the line number now
154 while tb.tb_next:
155 tb = tb.tb_next
156
157 import traceback
158 line = traceback.tb_lineno(tb)
159
160 _print_trace( text.split('\n'), line )
161
162 raise