summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-08-17 12:12:16 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 18:05:44 +0100
commit715d857174ceca82b85d6c8c7df520047ba7fb0c (patch)
tree363aac81a06b013471f1dede8ba4c0dc7d8bbe92 /bitbake
parent22a653d02880c35d3c9d04811c31aabdf1e69951 (diff)
downloadpoky-715d857174ceca82b85d6c8c7df520047ba7fb0c.tar.gz
bitbake: Fix default function parameter assignment to a list
With python you should not assign a list as the default value of a function parameter - because a list is mutable, the result will be that the first time a value is passed it will actually modify the default. Reference: http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments (Bitbake rev: 7859f7388f2e3f675d0e1527cfde18625f36f637) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/cooker.py15
-rw-r--r--bitbake/lib/bb/event.py4
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py23
-rw-r--r--bitbake/lib/bb/msg.py7
-rw-r--r--bitbake/lib/bb/process.py5
-rw-r--r--bitbake/lib/bb/server/process.py4
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py7
-rw-r--r--bitbake/lib/bb/taskdata.py8
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobeventhandler.py12
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py4
10 files changed, 58 insertions, 31 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 0f99342a0f..84bf46b9ee 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -114,12 +114,13 @@ class BBCooker:
114 Manages one bitbake build run 114 Manages one bitbake build run
115 """ 115 """
116 116
117 def __init__(self, configuration, featureSet = []): 117 def __init__(self, configuration, featureSet=None):
118 self.recipecache = None 118 self.recipecache = None
119 self.skiplist = {} 119 self.skiplist = {}
120 self.featureset = CookerFeatures() 120 self.featureset = CookerFeatures()
121 for f in featureSet: 121 if featureSet:
122 self.featureset.setFeature(f) 122 for f in featureSet:
123 self.featureset.setFeature(f)
123 124
124 self.configuration = configuration 125 self.configuration = configuration
125 126
@@ -567,12 +568,14 @@ class BBCooker:
567 568
568 logger.plain("%-35s %25s %25s", p, lateststr, prefstr) 569 logger.plain("%-35s %25s %25s", p, lateststr, prefstr)
569 570
570 def showEnvironment(self, buildfile = None, pkgs_to_build = []): 571 def showEnvironment(self, buildfile=None, pkgs_to_build=None):
571 """ 572 """
572 Show the outer or per-recipe environment 573 Show the outer or per-recipe environment
573 """ 574 """
574 fn = None 575 fn = None
575 envdata = None 576 envdata = None
577 if not pkgs_to_build:
578 pkgs_to_build = []
576 579
577 if buildfile: 580 if buildfile:
578 # Parse the configuration here. We need to do it explicitly here since 581 # Parse the configuration here. We need to do it explicitly here since
@@ -1037,13 +1040,13 @@ class BBCooker:
1037 1040
1038 return pkg_list 1041 return pkg_list
1039 1042
1040 def generateTargetsTree(self, klass=None, pkgs=[]): 1043 def generateTargetsTree(self, klass=None, pkgs=None):
1041 """ 1044 """
1042 Generate a dependency tree of buildable targets 1045 Generate a dependency tree of buildable targets
1043 Generate an event with the result 1046 Generate an event with the result
1044 """ 1047 """
1045 # if the caller hasn't specified a pkgs list default to universe 1048 # if the caller hasn't specified a pkgs list default to universe
1046 if not len(pkgs): 1049 if not pkgs:
1047 pkgs = ['universe'] 1050 pkgs = ['universe']
1048 # if inherited_class passed ensure all recipes which inherit the 1051 # if inherited_class passed ensure all recipes which inherit the
1049 # specified class are included in pkgs 1052 # specified class are included in pkgs
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 61a7f4a265..0e181102c6 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -176,7 +176,7 @@ def fire_from_worker(event, d):
176 fire_ui_handlers(event, d) 176 fire_ui_handlers(event, d)
177 177
178noop = lambda _: None 178noop = lambda _: None
179def register(name, handler, mask=[]): 179def register(name, handler, mask=None):
180 """Register an Event handler""" 180 """Register an Event handler"""
181 181
182 # already registered 182 # already registered
@@ -389,7 +389,7 @@ class DiskFull(Event):
389class NoProvider(Event): 389class NoProvider(Event):
390 """No Provider for an Event""" 390 """No Provider for an Event"""
391 391
392 def __init__(self, item, runtime=False, dependees=None, reasons=[], close_matches=[]): 392 def __init__(self, item, runtime=False, dependees=None, reasons=None, close_matches=None):
393 Event.__init__(self) 393 Event.__init__(self)
394 self._item = item 394 self._item = item
395 self._runtime = runtime 395 self._runtime = runtime
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 7b4d130f5f..ec0c31ae21 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -777,7 +777,7 @@ def localpath(url, d):
777 fetcher = bb.fetch2.Fetch([url], d) 777 fetcher = bb.fetch2.Fetch([url], d)
778 return fetcher.localpath(url) 778 return fetcher.localpath(url)
779 779
780def runfetchcmd(cmd, d, quiet = False, cleanup = []): 780def runfetchcmd(cmd, d, quiet=False, cleanup=None):
781 """ 781 """
782 Run cmd returning the command output 782 Run cmd returning the command output
783 Raise an error if interrupted or cmd fails 783 Raise an error if interrupted or cmd fails
@@ -802,6 +802,9 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []):
802 'SSH_AUTH_SOCK', 'SSH_AGENT_PID', 802 'SSH_AUTH_SOCK', 'SSH_AGENT_PID',
803 'SOCKS5_USER', 'SOCKS5_PASSWD'] 803 'SOCKS5_USER', 'SOCKS5_PASSWD']
804 804
805 if not cleanup:
806 cleanup = []
807
805 for var in exportvars: 808 for var in exportvars:
806 val = d.getVar(var, True) 809 val = d.getVar(var, True)
807 if val: 810 if val:
@@ -1267,7 +1270,7 @@ class FetchData(object):
1267class FetchMethod(object): 1270class FetchMethod(object):
1268 """Base class for 'fetch'ing data""" 1271 """Base class for 'fetch'ing data"""
1269 1272
1270 def __init__(self, urls = []): 1273 def __init__(self, urls=None):
1271 self.urls = [] 1274 self.urls = []
1272 1275
1273 def supports(self, urldata, d): 1276 def supports(self, urldata, d):
@@ -1552,11 +1555,11 @@ class Fetch(object):
1552 1555
1553 return local 1556 return local
1554 1557
1555 def download(self, urls = []): 1558 def download(self, urls=None):
1556 """ 1559 """
1557 Fetch all urls 1560 Fetch all urls
1558 """ 1561 """
1559 if len(urls) == 0: 1562 if not urls:
1560 urls = self.urls 1563 urls = self.urls
1561 1564
1562 network = self.d.getVar("BB_NO_NETWORK", True) 1565 network = self.d.getVar("BB_NO_NETWORK", True)
@@ -1634,12 +1637,12 @@ class Fetch(object):
1634 finally: 1637 finally:
1635 bb.utils.unlockfile(lf) 1638 bb.utils.unlockfile(lf)
1636 1639
1637 def checkstatus(self, urls = []): 1640 def checkstatus(self, urls=None):
1638 """ 1641 """
1639 Check all urls exist upstream 1642 Check all urls exist upstream
1640 """ 1643 """
1641 1644
1642 if len(urls) == 0: 1645 if not urls:
1643 urls = self.urls 1646 urls = self.urls
1644 1647
1645 for u in urls: 1648 for u in urls:
@@ -1662,12 +1665,12 @@ class Fetch(object):
1662 if not ret: 1665 if not ret:
1663 raise FetchError("URL %s doesn't work" % u, u) 1666 raise FetchError("URL %s doesn't work" % u, u)
1664 1667
1665 def unpack(self, root, urls = []): 1668 def unpack(self, root, urls=None):
1666 """ 1669 """
1667 Check all urls exist upstream 1670 Check all urls exist upstream
1668 """ 1671 """
1669 1672
1670 if len(urls) == 0: 1673 if not urls:
1671 urls = self.urls 1674 urls = self.urls
1672 1675
1673 for u in urls: 1676 for u in urls:
@@ -1685,12 +1688,12 @@ class Fetch(object):
1685 if ud.lockfile: 1688 if ud.lockfile:
1686 bb.utils.unlockfile(lf) 1689 bb.utils.unlockfile(lf)
1687 1690
1688 def clean(self, urls = []): 1691 def clean(self, urls=None):
1689 """ 1692 """
1690 Clean files that the fetcher gets or places 1693 Clean files that the fetcher gets or places
1691 """ 1694 """
1692 1695
1693 if len(urls) == 0: 1696 if not urls:
1694 urls = self.urls 1697 urls = self.urls
1695 1698
1696 for url in urls: 1699 for url in urls:
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index d79768db24..786b5aef40 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -150,7 +150,7 @@ loggerDefaultVerbose = False
150loggerVerboseLogs = False 150loggerVerboseLogs = False
151loggerDefaultDomains = [] 151loggerDefaultDomains = []
152 152
153def init_msgconfig(verbose, debug, debug_domains = []): 153def init_msgconfig(verbose, debug, debug_domains=None):
154 """ 154 """
155 Set default verbosity and debug levels config the logger 155 Set default verbosity and debug levels config the logger
156 """ 156 """
@@ -158,7 +158,10 @@ def init_msgconfig(verbose, debug, debug_domains = []):
158 bb.msg.loggerDefaultVerbose = verbose 158 bb.msg.loggerDefaultVerbose = verbose
159 if verbose: 159 if verbose:
160 bb.msg.loggerVerboseLogs = True 160 bb.msg.loggerVerboseLogs = True
161 bb.msg.loggerDefaultDomains = debug_domains 161 if debug_domains:
162 bb.msg.loggerDefaultDomains = debug_domains
163 else:
164 bb.msg.loggerDefaultDomains = []
162 165
163def constructLogOptions(): 166def constructLogOptions():
164 debug = loggerDefaultDebugLevel 167 debug = loggerDefaultDebugLevel
diff --git a/bitbake/lib/bb/process.py b/bitbake/lib/bb/process.py
index 7c797852ed..1c07f2d9b7 100644
--- a/bitbake/lib/bb/process.py
+++ b/bitbake/lib/bb/process.py
@@ -128,10 +128,13 @@ def _logged_communicate(pipe, log, input, extrafiles):
128 pipe.stderr.close() 128 pipe.stderr.close()
129 return ''.join(outdata), ''.join(errdata) 129 return ''.join(outdata), ''.join(errdata)
130 130
131def run(cmd, input=None, log=None, extrafiles=[], **options): 131def run(cmd, input=None, log=None, extrafiles=None, **options):
132 """Convenience function to run a command and return its output, raising an 132 """Convenience function to run a command and return its output, raising an
133 exception when the command fails""" 133 exception when the command fails"""
134 134
135 if not extrafiles:
136 extrafiles = []
137
135 if isinstance(cmd, basestring) and not "shell" in options: 138 if isinstance(cmd, basestring) and not "shell" in options:
136 options["shell"] = True 139 options["shell"] = True
137 140
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index ef3ee57aa4..3198635e2f 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -124,8 +124,10 @@ class ProcessServer(Process, BaseImplServer):
124 self.command_channel.close() 124 self.command_channel.close()
125 self.cooker.shutdown(True) 125 self.cooker.shutdown(True)
126 126
127 def idle_commands(self, delay, fds = []): 127 def idle_commands(self, delay, fds=None):
128 nextsleep = delay 128 nextsleep = delay
129 if not fds:
130 fds = []
129 131
130 for function, data in self._idlefuns.items(): 132 for function, data in self._idlefuns.items():
131 try: 133 try:
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index 75ec8556f4..f1a2067246 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -281,12 +281,15 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
281 self.connection_token = token 281 self.connection_token = token
282 282
283class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection): 283class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
284 def __init__(self, serverImpl, clientinfo=("localhost", 0), observer_only = False, featureset = []): 284 def __init__(self, serverImpl, clientinfo=("localhost", 0), observer_only = False, featureset = None):
285 self.connection, self.transport = _create_server(serverImpl.host, serverImpl.port) 285 self.connection, self.transport = _create_server(serverImpl.host, serverImpl.port)
286 self.clientinfo = clientinfo 286 self.clientinfo = clientinfo
287 self.serverImpl = serverImpl 287 self.serverImpl = serverImpl
288 self.observer_only = observer_only 288 self.observer_only = observer_only
289 self.featureset = featureset 289 if featureset:
290 self.featureset = featureset
291 else:
292 self.featureset = []
290 293
291 def connect(self, token = None): 294 def connect(self, token = None):
292 if token is None: 295 if token is None:
diff --git a/bitbake/lib/bb/taskdata.py b/bitbake/lib/bb/taskdata.py
index ca58e17922..5fab7043cc 100644
--- a/bitbake/lib/bb/taskdata.py
+++ b/bitbake/lib/bb/taskdata.py
@@ -514,7 +514,7 @@ class TaskData:
514 self.add_runtime_target(fn, item) 514 self.add_runtime_target(fn, item)
515 self.add_tasks(fn, dataCache) 515 self.add_tasks(fn, dataCache)
516 516
517 def fail_fnid(self, fnid, missing_list = []): 517 def fail_fnid(self, fnid, missing_list=None):
518 """ 518 """
519 Mark a file as failed (unbuildable) 519 Mark a file as failed (unbuildable)
520 Remove any references from build and runtime provider lists 520 Remove any references from build and runtime provider lists
@@ -523,6 +523,8 @@ class TaskData:
523 """ 523 """
524 if fnid in self.failed_fnids: 524 if fnid in self.failed_fnids:
525 return 525 return
526 if not missing_list:
527 missing_list = []
526 logger.debug(1, "File '%s' is unbuildable, removing...", self.fn_index[fnid]) 528 logger.debug(1, "File '%s' is unbuildable, removing...", self.fn_index[fnid])
527 self.failed_fnids.append(fnid) 529 self.failed_fnids.append(fnid)
528 for target in self.build_targets: 530 for target in self.build_targets:
@@ -536,7 +538,7 @@ class TaskData:
536 if len(self.run_targets[target]) == 0: 538 if len(self.run_targets[target]) == 0:
537 self.remove_runtarget(target, missing_list) 539 self.remove_runtarget(target, missing_list)
538 540
539 def remove_buildtarget(self, targetid, missing_list = []): 541 def remove_buildtarget(self, targetid, missing_list=None):
540 """ 542 """
541 Mark a build target as failed (unbuildable) 543 Mark a build target as failed (unbuildable)
542 Trigger removal of any files that have this as a dependency 544 Trigger removal of any files that have this as a dependency
@@ -561,7 +563,7 @@ class TaskData:
561 logger.error("Required build target '%s' has no buildable providers.\nMissing or unbuildable dependency chain was: %s", target, missing_list) 563 logger.error("Required build target '%s' has no buildable providers.\nMissing or unbuildable dependency chain was: %s", target, missing_list)
562 raise bb.providers.NoProvider(target) 564 raise bb.providers.NoProvider(target)
563 565
564 def remove_runtarget(self, targetid, missing_list = []): 566 def remove_runtarget(self, targetid, missing_list=None):
565 """ 567 """
566 Mark a run target as failed (unbuildable) 568 Mark a run target as failed (unbuildable)
567 Trigger removal of any files that have this as a dependency 569 Trigger removal of any files that have this as a dependency
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index 43edb70b08..b71fb33d30 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -440,11 +440,17 @@ class HobHandler(gobject.GObject):
440 self.commands_async.append(self.SUB_BUILD_RECIPES) 440 self.commands_async.append(self.SUB_BUILD_RECIPES)
441 self.run_next_command(self.GENERATE_PACKAGES) 441 self.run_next_command(self.GENERATE_PACKAGES)
442 442
443 def generate_image(self, image, base_image, image_packages=[], toolchain_packages=[], default_task="build"): 443 def generate_image(self, image, base_image, image_packages=None, toolchain_packages=None, default_task="build"):
444 self.image = image 444 self.image = image
445 self.base_image = base_image 445 self.base_image = base_image
446 self.package_queue = image_packages 446 if image_packages:
447 self.toolchain_packages = toolchain_packages 447 self.package_queue = image_packages
448 else:
449 self.package_queue = []
450 if toolchain_packages:
451 self.toolchain_packages = toolchain_packages
452 else:
453 self.toolchain_packages = []
448 self.default_task = default_task 454 self.default_task = default_task
449 self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""]) 455 self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
450 self.commands_async.append(self.SUB_PARSE_CONFIG) 456 self.commands_async.append(self.SUB_PARSE_CONFIG)
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 889b6c64ca..d29ddd6099 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -522,7 +522,9 @@ def builddashboard( request, build_id ):
522 522
523 523
524 524
525def generateCoveredList2( revlist = [] ): 525def generateCoveredList2( revlist = None ):
526 if not revlist:
527 revlist = []
526 covered_list = [ x for x in revlist if x.outcome == Task.OUTCOME_COVERED ] 528 covered_list = [ x for x in revlist if x.outcome == Task.OUTCOME_COVERED ]
527 while len(covered_list): 529 while len(covered_list):
528 revlist = [ x for x in revlist if x.outcome != Task.OUTCOME_COVERED ] 530 revlist = [ x for x in revlist if x.outcome != Task.OUTCOME_COVERED ]