summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/partition.py
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-02-14 22:21:38 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-04 23:18:17 +0000
commitf5ae79da406190bf27194d7cecf15926bbb6ef20 (patch)
tree8f745825923833393a896c3a084e42cd3f184528 /scripts/lib/wic/partition.py
parent3d47a212a627af50c78099eaf7308a6d38aaf1b3 (diff)
downloadpoky-f5ae79da406190bf27194d7cecf15926bbb6ef20.tar.gz
wic: raise WicError in core modules
Replaced sys.exit with raising WicError in the core wic modules. (From OE-Core rev: 1b11437fb25ece5b3eede52344b071e875fa738f) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/partition.py')
-rw-r--r--scripts/lib/wic/partition.py46
1 files changed, 21 insertions, 25 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index a68dc6fd6d..e100377933 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -26,9 +26,9 @@
26 26
27import logging 27import logging
28import os 28import os
29import sys
30import tempfile 29import tempfile
31 30
31from wic.errors import WicError
32from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var 32from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var
33from wic.plugin import pluginmgr 33from wic.plugin import pluginmgr
34 34
@@ -99,9 +99,9 @@ class Partition():
99 if self.fixed_size: 99 if self.fixed_size:
100 rootfs_size = self.fixed_size 100 rootfs_size = self.fixed_size
101 if actual_rootfs_size > rootfs_size: 101 if actual_rootfs_size > rootfs_size:
102 logger.error("Actual rootfs size (%d kB) is larger than allowed size %d kB", 102 raise WicError("Actual rootfs size (%d kB) is larger than "
103 actual_rootfs_size, rootfs_size) 103 "allowed size %d kB" %
104 sys.exit(1) 104 (actual_rootfs_size, rootfs_size))
105 else: 105 else:
106 extra_blocks = self.get_extra_block_count(actual_rootfs_size) 106 extra_blocks = self.get_extra_block_count(actual_rootfs_size)
107 if extra_blocks < self.extra_space: 107 if extra_blocks < self.extra_space:
@@ -132,10 +132,10 @@ class Partition():
132 """ 132 """
133 if not self.source: 133 if not self.source:
134 if not self.size and not self.fixed_size: 134 if not self.size and not self.fixed_size:
135 logger.error("The %s partition has a size of zero. Please " 135 raise WicError("The %s partition has a size of zero. Please "
136 "specify a non-zero --size/--fixed-size for that " 136 "specify a non-zero --size/--fixed-size for that "
137 "partition.", self.mountpoint) 137 "partition." % self.mountpoint)
138 sys.exit(1) 138
139 if self.fstype and self.fstype == "swap": 139 if self.fstype and self.fstype == "swap":
140 self.prepare_swap_partition(cr_workdir, oe_builddir, 140 self.prepare_swap_partition(cr_workdir, oe_builddir,
141 native_sysroot) 141 native_sysroot)
@@ -157,12 +157,11 @@ class Partition():
157 plugins = pluginmgr.get_source_plugins() 157 plugins = pluginmgr.get_source_plugins()
158 158
159 if self.source not in plugins: 159 if self.source not in plugins:
160 logger.error("The '%s' --source specified for %s doesn't exist.\n\t" 160 raise WicError("The '%s' --source specified for %s doesn't exist.\n\t"
161 "See 'wic list source-plugins' for a list of available" 161 "See 'wic list source-plugins' for a list of available"
162 " --sources.\n\tSee 'wic help source-plugins' for " 162 " --sources.\n\tSee 'wic help source-plugins' for "
163 "details on adding a new source plugin.", 163 "details on adding a new source plugin." %
164 self.source, self.mountpoint) 164 (self.source, self.mountpoint))
165 sys.exit(1)
166 165
167 srcparams_dict = {} 166 srcparams_dict = {}
168 if self.sourceparams: 167 if self.sourceparams:
@@ -192,16 +191,14 @@ class Partition():
192 # further processing required Partition.size to be an integer, make 191 # further processing required Partition.size to be an integer, make
193 # sure that it is one 192 # sure that it is one
194 if not isinstance(self.size, int): 193 if not isinstance(self.size, int):
195 logger.error("Partition %s internal size is not an integer. " 194 raise WicError("Partition %s internal size is not an integer. "
196 "This a bug in source plugin %s and needs to be fixed.", 195 "This a bug in source plugin %s and needs to be fixed." %
197 self.mountpoint, self.source) 196 (self.mountpoint, self.source))
198 sys.exit(1)
199 197
200 if self.fixed_size and self.size > self.fixed_size: 198 if self.fixed_size and self.size > self.fixed_size:
201 logger.error("File system image of partition %s is larger (%d kB) " 199 raise WicError("File system image of partition %s is "
202 "than its allowed size %d kB", 200 "larger (%d kB) than its allowed size %d kB" %
203 self.mountpoint, self.size, self.fixed_size) 201 (self.mountpoint, self.size, self.fixed_size))
204 sys.exit(1)
205 202
206 def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir, 203 def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir,
207 rootfs_dir): 204 rootfs_dir):
@@ -241,9 +238,8 @@ class Partition():
241 os.remove(rootfs) 238 os.remove(rootfs)
242 239
243 if not self.fstype: 240 if not self.fstype:
244 logger.error("File system for partition %s not specified in kickstart, " 241 raise WicError("File system for partition %s not specified in "
245 "use --fstype option", self.mountpoint) 242 "kickstart, use --fstype option" % self.mountpoint)
246 sys.exit(1)
247 243
248 # Get rootfs size from bitbake variable if it's not set in .ks file 244 # Get rootfs size from bitbake variable if it's not set in .ks file
249 if not self.size: 245 if not self.size: