diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-06-13 14:22:01 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-14 10:18:29 +0100 |
commit | 0165f40cbbed9ed1f941590b0aeef3f25fadb60c (patch) | |
tree | f8af9fe9db5736fa33268054b68225d1a2e2ee48 /scripts/lib | |
parent | ecefd3c55be30a4e77c7bc8a08e2828f47ce46da (diff) | |
download | poky-0165f40cbbed9ed1f941590b0aeef3f25fadb60c.tar.gz |
wic: add Disk._prop helper
Added generic helper to use in property methods to
access commands in a lazy manner.
(From OE-Core rev: 4c1ded3ddbd04ad1640620ec1348831692a93dbe)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/wic/engine.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index f8f2844cf6..e3701c442e 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py | |||
@@ -267,13 +267,18 @@ class Disk: | |||
267 | 267 | ||
268 | return self._partitions | 268 | return self._partitions |
269 | 269 | ||
270 | def _prop(self, name): | ||
271 | """Get path to the executable in a lazy way.""" | ||
272 | aname = "_%s" % name | ||
273 | if getattr(self, aname) is None: | ||
274 | setattr(self, aname, find_executable(name, self.paths)) | ||
275 | if not getattr(self, aname): | ||
276 | raise WicError("Can't find executable {}".format(name)) | ||
277 | return getattr(self, aname) | ||
278 | |||
270 | @property | 279 | @property |
271 | def mdir(self): | 280 | def mdir(self): |
272 | if self._mdir is None: | 281 | return self._prop('mdir') |
273 | self._mdir = find_executable("mdir", self.paths) | ||
274 | if not self._mdir: | ||
275 | raise WicError("Can't find executable mdir") | ||
276 | return self._mdir | ||
277 | 282 | ||
278 | def _get_part_image(self, pnum): | 283 | def _get_part_image(self, pnum): |
279 | if pnum not in self.partitions: | 284 | if pnum not in self.partitions: |