Patchwork [bitbake-devel,07/13] bitbake: cooker, command: add a command to return global data

login
register
mail settings
Submitter Alexandru DAMIAN
Date Sept. 9, 2013, 4:40 p.m.
Message ID <a1812224527bb7669488131821eb6989fcda6917.1378743829.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/57691/
State New
Headers show

Comments

Alexandru DAMIAN - Sept. 9, 2013, 4:40 p.m.
From: Alexandru DAMIAN <alexandru.damian@intel.com>

Adding the 'getDataDump' read-only command that will
return a dump of the global data state.

This will be used by the DSI to store the build configuration.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 bitbake/lib/bb/command.py |  7 +++++++
 bitbake/lib/bb/cooker.py  | 13 +++++++++++++
 2 files changed, 20 insertions(+)
Richard Purdie - Sept. 13, 2013, 2:52 p.m.
On Mon, 2013-09-09 at 17:40 +0100, Alex DAMIAN wrote:
> From: Alexandru DAMIAN <alexandru.damian@intel.com>
> 
> Adding the 'getDataDump' read-only command that will
> return a dump of the global data state.
> 
> This will be used by the DSI to store the build configuration.
> 
> Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
> ---
>  bitbake/lib/bb/command.py |  7 +++++++
>  bitbake/lib/bb/cooker.py  | 13 +++++++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
> index 3527ad0..4d36c4b 100644
> --- a/bitbake/lib/bb/command.py
> +++ b/bitbake/lib/bb/command.py
> @@ -145,6 +145,13 @@ class CommandsSync:
>          """
>          command.cooker.stop()
>  
> +    def getDataDump(self, command, params):
> +        """
> +        Returns a dump of the global state.
> +        """
> +        return command.cooker.getGlobalExpandedData()
> +    getDataDump.readonly = True
> +
>      def getVariable(self, command, params):
>          """
>          Read the value of a variable from data
> diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
> index 9fd3417..383c9c4 100644
> --- a/bitbake/lib/bb/cooker.py
> +++ b/bitbake/lib/bb/cooker.py
> @@ -1117,6 +1117,19 @@ class BBCooker:
>  
>          self.configuration.server_register_idlecallback(buildTargetsIdle, rq)
>  
> +
> +    def getGlobalExpandedData(self):
> +        dump = {}
> +        for k in self.data.keys():
> +            try:
> +                v = self.data.getVar(k, True)
> +                if not k.startswith("__") and not bool(self.data.getVarFlag(k, 'func')) and not isinstance(v, bb.data_smart.DataSmart):
> +                    dump[k] = { 'v' : v, 'd' : self.data.getVarFlag(k, 'doc') }
> +            except:
> +                pass
> +        return dump

There is a 'doc' hardcoded into there, perhaps this should be a better
named command and take a parameter?

Cheers,

Richard

Patch

diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 3527ad0..4d36c4b 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -145,6 +145,13 @@  class CommandsSync:
         """
         command.cooker.stop()
 
+    def getDataDump(self, command, params):
+        """
+        Returns a dump of the global state.
+        """
+        return command.cooker.getGlobalExpandedData()
+    getDataDump.readonly = True
+
     def getVariable(self, command, params):
         """
         Read the value of a variable from data
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 9fd3417..383c9c4 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1117,6 +1117,19 @@  class BBCooker:
 
         self.configuration.server_register_idlecallback(buildTargetsIdle, rq)
 
+
+    def getGlobalExpandedData(self):
+        dump = {}
+        for k in self.data.keys():
+            try:
+                v = self.data.getVar(k, True)
+                if not k.startswith("__") and not bool(self.data.getVarFlag(k, 'func')) and not isinstance(v, bb.data_smart.DataSmart):
+                    dump[k] = { 'v' : v, 'd' : self.data.getVarFlag(k, 'doc') }
+            except:
+                pass
+        return dump
+
+
     def generateNewImage(self, image, base_image, package_queue, timestamp, description):
         '''
         Create a new image with a "require"/"inherit" base_image statement