diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2015-05-11 16:17:01 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-16 22:31:50 +0100 |
commit | 7883af3097e043dd5b0f2c6f5f37189d9f70549e (patch) | |
tree | 449b76bfab9f172c2c55b8161f72f17b6b296abe /scripts | |
parent | c977cdf3d85da74ff4f5c9b10bf3caad7cb25204 (diff) | |
download | poky-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__.py | 5 | ||||
-rw-r--r-- | scripts/lib/devtool/deploy.py | 6 | ||||
-rw-r--r-- | scripts/lib/devtool/standard.py | 20 |
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 | ||
21 | import os | 21 | import os |
22 | import sys | 22 | import sys |
@@ -26,6 +26,7 @@ import logging | |||
26 | logger = logging.getLogger('devtool') | 26 | logger = logging.getLogger('devtool') |
27 | 27 | ||
28 | def exec_build_env_command(init_path, builddir, cmd, watch=False, **options): | 28 | def 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 | ||
51 | def exec_watch(cmd, **options): | 52 | def 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 | ||
70 | def setup_tinfoil(): | 72 | def 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 | ||
18 | import os | 19 | import os |
19 | import subprocess | 20 | import subprocess |
@@ -23,10 +24,12 @@ from devtool import exec_build_env_command | |||
23 | logger = logging.getLogger('devtool') | 24 | logger = logging.getLogger('devtool') |
24 | 25 | ||
25 | def plugin_init(pluginlist): | 26 | def plugin_init(pluginlist): |
27 | """Plugin initialization""" | ||
26 | pass | 28 | pass |
27 | 29 | ||
28 | 30 | ||
29 | def deploy(args, config, basepath, workspace): | 31 | def 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 | ||
89 | def undeploy(args, config, basepath, workspace): | 92 | def 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 | ||
124 | def register_commands(subparsers, context): | 127 | def 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 | ||
18 | import os | 19 | import os |
19 | import sys | 20 | import sys |
@@ -28,10 +29,12 @@ from devtool import exec_build_env_command, setup_tinfoil | |||
28 | logger = logging.getLogger('devtool') | 29 | logger = logging.getLogger('devtool') |
29 | 30 | ||
30 | def plugin_init(pluginlist): | 31 | def plugin_init(pluginlist): |
32 | """Plugin initialization""" | ||
31 | pass | 33 | pass |
32 | 34 | ||
33 | 35 | ||
34 | def add(args, config, basepath, workspace): | 36 | def 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 | ||
121 | def _check_compatible_recipe(pn, d): | 124 | def _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 | ||
153 | def _get_recipe_file(cooker, pn): | 157 | def _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 | ||
189 | def extract(args, config, basepath, workspace): | 194 | def 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 | ||
206 | def _extract_source(srctree, keep_temp, devbranch, d): | 212 | def _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 | ||
345 | def _add_md5(config, recipename, filename): | 354 | def _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 | ||
351 | def _check_preserve(config, recipename): | 361 | def _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 | ||
384 | def modify(args, config, basepath, workspace): | 396 | def 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 | ||
483 | def update_recipe(args, config, basepath, workspace): | 496 | def 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 | ||
665 | def status(args, config, basepath, workspace): | 679 | def 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 | ||
674 | def reset(args, config, basepath, workspace): | 689 | def 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 | ||
715 | def build(args, config, basepath, workspace): | 731 | def 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 | ||
726 | def register_commands(subparsers, context): | 743 | def 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') |