summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2006-09-09 17:47:52 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2006-09-09 17:47:52 +0000
commitbe966771286d0d43c9bb398406109170849ba13a (patch)
tree087d2315540132ff97e1400d50c7601605fce63e /lib
parent2bc178d17fa4f0ac52e0cc8d35f04e6a4f68fde5 (diff)
downloadbitbake-be966771286d0d43c9bb398406109170849ba13a.tar.gz
Complete conversion to use bb.msg
Diffstat (limited to 'lib')
-rw-r--r--lib/bb/build.py14
-rw-r--r--lib/bb/cache.py22
-rw-r--r--lib/bb/data.py7
-rw-r--r--lib/bb/data_smart.py7
-rw-r--r--lib/bb/msg.py13
-rw-r--r--lib/bb/parse/parse_py/BBHandler.py12
-rw-r--r--lib/bb/parse/parse_py/ConfHandler.py19
-rw-r--r--lib/bb/providers.py2
-rw-r--r--lib/bb/runqueue.py16
-rw-r--r--lib/bb/taskdata.py2
-rw-r--r--lib/bb/utils.py14
11 files changed, 70 insertions, 58 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py
index f7f52e91d..448153616 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License along with
Based on functions from the base bb module, Copyright 2003 Holger Schurig
"""
-from bb import data, fetch, fatal, error, note, event, mkdirhier, utils
+from bb import data, fetch, event, mkdirhier, utils
import bb, os
# events
@@ -154,7 +154,7 @@ def exec_func_shell(func, d):
f.close()
os.chmod(runfile, 0775)
if not func:
- error("Function not specified")
+ bb.msg.error(bb.msg.domain.Build, "Function not specified")
raise FuncFailed()
# open logs
@@ -165,7 +165,7 @@ def exec_func_shell(func, d):
else:
so = file(logfile, 'w')
except OSError, e:
- bb.error("opening log file: %s" % e)
+ bb.msg.error(bb.msg.domain.Build, "opening log file: %s" % e)
pass
se = so
@@ -213,9 +213,9 @@ def exec_func_shell(func, d):
# os.remove(logfile)
return
else:
- error("function %s failed" % func)
+ bb.msg.error(bb.msg.domain.Build, "function %s failed" % func)
if data.getVar("BBINCLUDELOGS", d):
- error("log data follows (%s)" % logfile)
+ bb.msg.error(bb.msg.domain.Build, "log data follows (%s)" % logfile)
f = open(logfile, "r")
while True:
l = f.readline()
@@ -225,7 +225,7 @@ def exec_func_shell(func, d):
print '| %s' % l
f.close()
else:
- error("see log in %s" % logfile)
+ bb.msg.error(bb.msg.domain.Build, "see log in %s" % logfile)
raise FuncFailed( logfile )
@@ -276,7 +276,7 @@ def exec_task(task, d):
task_cache.append(item)
data.setVar('_task_cache', task_cache, d)
except FuncFailed, reason:
- note( "Task failed: %s" % reason )
+ bb.msg.note(1, bb.msg.domain.Build, "Task failed: %s" % reason )
failedevent = TaskFailed(item, d)
event.fire(failedevent)
raise EventException("Function failed in task: %s" % reason, failedevent)
diff --git a/lib/bb/cache.py b/lib/bb/cache.py
index 9972f788b..774e74b86 100644
--- a/lib/bb/cache.py
+++ b/lib/bb/cache.py
@@ -38,7 +38,7 @@ try:
import cPickle as pickle
except ImportError:
import pickle
- print "NOTE: Importing cPickle failed. Falling back to a very slow implementation."
+ bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.")
__cache_version__ = "125"
@@ -58,13 +58,13 @@ class Cache:
if self.cachedir in [None, '']:
self.has_cache = False
if cooker.cb is not None:
- print "NOTE: Not using a cache. Set CACHE = <directory> to enable."
+ bb.msg.note(1, bb.msg.domain.Cache, "Not using a cache. Set CACHE = <directory> to enable.")
else:
self.has_cache = True
self.cachefile = os.path.join(self.cachedir,"bb_cache.dat")
if cooker.cb is not None:
- print "NOTE: Using cache in '%s'" % self.cachedir
+ bb.msg.note(1, bb.msg.domain.Cache, "Using cache in '%s'" % self.cachedir)
try:
os.stat( self.cachedir )
except OSError:
@@ -79,7 +79,7 @@ class Cache:
if version_data['BITBAKE_VER'] != bb.__version__:
raise ValueError, 'Bitbake Version Mismatch'
except (ValueError, KeyError):
- bb.note("Invalid cache found, rebuilding...")
+ bb.msg.note(1, bb.msg.domain.Cache, "Invalid cache found, rebuilding...")
self.depends_cache = {}
if self.depends_cache:
@@ -107,7 +107,7 @@ class Cache:
if fn != self.data_fn:
# We're trying to access data in the cache which doesn't exist
# yet setData hasn't been called to setup the right access. Very bad.
- bb.error("Parsing error data_fn %s and fn %s don't match" % (self.data_fn, fn))
+ bb.msg.error(bb.msg.domain.Cache, "Parsing error data_fn %s and fn %s don't match" % (self.data_fn, fn))
result = bb.data.getVar(var, self.data, exp)
self.depends_cache[fn][var] = result
@@ -174,19 +174,19 @@ class Cache:
# Check file still exists
if self.mtime(fn) == 0:
- bb.debug(2, "Cache: %s not longer exists" % fn)
+ bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s not longer exists" % fn)
self.remove(fn)
return False
# File isn't in depends_cache
if not fn in self.depends_cache:
- bb.debug(2, "Cache: %s is not cached" % fn)
+ bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s is not cached" % fn)
self.remove(fn)
return False
# Check the file's timestamp
if bb.parse.cached_mtime(fn) > self.getVar("CACHETIMESTAMP", fn, True):
- bb.debug(2, "Cache: %s changed" % fn)
+ bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s changed" % fn)
self.remove(fn)
return False
@@ -195,11 +195,11 @@ class Cache:
for f,old_mtime in depends:
new_mtime = bb.parse.cached_mtime(f)
if (new_mtime > old_mtime):
- bb.debug(2, "Cache: %s's dependency %s changed" % (fn, f))
+ bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s's dependency %s changed" % (fn, f))
self.remove(fn)
return False
- bb.debug(2, "Depends Cache: %s is clean" % fn)
+ bb.msg.debug(2, bb.msg.domain.Cache, "Depends Cache: %s is clean" % fn)
if not fn in self.clean:
self.clean[fn] = ""
@@ -219,7 +219,7 @@ class Cache:
Remove a fn from the cache
Called from the parser in error cases
"""
- bb.debug(1, "Removing %s from cache" % fn)
+ bb.msg.debug(1, bb.msg.domain.Cache, "Removing %s from cache" % fn)
if fn in self.depends_cache:
del self.depends_cache[fn]
if fn in self.clean:
diff --git a/lib/bb/data.py b/lib/bb/data.py
index 68cb48f58..4785a4798 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -45,7 +45,8 @@ else:
path = os.path.dirname(os.path.dirname(sys.argv[0]))
sys.path.insert(0,path)
-from bb import note, debug, data_smart
+from bb import data_smart
+import bb
_dict_type = data_smart.DataSmart
@@ -461,7 +462,7 @@ def update_data(d):
file://append.foo;patch=1 file://other.foo;patch=1
"""
- debug(2, "update_data()")
+ bb.msg.debug(2, bb.msg.domain.Data, "update_data()")
# now ask the cookie monster for help
#print "Cookie Monster"
@@ -499,7 +500,7 @@ def update_data(d):
try:
d[name] = d[var]
except:
- note ("Untracked delVar")
+ bb.msg.note(1, bb.msg.domain.Data, "Untracked delVar")
# now on to the appends and prepends
if d._special_values.has_key('_append'):
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 4ae0047ee..9dabf16a7 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -29,7 +29,8 @@ Based on functions from the base bb module, Copyright 2003 Holger Schurig
"""
import copy, os, re, sys, time, types
-from bb import note, debug, error, fatal, utils, methodpool
+import bb
+from bb import utils, methodpool
from COW import COWDictBase
from sets import Set
from new import classobj
@@ -79,11 +80,11 @@ class DataSmart:
s = __expand_python_regexp__.sub(python_sub, s)
if s == olds: break
if type(s) is not types.StringType: # sanity check
- error('expansion of %s returned non-string %s' % (olds, s))
+ bb.msg.error(bb.msg.domain.Data, 'expansion of %s returned non-string %s' % (olds, s))
except KeyboardInterrupt:
raise
except:
- note("%s:%s while evaluating:\n%s" % (sys.exc_info()[0], sys.exc_info()[1], s))
+ bb.msg.note(1, bb.msg.domain.Data, "%s:%s while evaluating:\n%s" % (sys.exc_info()[0], sys.exc_info()[1], s))
raise
return s
diff --git a/lib/bb/msg.py b/lib/bb/msg.py
index 8634f1f83..268305388 100644
--- a/lib/bb/msg.py
+++ b/lib/bb/msg.py
@@ -30,7 +30,18 @@ debug_level = 0
verbose = False
-domain = bb.utils.Enum('Depends', 'Provider', 'Build', 'Parsing', 'Collection', 'RunQueue', 'TaskData', 'Fetcher')
+domain = bb.utils.Enum(
+ 'Build',
+ 'Cache',
+ 'Collection',
+ 'Data',
+ 'Depends',
+ 'Fetcher',
+ 'Parsing',
+ 'Provider',
+ 'RunQueue',
+ 'TaskData',
+ 'Util')
#
# Message control functions
diff --git a/lib/bb/parse/parse_py/BBHandler.py b/lib/bb/parse/parse_py/BBHandler.py
index c82090fec..2f8710760 100644
--- a/lib/bb/parse/parse_py/BBHandler.py
+++ b/lib/bb/parse/parse_py/BBHandler.py
@@ -23,7 +23,7 @@
import re, bb, os, sys, time
import bb.fetch, bb.build, bb.utils
-from bb import debug, data, fetch, fatal, methodpool
+from bb import data, fetch, methodpool
from ConfHandler import include, localpath, obtain, init
from bb.parse import ParseError
@@ -60,7 +60,7 @@ def inherit(files, d):
file = os.path.join('classes', '%s.bbclass' % file)
if not file in __inherit_cache.split():
- debug(2, "BB %s:%d: inheriting %s" % (fn, lineno, file))
+ bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file))
__inherit_cache += " %s" % file
include(fn, file, d)
data.setVar('__inherit_cache', __inherit_cache, d)
@@ -75,9 +75,9 @@ def handle(fn, d, include = 0):
__residue__ = []
if include == 0:
- debug(2, "BB " + fn + ": handle(data)")
+ bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data)")
else:
- debug(2, "BB " + fn + ": handle(data, include)")
+ bb.msg.debug(2, bb.msg.domain.Parsing, "BB " + fn + ": handle(data, include)")
(root, ext) = os.path.splitext(os.path.basename(fn))
base_name = "%s%s" % (root,ext)
@@ -152,7 +152,7 @@ def handle(fn, d, include = 0):
if t:
data.setVar('T', t, d)
except Exception, e:
- bb.debug(1, "executing anonymous function: %s" % e)
+ bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e)
raise
data.delVar("__anonqueue", d)
data.delVar("__anonfunc", d)
@@ -374,7 +374,7 @@ def vars_from_file(mypkg, d):
def set_additional_vars(file, d, include):
"""Deduce rest of variables, e.g. ${A} out of ${SRC_URI}"""
- debug(2,"BB %s: set_additional_vars" % file)
+ bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file)
src_uri = data.getVar('SRC_URI', d)
if not src_uri:
diff --git a/lib/bb/parse/parse_py/ConfHandler.py b/lib/bb/parse/parse_py/ConfHandler.py
index 90978300a..26f8038a8 100644
--- a/lib/bb/parse/parse_py/ConfHandler.py
+++ b/lib/bb/parse/parse_py/ConfHandler.py
@@ -22,7 +22,6 @@
Place, Suite 330, Boston, MA 02111-1307 USA."""
import re, bb.data, os, sys
-from bb import debug, fatal
from bb.parse import ParseError
#__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
@@ -61,25 +60,25 @@ def obtain(fn, data = bb.data.init()):
if localfn != fn:
dldir = bb.data.getVar('DL_DIR', data, 1)
if not dldir:
- debug(1, "obtain: DL_DIR not defined")
+ bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: DL_DIR not defined")
return localfn
bb.mkdirhier(dldir)
try:
bb.fetch.init([fn])
except bb.fetch.NoMethodError:
(type, value, traceback) = sys.exc_info()
- debug(1, "obtain: no method: %s" % value)
+ bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: no method: %s" % value)
return localfn
try:
bb.fetch.go(data)
except bb.fetch.MissingParameterError:
(type, value, traceback) = sys.exc_info()
- debug(1, "obtain: missing parameters: %s" % value)
+ bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: missing parameters: %s" % value)
return localfn
except bb.fetch.FetchError:
(type, value, traceback) = sys.exc_info()
- debug(1, "obtain: failed: %s" % value)
+ bb.msg.debug(1, bb.msg.domain.Parsing, "obtain: failed: %s" % value)
return localfn
return localfn
@@ -102,7 +101,7 @@ def include(oldfn, fn, data = bb.data.init(), error_out = False):
except IOError:
if error_out:
raise ParseError("Could not include required file %(fn)s" % vars() )
- debug(2, "CONF file '%s' not found" % fn)
+ bb.msg.debug(2, bb.msg.domain.Parsing, "CONF file '%s' not found" % fn)
def handle(fn, data = bb.data.init(), include = 0):
if include:
@@ -129,13 +128,13 @@ def handle(fn, data = bb.data.init(), include = 0):
if os.access(currname, os.R_OK):
f = open(currname, 'r')
abs_fn = currname
- debug(1, "CONF %s %s" % (inc_string, currname))
+ bb.msg.debug(2, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string, currname))
break
if f is None:
raise IOError("file '%s' not found" % fn)
else:
f = open(fn,'r')
- debug(1, "CONF %s %s" % (inc_string,fn))
+ bb.msg.debug(1, bb.msg.domain.Parsing, "CONF %s %s" % (inc_string,fn))
abs_fn = fn
if include:
@@ -185,7 +184,7 @@ def feeder(lineno, s, fn, data = bb.data.init()):
else:
val = groupd["value"]
if 'flag' in groupd and groupd['flag'] != None:
-# bb.note("setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val))
+ bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val))
bb.data.setVarFlag(key, groupd['flag'], val, data)
else:
bb.data.setVar(key, val, data)
@@ -194,7 +193,7 @@ def feeder(lineno, s, fn, data = bb.data.init()):
m = __include_regexp__.match(s)
if m:
s = bb.data.expand(m.group(1), data)
-# debug(2, "CONF %s:%d: including %s" % (fn, lineno, s))
+ bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s))
include(fn, s, data)
return
diff --git a/lib/bb/providers.py b/lib/bb/providers.py
index 458eef274..89f0fa713 100644
--- a/lib/bb/providers.py
+++ b/lib/bb/providers.py
@@ -140,7 +140,7 @@ def filterProviders(providers, item, cfgData, dataCache, build_cache_fail = {}):
eligible.remove(p)
if len(eligible) == 0:
- bb.error("no eligible providers for %s" % item)
+ bb.msg.error(bb.msg.domain.Provider, "no eligible providers for %s" % item)
return 0
# look to see if one of them is already staged, or marked as preferred.
diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index 4c17579fd..b5361f9c5 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -121,7 +121,7 @@ class RunQueue:
#Prune self references
if task in depends:
newdep = []
- bb.debug(2, "Task %s (%s %s) contains self reference! %s" % (task, taskData.fn_index[taskData.tasks_fnid[task]], taskData.tasks_name[task], depends))
+ bb.msg.debug(2, bb.msg.domain.RunQueue, "Task %s (%s %s) contains self reference! %s" % (task, taskData.fn_index[taskData.tasks_fnid[task]], taskData.tasks_name[task], depends))
for dep in depends:
if task != dep:
newdep.append(dep)
@@ -196,7 +196,7 @@ class RunQueue:
origdeps = self.runq_depends[listid]
for origdep in origdeps:
if maps[origdep] == -1:
- bb.fatal(bb.msg.domain.RunQueue, "Invalid mapping - Should never happen!")
+ bb.msg.fatal(bb.msg.domain.RunQueue, "Invalid mapping - Should never happen!")
newdeps.append(maps[origdep])
self.runq_depends[listid] = newdeps
@@ -217,7 +217,7 @@ class RunQueue:
for dep in revdeps:
if dep in self.runq_depends[listid]:
#self.dump_data(taskData)
- bb.fatal("Task %s (%s) has circular dependency on %s (%s)" % (taskData.fn_index[self.runq_fnid[dep]], self.runq_task[dep] , taskData.fn_index[self.runq_fnid[listid]], self.runq_task[listid]))
+ bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) has circular dependency on %s (%s)" % (taskData.fn_index[self.runq_fnid[dep]], self.runq_task[dep] , taskData.fn_index[self.runq_fnid[listid]], self.runq_task[listid]))
runq_weight1[listid] = len(revdeps)
bb.msg.note(2, bb.msg.domain.RunQueue, "Compute totals (have %s endpoint(s))" % len(endpoints))
@@ -238,9 +238,9 @@ class RunQueue:
# Sanity Checks
for task in range(len(self.runq_fnid)):
if runq_done[task] == 0:
- bb.fatal("Task %s (%s) not processed!" % (task, self.get_user_idstring(task, taskData)))
+ bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) not processed!" % (task, self.get_user_idstring(task, taskData)))
if runq_weight1[task] != 0:
- bb.fatal("Task %s (%s) count not zero!" % (task, self.get_user_idstring(task, taskData)))
+ bb.msg.fatal(bb.msg.domain.RunQueue, "Task %s (%s) count not zero!" % (task, self.get_user_idstring(task, taskData)))
# Make a weight sorted map
from copy import deepcopy
@@ -379,13 +379,13 @@ class RunQueue:
except SystemExit:
raise
except:
- bb.error("Exception received")
+ bb.msg.error(bb.msg.domain.RunQueue, "Exception received")
if active_builds > 0:
while active_builds > 0:
- bb.note("Waiting for %s active tasks to finish" % active_builds)
+ bb.msg.note(1, bb.msg.domain.RunQueue, "Waiting for %s active tasks to finish" % active_builds)
tasknum = 1
for k, v in build_pids.iteritems():
- bb.note("%s: %s (%s)" % (tasknum, self.get_user_idstring(v, taskData), k))
+ bb.msg.note(1, bb.msg.domain.RunQueue, "%s: %s (%s)" % (tasknum, self.get_user_idstring(v, taskData), k))
tasknum = tasknum + 1
result = os.waitpid(-1, 0)
del build_pids[result[0]]
diff --git a/lib/bb/taskdata.py b/lib/bb/taskdata.py
index 839ac1af1..880aec4c2 100644
--- a/lib/bb/taskdata.py
+++ b/lib/bb/taskdata.py
@@ -135,7 +135,7 @@ class TaskData:
fnid = self.getfn_id(fn)
if fnid in self.failed_fnids:
- bb.fatal("Trying to re-add a failed file? Something is broken...")
+ bb.msg.fatal(bb.msg.domain.TaskData, "Trying to re-add a failed file? Something is broken...")
# Check if we've already seen this fn
if fnid in self.tasks_fnid:
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index b63c4e530..d7383f44b 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -103,11 +103,11 @@ def _print_trace(body, line):
import bb
# print the environment of the method
- bb.error("Printing the environment of the function")
+ bb.msg.error(bb.msg.domain.Util, "Printing the environment of the function")
min_line = max(1,line-4)
max_line = min(line+4,len(body)-1)
for i in range(min_line,max_line+1):
- bb.error("\t%.4d:%s" % (i, body[i-1]) )
+ bb.msg.error(bb.msg.domain.Util, "\t%.4d:%s" % (i, body[i-1]) )
def better_compile(text, file, realfile):
@@ -122,9 +122,9 @@ def better_compile(text, file, realfile):
# split the text into lines again
body = text.split('\n')
- bb.error("Error in compiling: ", realfile)
- bb.error("The lines resulting into this error were:")
- bb.error("\t%d:%s:'%s'" % (e.lineno, e.__class__.__name__, body[e.lineno-1]))
+ bb.msg.error(bb.msg.domain.Util, "Error in compiling: ", realfile)
+ bb.msg.error(bb.msg.domain.Util, "The lines resulting into this error were:")
+ bb.msg.error(bb.msg.domain.Util, "\t%d:%s:'%s'" % (e.lineno, e.__class__.__name__, body[e.lineno-1]))
_print_trace(body, e.lineno)
@@ -147,8 +147,8 @@ def better_exec(code, context, text, realfile):
raise
# print the Header of the Error Message
- bb.error("Error in executing: ", realfile)
- bb.error("Exception:%s Message:%s" % (t,value) )
+ bb.msg.error(bb.msg.domain.Util, "Error in executing: ", realfile)
+ bb.msg.error(bb.msg.domain.Util, "Exception:%s Message:%s" % (t,value) )
# let us find the line number now
while tb.tb_next: