From 941ace29bb4c7015d1faf8eaf8bad0ebce420004 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Thu, 13 Feb 2025 13:04:06 +0100 Subject: [PATCH] refs #1501 add ogListLogicalPartitions --- client/lib/engine/bin/DiskLib.py | 24 ++++++------------- .../shared/functions/ogListLogicalPartitions | 22 +++++++++++++++++ client/shared/functions/ogListPartitions | 2 +- 3 files changed, 30 insertions(+), 18 deletions(-) create mode 100755 client/shared/functions/ogListLogicalPartitions diff --git a/client/lib/engine/bin/DiskLib.py b/client/lib/engine/bin/DiskLib.py index 3afd71c..617efc4 100755 --- a/client/lib/engine/bin/DiskLib.py +++ b/client/lib/engine/bin/DiskLib.py @@ -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:] #/** diff --git a/client/shared/functions/ogListLogicalPartitions b/client/shared/functions/ogListLogicalPartitions new file mode 100755 index 0000000..c79a006 --- /dev/null +++ b/client/shared/functions/ogListLogicalPartitions @@ -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)) diff --git a/client/shared/functions/ogListPartitions b/client/shared/functions/ogListPartitions index e507d73..ca0479b 100755 --- a/client/shared/functions/ogListPartitions +++ b/client/shared/functions/ogListPartitions @@ -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))