refs #1501 add ogListLogicalPartitions

pull/1/head
Natalia Serrano 2025-02-13 13:04:06 +01:00
parent 00da7454ec
commit 941ace29bb
3 changed files with 30 additions and 18 deletions

View File

@ -1087,7 +1087,7 @@ def ogListPartitions (disk):
SIZE = ogGetPartitionSize (disk, PART) or 0
p.append (f'{TYPE}:{SIZE}')
return ' '.join (p)
return p
#/**
@ -1126,24 +1126,14 @@ def ogListPrimaryPartitions(*args):
#@param int_ndisk nº de orden del disco
#@see ogListPartitions
#*/ ##
def ogListLogicalPartitions(*args):
# Variables locales
PTTYPE = None
PARTS = None
def ogListLogicalPartitions (disk):
PTTYPE = ogGetPartitionTableType (disk)
if not PTTYPE: return None
# Si se solicita, mostrar ayuda.
if len(args) == 1 and args[0] == "help":
SystemLib.ogHelp('ogListLogicalPartitions', 'ogListLogicalPartitions int_ndisk', 'ogListLogicalPartitions 1 => LINUX-SWAP:999998')
return
PARTS = ogListPartitions (disk)
if not PARTS: return None
PTTYPE = ogGetPartitionTableType(args[0])
if PTTYPE is None:
return
PARTS = ogListPartitions(*args)
if PARTS is None:
return
return PARTS.split(" ")[4:]
return PARTS[4:]
#/**

View File

@ -0,0 +1,22 @@
#!/usr/bin/python3
import sys
import argparse
from SystemLib import ogHelp
from DiskLib import ogListLogicalPartitions
parser = argparse.ArgumentParser (add_help=False)
parser.add_argument ('disk')
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
#parser.print_help() sale en inglés aunque la locale indique otra cosa
ogHelp ('ogListLogicalPartitions', 'ogListLogicalPartitions int_ndisk', ['ogListLogicalPartitions 1'])
sys.exit (0)
args = parser.parse_args()
ret = ogListLogicalPartitions (args.disk)
if ret is not None:
if ret == True: sys.exit (0)
elif ret == False: sys.exit (1)
else: print (' '.join (ret))

View File

@ -19,4 +19,4 @@ ret = ogListPartitions (args.disk)
if ret is not None:
if ret == True: sys.exit (0)
elif ret == False: sys.exit (1)
else: print (ret)
else: print (' '.join (ret))