Use format method for messages in image_resize

There are more places where this cleanup from %x format
attributes to the format() method is required. Here it is
done in the scope of the image resize task
This commit is contained in:
Marcus Schäfer 2016-10-19 11:34:05 +02:00
parent de80a1f9b7
commit a3ce96ae78
No known key found for this signature in database
GPG Key ID: AD11DD02B44996EF
2 changed files with 13 additions and 9 deletions

View File

@ -94,24 +94,27 @@ class ImageResizeTask(CliTask):
)
if not image_format.has_raw_disk():
raise KiwiImageResizeError(
'no raw disk image %s found in build results' %
image_format.diskname
'no raw disk image {0} found in build results'.format(
image_format.diskname
)
)
new_disk_size = self._to_bytes(self.command_args['--size'])
log.info(
'Resizing raw disk to %d bytes', new_disk_size
'Resizing raw disk to {0} bytes'.format(new_disk_size)
)
resize_result = image_format.resize_raw_disk(new_disk_size)
if disk_format and resize_result is True:
log.info(
'Creating %s disk format from resized raw disk', disk_format
'Creating {0} disk format from resized raw disk'.format(
disk_format
)
)
image_format.create_image_format()
elif resize_result is False:
log.info(
'Raw disk is already at %d bytes', new_disk_size
'Raw disk is already at {0} bytes'.format(new_disk_size)
)
def _to_bytes(self, size_value):
@ -119,8 +122,9 @@ class ImageResizeTask(CliTask):
size = re.search(size_format, size_value)
if not size:
raise KiwiImageResizeError(
'unsupported size format %s, must match %s' %
(size_value, size_format)
'unsupported size format {0}, must match {1}'.format(
size_value, size_format
)
)
size_base = int(size.group(1))
size_unit = {'g': 3, 'm': 2}.get(size.group(2).lower())

View File

@ -106,8 +106,8 @@ class TestImageResizeTask(object):
call('--> loaded %s', '../data/root-dir/image/config.xml'),
call('--> Selected build type: %s', 'vmx'),
call('--> Selected profiles: %s', 'vmxFlavour'),
call('Resizing raw disk to %d bytes', 42),
call('Raw disk is already at %d bytes', 42)
call('Resizing raw disk to 42 bytes'),
call('Raw disk is already at 42 bytes')
]
def test_process_image_resize_help(self):