From e6937a211a993fd1612e6505fa4de89c4f95f937 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Thu, 20 Feb 2025 14:00:41 +0100 Subject: [PATCH] refs #1594 simplify a couple of lines --- client/lib/engine/bin/DiskLib.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/client/lib/engine/bin/DiskLib.py b/client/lib/engine/bin/DiskLib.py index 88e12da..a87fbc3 100755 --- a/client/lib/engine/bin/DiskLib.py +++ b/client/lib/engine/bin/DiskLib.py @@ -176,9 +176,7 @@ def ogCreatePartitions (disk, parts): ogCreatePartitionTable (ND) # Definir particiones y notificar al kernel. - print (f'about to run sfdisk: ({sfdisk_input})') p = subprocess.run (['sfdisk', DISK], input=sfdisk_input, capture_output=True, text=True) - print (f'rc ({p.returncode}) stdout ({p.stdout}) stderr ({p.stderr})') subprocess.run (['partprobe', DISK]) if CACHESIZE: CacheLib.ogMountCache() return True @@ -257,10 +255,11 @@ def ogCreateGptPartitions (disk, parts): SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, TYPE) return None # Comprobar tamaño numérico y convertir en sectores de 512 B. - SIZE = 2 * SIZE + SIZE *= 2 # SIZE debe ser múltiplo de ALIGN, si no gdisk lo mueve automáticamente. - DIV = SIZE // ALIGN - SIZE = DIV * ALIGN + SIZE = (SIZE // ALIGN) * ALIGN + + # Generar datos para la partición. # En el caso de que la partición sea EMPTY no se crea nada if 'EMPTY' != TYPE: OPTIONS += [f'-n{PART}:{START}:+{SIZE}', f'-t{PART}:{ID}'] @@ -276,14 +275,12 @@ def ogCreateGptPartitions (disk, parts): # Desmontar los sistemas de archivos del disco antes de realizar las operaciones. FileSystemLib.ogUnmountAll (ND) - if CACHESIZE: - CacheLib.ogUnmountCache() + if CACHESIZE: CacheLib.ogUnmountCache() # Si la tabla de particiones no es valida, volver a generarla. ogCreatePartitionTable (ND) # Definir particiones y notificar al kernel. - # Borramos primero las particiones y luego creamos las nuevas subprocess.run (['sgdisk'] + DELOPTIONS + OPTIONS + [DISK]) subprocess.run (['partprobe', DISK]) if CACHESIZE: CacheLib.ogMountCache()