summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2015-05-11 16:17:01 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-16 22:31:50 +0100
commit7883af3097e043dd5b0f2c6f5f37189d9f70549e (patch)
tree449b76bfab9f172c2c55b8161f72f17b6b296abe /scripts
parentc977cdf3d85da74ff4f5c9b10bf3caad7cb25204 (diff)
downloadpoky-7883af3097e043dd5b0f2c6f5f37189d9f70549e.tar.gz
devtool: add missing docstrings
(From OE-Core rev: 07b2e731a378c56852e2715f6c001097b81abe46) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/devtool/__init__.py5
-rw-r--r--scripts/lib/devtool/deploy.py6
-rw-r--r--scripts/lib/devtool/standard.py20
3 files changed, 28 insertions, 3 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index f19d0328f3..88665124d1 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -16,7 +16,7 @@
16# You should have received a copy of the GNU General Public License along 16# You should have received a copy of the GNU General Public License along
17# with this program; if not, write to the Free Software Foundation, Inc., 17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 19"""Devtool plugins module"""
20 20
21import os 21import os
22import sys 22import sys
@@ -26,6 +26,7 @@ import logging
26logger = logging.getLogger('devtool') 26logger = logging.getLogger('devtool')
27 27
28def exec_build_env_command(init_path, builddir, cmd, watch=False, **options): 28def exec_build_env_command(init_path, builddir, cmd, watch=False, **options):
29 """Run a program in bitbake build context"""
29 import bb 30 import bb
30 if not 'cwd' in options: 31 if not 'cwd' in options:
31 options["cwd"] = builddir 32 options["cwd"] = builddir
@@ -49,6 +50,7 @@ def exec_build_env_command(init_path, builddir, cmd, watch=False, **options):
49 return bb.process.run('%s%s' % (init_prefix, cmd), **options) 50 return bb.process.run('%s%s' % (init_prefix, cmd), **options)
50 51
51def exec_watch(cmd, **options): 52def exec_watch(cmd, **options):
53 """Run program with stdout shown on sys.stdout"""
52 if isinstance(cmd, basestring) and not "shell" in options: 54 if isinstance(cmd, basestring) and not "shell" in options:
53 options["shell"] = True 55 options["shell"] = True
54 56
@@ -68,6 +70,7 @@ def exec_watch(cmd, **options):
68 return buf 70 return buf
69 71
70def setup_tinfoil(): 72def setup_tinfoil():
73 """Initialize tinfoil api from bitbake"""
71 import scriptpath 74 import scriptpath
72 bitbakepath = scriptpath.add_bitbake_lib_path() 75 bitbakepath = scriptpath.add_bitbake_lib_path()
73 if not bitbakepath: 76 if not bitbakepath:
diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py
index 4f968c6f21..3c7abfa8a7 100644
--- a/scripts/lib/devtool/deploy.py
+++ b/scripts/lib/devtool/deploy.py
@@ -14,6 +14,7 @@
14# You should have received a copy of the GNU General Public License along 14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc., 15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17"""Devtool plugin containing the deploy subcommands"""
17 18
18import os 19import os
19import subprocess 20import subprocess
@@ -23,10 +24,12 @@ from devtool import exec_build_env_command
23logger = logging.getLogger('devtool') 24logger = logging.getLogger('devtool')
24 25
25def plugin_init(pluginlist): 26def plugin_init(pluginlist):
27 """Plugin initialization"""
26 pass 28 pass
27 29
28 30
29def deploy(args, config, basepath, workspace): 31def deploy(args, config, basepath, workspace):
32 """Entry point for the devtool 'deploy' subcommand"""
30 import re 33 import re
31 34
32 if not args.recipename in workspace: 35 if not args.recipename in workspace:
@@ -87,7 +90,7 @@ def deploy(args, config, basepath, workspace):
87 return 0 90 return 0
88 91
89def undeploy(args, config, basepath, workspace): 92def undeploy(args, config, basepath, workspace):
90 93 """Entry point for the devtool 'undeploy' subcommand"""
91 deploy_file = os.path.join(basepath, 'target_deploy', args.target, args.recipename + '.list') 94 deploy_file = os.path.join(basepath, 'target_deploy', args.target, args.recipename + '.list')
92 if not os.path.exists(deploy_file): 95 if not os.path.exists(deploy_file):
93 logger.error('%s has not been deployed' % args.recipename) 96 logger.error('%s has not been deployed' % args.recipename)
@@ -122,6 +125,7 @@ def undeploy(args, config, basepath, workspace):
122 125
123 126
124def register_commands(subparsers, context): 127def register_commands(subparsers, context):
128 """Register devtool subcommands from the deploy plugin"""
125 parser_deploy = subparsers.add_parser('deploy-target', help='Deploy recipe output files to live target machine') 129 parser_deploy = subparsers.add_parser('deploy-target', help='Deploy recipe output files to live target machine')
126 parser_deploy.add_argument('recipename', help='Recipe to deploy') 130 parser_deploy.add_argument('recipename', help='Recipe to deploy')
127 parser_deploy.add_argument('target', help='Live target machine running an ssh server: user@hostname[:destdir]') 131 parser_deploy.add_argument('target', help='Live target machine running an ssh server: user@hostname[:destdir]')
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index a9dd3b2c2f..2f8b194c5f 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -14,6 +14,7 @@
14# You should have received a copy of the GNU General Public License along 14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc., 15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17"""Devtool standard plugins"""
17 18
18import os 19import os
19import sys 20import sys
@@ -28,10 +29,12 @@ from devtool import exec_build_env_command, setup_tinfoil
28logger = logging.getLogger('devtool') 29logger = logging.getLogger('devtool')
29 30
30def plugin_init(pluginlist): 31def plugin_init(pluginlist):
32 """Plugin initialization"""
31 pass 33 pass
32 34
33 35
34def add(args, config, basepath, workspace): 36def add(args, config, basepath, workspace):
37 """Entry point for the devtool 'add' subcommand"""
35 import bb 38 import bb
36 import oe.recipeutils 39 import oe.recipeutils
37 40
@@ -119,6 +122,7 @@ def add(args, config, basepath, workspace):
119 122
120 123
121def _check_compatible_recipe(pn, d): 124def _check_compatible_recipe(pn, d):
125 """Check if the recipe is supported by devtool"""
122 if pn == 'perf': 126 if pn == 'perf':
123 logger.error("The perf recipe does not actually check out source and thus cannot be supported by this tool") 127 logger.error("The perf recipe does not actually check out source and thus cannot be supported by this tool")
124 return False 128 return False
@@ -151,6 +155,7 @@ def _check_compatible_recipe(pn, d):
151 155
152 156
153def _get_recipe_file(cooker, pn): 157def _get_recipe_file(cooker, pn):
158 """Find recipe file corresponding a package name"""
154 import oe.recipeutils 159 import oe.recipeutils
155 recipefile = oe.recipeutils.pn_to_recipe(cooker, pn) 160 recipefile = oe.recipeutils.pn_to_recipe(cooker, pn)
156 if not recipefile: 161 if not recipefile:
@@ -187,6 +192,7 @@ def _ls_tree(directory):
187 192
188 193
189def extract(args, config, basepath, workspace): 194def extract(args, config, basepath, workspace):
195 """Entry point for the devtool 'extract' subcommand"""
190 import bb 196 import bb
191 197
192 tinfoil = setup_tinfoil() 198 tinfoil = setup_tinfoil()
@@ -204,10 +210,12 @@ def extract(args, config, basepath, workspace):
204 210
205 211
206def _extract_source(srctree, keep_temp, devbranch, d): 212def _extract_source(srctree, keep_temp, devbranch, d):
213 """Extract sources of a recipe"""
207 import bb.event 214 import bb.event
208 import oe.recipeutils 215 import oe.recipeutils
209 216
210 def eventfilter(name, handler, event, d): 217 def eventfilter(name, handler, event, d):
218 """Bitbake event filter for devtool extract operation"""
211 if name == 'base_eventhandler': 219 if name == 'base_eventhandler':
212 return True 220 return True
213 else: 221 else:
@@ -257,6 +265,7 @@ def _extract_source(srctree, keep_temp, devbranch, d):
257 # are to handle e.g. linux-yocto's extra tasks 265 # are to handle e.g. linux-yocto's extra tasks
258 executed = [] 266 executed = []
259 def exec_task_func(func, report): 267 def exec_task_func(func, report):
268 """Run specific bitbake task for a recipe"""
260 if not func in executed: 269 if not func in executed:
261 deps = crd.getVarFlag(func, 'deps') 270 deps = crd.getVarFlag(func, 'deps')
262 if deps: 271 if deps:
@@ -343,12 +352,15 @@ def _extract_source(srctree, keep_temp, devbranch, d):
343 return initial_rev 352 return initial_rev
344 353
345def _add_md5(config, recipename, filename): 354def _add_md5(config, recipename, filename):
355 """Record checksum of a recipe to the md5-file of the workspace"""
346 import bb.utils 356 import bb.utils
347 md5 = bb.utils.md5_file(filename) 357 md5 = bb.utils.md5_file(filename)
348 with open(os.path.join(config.workspace_path, '.devtool_md5'), 'a') as f: 358 with open(os.path.join(config.workspace_path, '.devtool_md5'), 'a') as f:
349 f.write('%s|%s|%s\n' % (recipename, os.path.relpath(filename, config.workspace_path), md5)) 359 f.write('%s|%s|%s\n' % (recipename, os.path.relpath(filename, config.workspace_path), md5))
350 360
351def _check_preserve(config, recipename): 361def _check_preserve(config, recipename):
362 """Check if a recipe was manually changed and needs to be saved in 'attic'
363 directory"""
352 import bb.utils 364 import bb.utils
353 origfile = os.path.join(config.workspace_path, '.devtool_md5') 365 origfile = os.path.join(config.workspace_path, '.devtool_md5')
354 newfile = os.path.join(config.workspace_path, '.devtool_md5_new') 366 newfile = os.path.join(config.workspace_path, '.devtool_md5_new')
@@ -382,6 +394,7 @@ def _check_preserve(config, recipename):
382 394
383 395
384def modify(args, config, basepath, workspace): 396def modify(args, config, basepath, workspace):
397 """Entry point for the devtool 'modify' subcommand"""
385 import bb 398 import bb
386 import oe.recipeutils 399 import oe.recipeutils
387 400
@@ -481,6 +494,7 @@ def modify(args, config, basepath, workspace):
481 494
482 495
483def update_recipe(args, config, basepath, workspace): 496def update_recipe(args, config, basepath, workspace):
497 """Entry point for the devtool 'update-recipe' subcommand"""
484 if not args.recipename in workspace: 498 if not args.recipename in workspace:
485 logger.error("no recipe named %s in your workspace" % args.recipename) 499 logger.error("no recipe named %s in your workspace" % args.recipename)
486 return -1 500 return -1
@@ -511,7 +525,7 @@ def update_recipe(args, config, basepath, workspace):
511 mode = args.mode 525 mode = args.mode
512 526
513 def remove_patches(srcuri, patchlist): 527 def remove_patches(srcuri, patchlist):
514 # Remove any patches that we don't need 528 """Remove patches"""
515 updated = False 529 updated = False
516 for patch in patchlist: 530 for patch in patchlist:
517 patchfile = os.path.basename(patch) 531 patchfile = os.path.basename(patch)
@@ -663,6 +677,7 @@ def update_recipe(args, config, basepath, workspace):
663 677
664 678
665def status(args, config, basepath, workspace): 679def status(args, config, basepath, workspace):
680 """Entry point for the devtool 'status' subcommand"""
666 if workspace: 681 if workspace:
667 for recipe, value in workspace.iteritems(): 682 for recipe, value in workspace.iteritems():
668 print("%s: %s" % (recipe, value)) 683 print("%s: %s" % (recipe, value))
@@ -672,6 +687,7 @@ def status(args, config, basepath, workspace):
672 687
673 688
674def reset(args, config, basepath, workspace): 689def reset(args, config, basepath, workspace):
690 """Entry point for the devtool 'reset' subcommand"""
675 import bb.utils 691 import bb.utils
676 if args.recipename: 692 if args.recipename:
677 if args.all: 693 if args.all:
@@ -713,6 +729,7 @@ def reset(args, config, basepath, workspace):
713 729
714 730
715def build(args, config, basepath, workspace): 731def build(args, config, basepath, workspace):
732 """Entry point for the devtool 'build' subcommand"""
716 import bb 733 import bb
717 if not args.recipename in workspace: 734 if not args.recipename in workspace:
718 logger.error("no recipe named %s in your workspace" % args.recipename) 735 logger.error("no recipe named %s in your workspace" % args.recipename)
@@ -724,6 +741,7 @@ def build(args, config, basepath, workspace):
724 741
725 742
726def register_commands(subparsers, context): 743def register_commands(subparsers, context):
744 """Register devtool subcommands from this plugin"""
727 parser_add = subparsers.add_parser('add', help='Add a new recipe', 745 parser_add = subparsers.add_parser('add', help='Add a new recipe',
728 description='Adds a new recipe') 746 description='Adds a new recipe')
729 parser_add.add_argument('recipename', help='Name for new recipe to add') 747 parser_add.add_argument('recipename', help='Name for new recipe to add')