mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
storage: yapf changes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
8b96ea0698
commit
c3a3d80ea5
@ -78,15 +78,18 @@ def subcommand_expand_partition(arguments):
|
|||||||
|
|
||||||
def _resize_partition(device, requested_partition, free_space):
|
def _resize_partition(device, requested_partition, free_space):
|
||||||
"""Resize the partition table entry."""
|
"""Resize the partition table entry."""
|
||||||
command = ['parted', '--align=optimal', '--script', device, 'unit', 'B',
|
command = [
|
||||||
'resizepart', requested_partition['number'],
|
'parted', '--align=optimal', '--script', device, 'unit', 'B',
|
||||||
str(free_space['end'])]
|
'resizepart', requested_partition['number'],
|
||||||
|
str(free_space['end'])
|
||||||
|
]
|
||||||
# XXX: Remove workaround after bug in parted is fixed:
|
# XXX: Remove workaround after bug in parted is fixed:
|
||||||
# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24215
|
# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24215
|
||||||
fallback_command = ['parted', '--align=optimal', device,
|
fallback_command = [
|
||||||
'---pretend-input-tty', 'unit', 'B', 'resizepart',
|
'parted', '--align=optimal', device, '---pretend-input-tty', 'unit',
|
||||||
requested_partition['number'], 'yes',
|
'B', 'resizepart', requested_partition['number'], 'yes',
|
||||||
str(free_space['end'])]
|
str(free_space['end'])
|
||||||
|
]
|
||||||
try:
|
try:
|
||||||
subprocess.run(command, check=True)
|
subprocess.run(command, check=True)
|
||||||
except subprocess.CalledProcessError as exception:
|
except subprocess.CalledProcessError as exception:
|
||||||
@ -107,8 +110,8 @@ def _resize_file_system(device, requested_partition, free_space):
|
|||||||
|
|
||||||
def _resize_ext4(device, requested_partition, free_space):
|
def _resize_ext4(device, requested_partition, free_space):
|
||||||
"""Resize an ext4 file system inside a partition."""
|
"""Resize an ext4 file system inside a partition."""
|
||||||
partition_device = _get_partition_device(
|
partition_device = _get_partition_device(device,
|
||||||
device, requested_partition['number'])
|
requested_partition['number'])
|
||||||
try:
|
try:
|
||||||
command = ['resize2fs', partition_device]
|
command = ['resize2fs', partition_device]
|
||||||
subprocess.run(command, stdout=subprocess.DEVNULL,
|
subprocess.run(command, stdout=subprocess.DEVNULL,
|
||||||
@ -191,8 +194,9 @@ def _get_root_device_and_partition_number(device):
|
|||||||
|
|
||||||
def _get_partitions_and_free_spaces(device, partition_number):
|
def _get_partitions_and_free_spaces(device, partition_number):
|
||||||
"""Run parted and return list of partitions and free spaces."""
|
"""Run parted and return list of partitions and free spaces."""
|
||||||
command = ['parted', '--machine', '--script', device, 'unit', 'B',
|
command = [
|
||||||
'print', 'free']
|
'parted', '--machine', '--script', device, 'unit', 'B', 'print', 'free'
|
||||||
|
]
|
||||||
process = subprocess.run(command, stdout=subprocess.PIPE, check=True)
|
process = subprocess.run(command, stdout=subprocess.PIPE, check=True)
|
||||||
|
|
||||||
requested_partition = None
|
requested_partition = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user