1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 01:19:52 +00:00

bitbake: lib/bb: Clean up use of len()

(Bitbake rev: bbbc843e86639604d00d76b1949b94a78cf1d95d)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2021-11-02 11:07:17 +00:00
parent 5fb6b453f6
commit 9abab49f2b
9 changed files with 56 additions and 56 deletions
+2 -2
View File
@@ -60,7 +60,7 @@ def find_siginfo_task(bbhandler, pn, taskname, sig1=None, sig2=None):
if sig1 and sig2: if sig1 and sig2:
sigfiles = find_siginfo(bbhandler, pn, taskname, [sig1, sig2]) sigfiles = find_siginfo(bbhandler, pn, taskname, [sig1, sig2])
if len(sigfiles) == 0: if not sigfiles:
logger.error('No sigdata files found matching %s %s matching either %s or %s' % (pn, taskname, sig1, sig2)) logger.error('No sigdata files found matching %s %s matching either %s or %s' % (pn, taskname, sig1, sig2))
sys.exit(1) sys.exit(1)
elif not sig1 in sigfiles: elif not sig1 in sigfiles:
@@ -86,7 +86,7 @@ def recursecb(key, hash1, hash2):
hashfiles = find_siginfo(tinfoil, key, None, hashes) hashfiles = find_siginfo(tinfoil, key, None, hashes)
recout = [] recout = []
if len(hashfiles) == 0: if not hashfiles:
recout.append("Unable to find matching sigdata for %s with hashes %s or %s" % (key, hash1, hash2)) recout.append("Unable to find matching sigdata for %s with hashes %s or %s" % (key, hash1, hash2))
elif not hash1 in hashfiles: elif not hash1 in hashfiles:
recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash1)) recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash1))
+3 -3
View File
@@ -1656,7 +1656,7 @@ class BBCooker:
# Return a copy, don't modify the original # Return a copy, don't modify the original
pkgs_to_build = pkgs_to_build[:] pkgs_to_build = pkgs_to_build[:]
if len(pkgs_to_build) == 0: if not pkgs_to_build:
raise NothingToBuild raise NothingToBuild
ignore = (self.data.getVar("ASSUME_PROVIDED") or "").split() ignore = (self.data.getVar("ASSUME_PROVIDED") or "").split()
@@ -1795,10 +1795,10 @@ class CookerCollectFiles(object):
files.sort( key=lambda fileitem: self.calc_bbfile_priority(fileitem)[0] ) files.sort( key=lambda fileitem: self.calc_bbfile_priority(fileitem)[0] )
config.setVar("BBFILES_PRIORITIZED", " ".join(files)) config.setVar("BBFILES_PRIORITIZED", " ".join(files))
if not len(files): if not files:
files = self.get_bbfiles() files = self.get_bbfiles()
if not len(files): if not files:
collectlog.error("no recipe files to build, check your BBPATH and BBFILES?") collectlog.error("no recipe files to build, check your BBPATH and BBFILES?")
bb.event.fire(CookerExit(), eventdata) bb.event.fire(CookerExit(), eventdata)
+1 -1
View File
@@ -86,7 +86,7 @@ class ConfigParameters(object):
action['msg'] = "Only one target can be used with the --environment option." action['msg'] = "Only one target can be used with the --environment option."
elif self.options.buildfile and len(self.options.pkgs_to_build) > 0: elif self.options.buildfile and len(self.options.pkgs_to_build) > 0:
action['msg'] = "No target should be used with the --environment and --buildfile options." action['msg'] = "No target should be used with the --environment and --buildfile options."
elif len(self.options.pkgs_to_build) > 0: elif self.options.pkgs_to_build:
action['action'] = ["showEnvironmentTarget", self.options.pkgs_to_build] action['action'] = ["showEnvironmentTarget", self.options.pkgs_to_build]
else: else:
action['action'] = ["showEnvironment", self.options.buildfile] action['action'] = ["showEnvironment", self.options.buildfile]
+2 -2
View File
@@ -770,7 +770,7 @@ def get_srcrev(d, method_name='sortable_revision'):
if urldata[u].method.supports_srcrev(): if urldata[u].method.supports_srcrev():
scms.append(u) scms.append(u)
if len(scms) == 0: if not scms:
raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI") raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI")
if len(scms) == 1 and len(urldata[scms[0]].names) == 1: if len(scms) == 1 and len(urldata[scms[0]].names) == 1:
@@ -1636,7 +1636,7 @@ class Fetch(object):
if localonly and cache: if localonly and cache:
raise Exception("bb.fetch2.Fetch.__init__: cannot set cache and localonly at same time") raise Exception("bb.fetch2.Fetch.__init__: cannot set cache and localonly at same time")
if len(urls) == 0: if not urls:
urls = d.getVar("SRC_URI").split() urls = d.getVar("SRC_URI").split()
self.urls = urls self.urls = urls
self.d = d self.d = d
+1 -1
View File
@@ -163,7 +163,7 @@ class GitSM(Git):
else: else:
self.process_submodules(ud, ud.clonedir, need_update_submodule, d) self.process_submodules(ud, ud.clonedir, need_update_submodule, d)
if len(need_update_list) > 0: if need_update_list:
logger.debug('gitsm: Submodules requiring update: %s' % (' '.join(need_update_list))) logger.debug('gitsm: Submodules requiring update: %s' % (' '.join(need_update_list)))
return True return True
+33 -33
View File
@@ -547,7 +547,7 @@ class RunQueueData:
next_points.append(revdep) next_points.append(revdep)
task_done[revdep] = True task_done[revdep] = True
endpoints = next_points endpoints = next_points
if len(next_points) == 0: if not next_points:
break break
# Circular dependency sanity check # Circular dependency sanity check
@@ -589,7 +589,7 @@ class RunQueueData:
found = False found = False
for mc in self.taskData: for mc in self.taskData:
if len(taskData[mc].taskentries) > 0: if taskData[mc].taskentries:
found = True found = True
break break
if not found: if not found:
@@ -773,7 +773,7 @@ class RunQueueData:
# Find the dependency chain endpoints # Find the dependency chain endpoints
endpoints = set() endpoints = set()
for tid in self.runtaskentries: for tid in self.runtaskentries:
if len(deps[tid]) == 0: if not deps[tid]:
endpoints.add(tid) endpoints.add(tid)
# Iterate the chains collating dependencies # Iterate the chains collating dependencies
while endpoints: while endpoints:
@@ -784,11 +784,11 @@ class RunQueueData:
cumulativedeps[dep].update(cumulativedeps[tid]) cumulativedeps[dep].update(cumulativedeps[tid])
if tid in deps[dep]: if tid in deps[dep]:
deps[dep].remove(tid) deps[dep].remove(tid)
if len(deps[dep]) == 0: if not deps[dep]:
next.add(dep) next.add(dep)
endpoints = next endpoints = next
#for tid in deps: #for tid in deps:
# if len(deps[tid]) != 0: # if deps[tid]:
# bb.warn("Sanity test failure, dependencies left for %s (%s)" % (tid, deps[tid])) # bb.warn("Sanity test failure, dependencies left for %s (%s)" % (tid, deps[tid]))
# Loop here since recrdeptasks can depend upon other recrdeptasks and we have to # Loop here since recrdeptasks can depend upon other recrdeptasks and we have to
@@ -958,7 +958,7 @@ class RunQueueData:
delcount[tid] = self.runtaskentries[tid] delcount[tid] = self.runtaskentries[tid]
del self.runtaskentries[tid] del self.runtaskentries[tid]
if len(self.runtaskentries) == 0: if not self.runtaskentries:
bb.msg.fatal("RunQueue", "Could not find any tasks with the tasknames %s to run within the recipes of the taskgraphs of the targets %s" % (str(self.cooker.configuration.runall), str(self.targets))) bb.msg.fatal("RunQueue", "Could not find any tasks with the tasknames %s to run within the recipes of the taskgraphs of the targets %s" % (str(self.cooker.configuration.runall), str(self.targets)))
self.init_progress_reporter.next_stage() self.init_progress_reporter.next_stage()
@@ -983,7 +983,7 @@ class RunQueueData:
delcount[tid] = self.runtaskentries[tid] delcount[tid] = self.runtaskentries[tid]
del self.runtaskentries[tid] del self.runtaskentries[tid]
if len(self.runtaskentries) == 0: if not self.runtaskentries:
bb.msg.fatal("RunQueue", "Could not find any tasks with the tasknames %s to run within the taskgraphs of the targets %s" % (str(self.cooker.configuration.runonly), str(self.targets))) bb.msg.fatal("RunQueue", "Could not find any tasks with the tasknames %s to run within the taskgraphs of the targets %s" % (str(self.cooker.configuration.runonly), str(self.targets)))
# #
@@ -991,7 +991,7 @@ class RunQueueData:
# #
# Check to make sure we still have tasks to run # Check to make sure we still have tasks to run
if len(self.runtaskentries) == 0: if not self.runtaskentries:
if not taskData[''].abort: if not taskData[''].abort:
bb.msg.fatal("RunQueue", "All buildable tasks have been run but the build is incomplete (--continue mode). Errors for the tasks that failed will have been printed above.") bb.msg.fatal("RunQueue", "All buildable tasks have been run but the build is incomplete (--continue mode). Errors for the tasks that failed will have been printed above.")
else: else:
@@ -1015,7 +1015,7 @@ class RunQueueData:
endpoints = [] endpoints = []
for tid in self.runtaskentries: for tid in self.runtaskentries:
revdeps = self.runtaskentries[tid].revdeps revdeps = self.runtaskentries[tid].revdeps
if len(revdeps) == 0: if not revdeps:
endpoints.append(tid) endpoints.append(tid)
for dep in revdeps: for dep in revdeps:
if dep in self.runtaskentries[tid].depends: if dep in self.runtaskentries[tid].depends:
@@ -1188,9 +1188,9 @@ class RunQueueData:
# Iterate over the task list and call into the siggen code # Iterate over the task list and call into the siggen code
dealtwith = set() dealtwith = set()
todeal = set(self.runtaskentries) todeal = set(self.runtaskentries)
while len(todeal) > 0: while todeal:
for tid in todeal.copy(): for tid in todeal.copy():
if len(self.runtaskentries[tid].depends - dealtwith) == 0: if not (self.runtaskentries[tid].depends - dealtwith):
dealtwith.add(tid) dealtwith.add(tid)
todeal.remove(tid) todeal.remove(tid)
self.prepare_task_hash(tid) self.prepare_task_hash(tid)
@@ -1500,10 +1500,10 @@ class RunQueue:
self.rqexe = RunQueueExecute(self) self.rqexe = RunQueueExecute(self)
# If we don't have any setscene functions, skip execution # If we don't have any setscene functions, skip execution
if len(self.rqdata.runq_setscene_tids) == 0: if not self.rqdata.runq_setscene_tids:
logger.info('No setscene tasks') logger.info('No setscene tasks')
for tid in self.rqdata.runtaskentries: for tid in self.rqdata.runtaskentries:
if len(self.rqdata.runtaskentries[tid].depends) == 0: if not self.rqdata.runtaskentries[tid].depends:
self.rqexe.setbuildable(tid) self.rqexe.setbuildable(tid)
self.rqexe.tasks_notcovered.add(tid) self.rqexe.tasks_notcovered.add(tid)
self.rqexe.sqdone = True self.rqexe.sqdone = True
@@ -1780,7 +1780,7 @@ class RunQueueExecute:
bb.fatal("Invalid scheduler '%s'. Available schedulers: %s" % bb.fatal("Invalid scheduler '%s'. Available schedulers: %s" %
(self.scheduler, ", ".join(obj.name for obj in schedulers))) (self.scheduler, ", ".join(obj.name for obj in schedulers)))
#if len(self.rqdata.runq_setscene_tids) > 0: #if self.rqdata.runq_setscene_tids:
self.sqdata = SQData() self.sqdata = SQData()
build_scenequeue_data(self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self) build_scenequeue_data(self.sqdata, self.rqdata, self.rq, self.cooker, self.stampcache, self)
@@ -1821,7 +1821,7 @@ class RunQueueExecute:
# worker must have died? # worker must have died?
pass pass
if len(self.failed_tids) != 0: if self.failed_tids:
self.rq.state = runQueueFailed self.rq.state = runQueueFailed
return return
@@ -1837,7 +1837,7 @@ class RunQueueExecute:
self.rq.read_workers() self.rq.read_workers()
return self.rq.active_fds() return self.rq.active_fds()
if len(self.failed_tids) != 0: if self.failed_tids:
self.rq.state = runQueueFailed self.rq.state = runQueueFailed
return True return True
@@ -2001,7 +2001,7 @@ class RunQueueExecute:
if x not in self.tasks_scenequeue_done: if x not in self.tasks_scenequeue_done:
logger.error("Task %s was never processed by the setscene code" % x) logger.error("Task %s was never processed by the setscene code" % x)
err = True err = True
if len(self.rqdata.runtaskentries[x].depends) == 0 and x not in self.runq_buildable: if not self.rqdata.runtaskentries[x].depends and x not in self.runq_buildable:
logger.error("Task %s was never marked as buildable by the setscene code" % x) logger.error("Task %s was never marked as buildable by the setscene code" % x)
err = True err = True
return err return err
@@ -2025,7 +2025,7 @@ class RunQueueExecute:
# Find the next setscene to run # Find the next setscene to run
for nexttask in self.sorted_setscene_tids: for nexttask in self.sorted_setscene_tids:
if nexttask in self.sq_buildable and nexttask not in self.sq_running and self.sqdata.stamps[nexttask] not in self.build_stamps.values(): if nexttask in self.sq_buildable and nexttask not in self.sq_running and self.sqdata.stamps[nexttask] not in self.build_stamps.values():
if nexttask not in self.sqdata.unskippable and len(self.sqdata.sq_revdeps[nexttask]) > 0 and self.sqdata.sq_revdeps[nexttask].issubset(self.scenequeue_covered) and self.check_dependencies(nexttask, self.sqdata.sq_revdeps[nexttask]): if nexttask not in self.sqdata.unskippable and self.sqdata.sq_revdeps[nexttask] and self.sqdata.sq_revdeps[nexttask].issubset(self.scenequeue_covered) and self.check_dependencies(nexttask, self.sqdata.sq_revdeps[nexttask]):
if nexttask not in self.rqdata.target_tids: if nexttask not in self.rqdata.target_tids:
logger.debug2("Skipping setscene for task %s" % nexttask) logger.debug2("Skipping setscene for task %s" % nexttask)
self.sq_task_skip(nexttask) self.sq_task_skip(nexttask)
@@ -2189,7 +2189,7 @@ class RunQueueExecute:
if self.can_start_task(): if self.can_start_task():
return True return True
if self.stats.active > 0 or len(self.sq_live) > 0: if self.stats.active > 0 or self.sq_live:
self.rq.read_workers() self.rq.read_workers()
return self.rq.active_fds() return self.rq.active_fds()
@@ -2201,7 +2201,7 @@ class RunQueueExecute:
self.sq_task_failoutright(tid) self.sq_task_failoutright(tid)
return True return True
if len(self.failed_tids) != 0: if self.failed_tids:
self.rq.state = runQueueFailed self.rq.state = runQueueFailed
return True return True
@@ -2280,7 +2280,7 @@ class RunQueueExecute:
covered.intersection_update(self.tasks_scenequeue_done) covered.intersection_update(self.tasks_scenequeue_done)
for tid in notcovered | covered: for tid in notcovered | covered:
if len(self.rqdata.runtaskentries[tid].depends) == 0: if not self.rqdata.runtaskentries[tid].depends:
self.setbuildable(tid) self.setbuildable(tid)
elif self.rqdata.runtaskentries[tid].depends.issubset(self.runq_complete): elif self.rqdata.runtaskentries[tid].depends.issubset(self.runq_complete):
self.setbuildable(tid) self.setbuildable(tid)
@@ -2339,7 +2339,7 @@ class RunQueueExecute:
# Now iterate those tasks in dependency order to regenerate their taskhash/unihash # Now iterate those tasks in dependency order to regenerate their taskhash/unihash
next = set() next = set()
for p in total: for p in total:
if len(self.rqdata.runtaskentries[p].depends) == 0: if not self.rqdata.runtaskentries[p].depends:
next.add(p) next.add(p)
elif self.rqdata.runtaskentries[p].depends.isdisjoint(total): elif self.rqdata.runtaskentries[p].depends.isdisjoint(total):
next.add(p) next.add(p)
@@ -2349,7 +2349,7 @@ class RunQueueExecute:
current = next.copy() current = next.copy()
next = set() next = set()
for tid in current: for tid in current:
if len(self.rqdata.runtaskentries[p].depends) and not self.rqdata.runtaskentries[tid].depends.isdisjoint(total): if self.rqdata.runtaskentries[p].depends and not self.rqdata.runtaskentries[tid].depends.isdisjoint(total):
continue continue
orighash = self.rqdata.runtaskentries[tid].hash orighash = self.rqdata.runtaskentries[tid].hash
dc = bb.parse.siggen.get_data_caches(self.rqdata.dataCaches, mc_from_tid(tid)) dc = bb.parse.siggen.get_data_caches(self.rqdata.dataCaches, mc_from_tid(tid))
@@ -2436,7 +2436,7 @@ class RunQueueExecute:
if not harddepfail and self.sqdata.sq_revdeps[tid].issubset(self.scenequeue_covered | self.scenequeue_notcovered): if not harddepfail and self.sqdata.sq_revdeps[tid].issubset(self.scenequeue_covered | self.scenequeue_notcovered):
if tid not in self.sq_buildable: if tid not in self.sq_buildable:
self.sq_buildable.add(tid) self.sq_buildable.add(tid)
if len(self.sqdata.sq_revdeps[tid]) == 0: if not self.sqdata.sq_revdeps[tid]:
self.sq_buildable.add(tid) self.sq_buildable.add(tid)
if tid in self.sqdata.outrightfail: if tid in self.sqdata.outrightfail:
@@ -2652,7 +2652,7 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
for tid in rqdata.runtaskentries: for tid in rqdata.runtaskentries:
sq_revdeps[tid] = copy.copy(rqdata.runtaskentries[tid].revdeps) sq_revdeps[tid] = copy.copy(rqdata.runtaskentries[tid].revdeps)
sq_revdeps_squash[tid] = set() sq_revdeps_squash[tid] = set()
if (len(sq_revdeps[tid]) == 0) and tid not in rqdata.runq_setscene_tids: if not sq_revdeps[tid] and tid not in rqdata.runq_setscene_tids:
#bb.warn("Added endpoint %s" % (tid)) #bb.warn("Added endpoint %s" % (tid))
endpoints[tid] = set() endpoints[tid] = set()
@@ -2693,9 +2693,9 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
sq_revdeps[dep].remove(point) sq_revdeps[dep].remove(point)
if tasks: if tasks:
sq_revdeps_squash[dep] |= tasks sq_revdeps_squash[dep] |= tasks
if len(sq_revdeps[dep]) == 0 and dep not in rqdata.runq_setscene_tids: if not sq_revdeps[dep] and dep not in rqdata.runq_setscene_tids:
newendpoints[dep] = task newendpoints[dep] = task
if len(newendpoints) != 0: if newendpoints:
process_endpoints(newendpoints) process_endpoints(newendpoints)
process_endpoints(endpoints) process_endpoints(endpoints)
@@ -2707,7 +2707,7 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
# Take the build endpoints (no revdeps) and find the sstate tasks they depend upon # Take the build endpoints (no revdeps) and find the sstate tasks they depend upon
new = True new = True
for tid in rqdata.runtaskentries: for tid in rqdata.runtaskentries:
if len(rqdata.runtaskentries[tid].revdeps) == 0: if not rqdata.runtaskentries[tid].revdeps:
sqdata.unskippable.add(tid) sqdata.unskippable.add(tid)
sqdata.unskippable |= sqrq.cantskip sqdata.unskippable |= sqrq.cantskip
while new: while new:
@@ -2716,7 +2716,7 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
for tid in sorted(orig, reverse=True): for tid in sorted(orig, reverse=True):
if tid in rqdata.runq_setscene_tids: if tid in rqdata.runq_setscene_tids:
continue continue
if len(rqdata.runtaskentries[tid].depends) == 0: if not rqdata.runtaskentries[tid].depends:
# These are tasks which have no setscene tasks in their chain, need to mark as directly buildable # These are tasks which have no setscene tasks in their chain, need to mark as directly buildable
sqrq.setbuildable(tid) sqrq.setbuildable(tid)
sqdata.unskippable |= rqdata.runtaskentries[tid].depends sqdata.unskippable |= rqdata.runtaskentries[tid].depends
@@ -2731,7 +2731,7 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
for taskcounter, tid in enumerate(rqdata.runtaskentries): for taskcounter, tid in enumerate(rqdata.runtaskentries):
if tid in rqdata.runq_setscene_tids: if tid in rqdata.runq_setscene_tids:
pass pass
elif len(sq_revdeps_squash[tid]) != 0: elif sq_revdeps_squash[tid]:
bb.msg.fatal("RunQueue", "Something went badly wrong during scenequeue generation, aborting. Please report this problem.") bb.msg.fatal("RunQueue", "Something went badly wrong during scenequeue generation, aborting. Please report this problem.")
else: else:
del sq_revdeps_squash[tid] del sq_revdeps_squash[tid]
@@ -2796,7 +2796,7 @@ def build_scenequeue_data(sqdata, rqdata, rq, cooker, stampcache, sqrq):
sqdata.multiconfigs = set() sqdata.multiconfigs = set()
for tid in sqdata.sq_revdeps: for tid in sqdata.sq_revdeps:
sqdata.multiconfigs.add(mc_from_tid(tid)) sqdata.multiconfigs.add(mc_from_tid(tid))
if len(sqdata.sq_revdeps[tid]) == 0: if not sqdata.sq_revdeps[tid]:
sqrq.sq_buildable.add(tid) sqrq.sq_buildable.add(tid)
rqdata.init_progress_reporter.finish() rqdata.init_progress_reporter.finish()
@@ -3050,7 +3050,7 @@ class runQueuePipe():
raise raise
end = len(self.queue) end = len(self.queue)
found = True found = True
while found and len(self.queue): while found and self.queue:
found = False found = False
index = self.queue.find(b"</event>") index = self.queue.find(b"</event>")
while index != -1 and self.queue.startswith(b"<event>"): while index != -1 and self.queue.startswith(b"<event>"):
@@ -3088,7 +3088,7 @@ class runQueuePipe():
def close(self): def close(self):
while self.read(): while self.read():
continue continue
if len(self.queue) > 0: if self.queue:
print("Warning, worker left partial message: %s" % self.queue) print("Warning, worker left partial message: %s" % self.queue)
self.input.close() self.input.close()
+2 -2
View File
@@ -451,12 +451,12 @@ class TaskData:
for target in self.build_targets: for target in self.build_targets:
if fn in self.build_targets[target]: if fn in self.build_targets[target]:
self.build_targets[target].remove(fn) self.build_targets[target].remove(fn)
if len(self.build_targets[target]) == 0: if not self.build_targets[target]:
self.remove_buildtarget(target, missing_list) self.remove_buildtarget(target, missing_list)
for target in self.run_targets: for target in self.run_targets:
if fn in self.run_targets[target]: if fn in self.run_targets[target]:
self.run_targets[target].remove(fn) self.run_targets[target].remove(fn)
if len(self.run_targets[target]) == 0: if not self.run_targets[target]:
self.remove_runtarget(target, missing_list) self.remove_runtarget(target, missing_list)
def remove_buildtarget(self, target, missing_list=None): def remove_buildtarget(self, target, missing_list=None):
+10 -10
View File
@@ -483,11 +483,11 @@ class ORMWrapper(object):
# we already created the root directory, so ignore any # we already created the root directory, so ignore any
# entry for it # entry for it
if len(path) == 0: if not path:
continue continue
parent_path = "/".join(path.split("/")[:len(path.split("/")) - 1]) parent_path = "/".join(path.split("/")[:len(path.split("/")) - 1])
if len(parent_path) == 0: if not parent_path:
parent_path = "/" parent_path = "/"
parent_obj = self._cached_get(Target_File, target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY) parent_obj = self._cached_get(Target_File, target = target_obj, path = parent_path, inodetype = Target_File.ITYPE_DIRECTORY)
tf_obj = Target_File.objects.create( tf_obj = Target_File.objects.create(
@@ -633,7 +633,7 @@ class ORMWrapper(object):
packagefile_objects.append(Package_File( package = packagedict[p]['object'], packagefile_objects.append(Package_File( package = packagedict[p]['object'],
path = targetpath, path = targetpath,
size = targetfilesize)) size = targetfilesize))
if len(packagefile_objects): if packagefile_objects:
Package_File.objects.bulk_create(packagefile_objects) Package_File.objects.bulk_create(packagefile_objects)
except KeyError as e: except KeyError as e:
errormsg += " stpi: Key error, package %s key %s \n" % ( p, e ) errormsg += " stpi: Key error, package %s key %s \n" % ( p, e )
@@ -673,7 +673,7 @@ class ORMWrapper(object):
logger.warning("Could not add dependency to the package %s " logger.warning("Could not add dependency to the package %s "
"because %s is an unknown package", p, px) "because %s is an unknown package", p, px)
if len(packagedeps_objs) > 0: if packagedeps_objs:
Package_Dependency.objects.bulk_create(packagedeps_objs) Package_Dependency.objects.bulk_create(packagedeps_objs)
else: else:
logger.info("No package dependencies created") logger.info("No package dependencies created")
@@ -767,7 +767,7 @@ class ORMWrapper(object):
packagefile_objects.append(Package_File( package = bp_object, packagefile_objects.append(Package_File( package = bp_object,
path = path, path = path,
size = package_info['FILES_INFO'][path] )) size = package_info['FILES_INFO'][path] ))
if len(packagefile_objects): if packagefile_objects:
Package_File.objects.bulk_create(packagefile_objects) Package_File.objects.bulk_create(packagefile_objects)
def _po_byname(p): def _po_byname(p):
@@ -809,7 +809,7 @@ class ORMWrapper(object):
packagedeps_objs.append(Package_Dependency( package = bp_object, packagedeps_objs.append(Package_Dependency( package = bp_object,
depends_on = _po_byname(p), dep_type = Package_Dependency.TYPE_RCONFLICTS)) depends_on = _po_byname(p), dep_type = Package_Dependency.TYPE_RCONFLICTS))
if len(packagedeps_objs) > 0: if packagedeps_objs:
Package_Dependency.objects.bulk_create(packagedeps_objs) Package_Dependency.objects.bulk_create(packagedeps_objs)
return bp_object return bp_object
@@ -826,7 +826,7 @@ class ORMWrapper(object):
desc = vardump[root_var]['doc'] desc = vardump[root_var]['doc']
if desc is None: if desc is None:
desc = '' desc = ''
if len(desc): if desc:
HelpText.objects.get_or_create(build=build_obj, HelpText.objects.get_or_create(build=build_obj,
area=HelpText.VARIABLE, area=HelpText.VARIABLE,
key=k, text=desc) key=k, text=desc)
@@ -846,7 +846,7 @@ class ORMWrapper(object):
file_name = vh['file'], file_name = vh['file'],
line_number = vh['line'], line_number = vh['line'],
operation = vh['op'])) operation = vh['op']))
if len(varhist_objects): if varhist_objects:
VariableHistory.objects.bulk_create(varhist_objects) VariableHistory.objects.bulk_create(varhist_objects)
@@ -1069,7 +1069,7 @@ class BuildInfoHelper(object):
for t in self.internal_state['targets']: for t in self.internal_state['targets']:
buildname = self.internal_state['build'].build_name buildname = self.internal_state['build'].build_name
pe, pv = task_object.recipe.version.split(":",1) pe, pv = task_object.recipe.version.split(":",1)
if len(pe) > 0: if pe:
package = task_object.recipe.name + "-" + pe + "_" + pv package = task_object.recipe.name + "-" + pe + "_" + pv
else: else:
package = task_object.recipe.name + "-" + pv package = task_object.recipe.name + "-" + pv
@@ -1618,7 +1618,7 @@ class BuildInfoHelper(object):
if 'backlog' in self.internal_state: if 'backlog' in self.internal_state:
# if we have a backlog of events, do our best to save them here # if we have a backlog of events, do our best to save them here
if len(self.internal_state['backlog']): if self.internal_state['backlog']:
tempevent = self.internal_state['backlog'].pop() tempevent = self.internal_state['backlog'].pop()
logger.debug("buildinfohelper: Saving stored event %s " logger.debug("buildinfohelper: Saving stored event %s "
% tempevent) % tempevent)
+2 -2
View File
@@ -73,13 +73,13 @@ class BBUIEventQueue:
self.eventQueueLock.acquire() self.eventQueueLock.acquire()
if len(self.eventQueue) == 0: if not self.eventQueue:
self.eventQueueLock.release() self.eventQueueLock.release()
return None return None
item = self.eventQueue.pop(0) item = self.eventQueue.pop(0)
if len(self.eventQueue) == 0: if not self.eventQueue:
self.eventQueueNotify.clear() self.eventQueueNotify.clear()
self.eventQueueLock.release() self.eventQueueLock.release()