curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #02303
Re: [Merge] ~dbungert/curtin:ntfs into curtin:master
Review: Approve
Diff comments:
> diff --git a/tests/integration/test_block_meta.py b/tests/integration/test_block_meta.py
> index be69bc0..76a974b 100644
> --- a/tests/integration/test_block_meta.py
> +++ b/tests/integration/test_block_meta.py
> @@ -49,6 +49,37 @@ def _get_filesystem_size(dev, part_action, fstype='ext4'):
> return int(block_count) * int(block_size)
>
>
> +def _get_ntfs_size(dev, part_action):
> + num = part_action['number']
> + cmd = ['ntfsresize',
> + '--no-action',
> + '--force', # needed post-resize, which otherwise demands a CHKDSK
> + '--info', f'{dev}p{num}']
> + out = util.subp(cmd, capture=True)[0]
> + # Sample input:
> + # Current volume size: 41939456 bytes (42 MB)
> + volsize_matcher = re.compile(r'^Current volume size: ([0-9]+) bytes')
Completely up to you but you can use a "one-liner" using re.MULTILINE in combination with re.search:
m = re.search(r"^Current volume size: ([0-9]+) bytes", out, re.MULTILINE)
if m is None:
raise Exception("ntfs volume size not found")
return int(m.group(1))
> + for line in out.splitlines():
> + m = volsize_matcher.match(line)
> + if m:
> + return int(m.group(1))
> + raise Exception('ntfs volume size not found')
> +
> +
> +_get_fs_sizers = {
> + 'ext2': _get_ext_size,
> + 'ext3': _get_ext_size,
> + 'ext4': _get_ext_size,
> + 'ntfs': _get_ntfs_size,
> +}
> +
> +
> +def _get_filesystem_size(dev, part_action, fstype='ext4'):
> + if fstype not in _get_fs_sizers.keys():
> + raise Exception(f'_get_filesystem_size: no support for {fstype}')
> + return _get_fs_sizers[fstype](dev, part_action)
> +
> +
> def _get_extended_partition_size(dev, num):
> # sysfs reports extended partitions as having 1K size
> # sfdisk seems to have a better idea
--
https://code.launchpad.net/~dbungert/curtin/+git/curtin/+merge/420513
Your team curtin developers is subscribed to branch curtin:master.
References