refs #1502 add ogListPrimaryPartitions
parent
941ace29bb
commit
79718100f6
|
@ -1096,28 +1096,22 @@ def ogListPartitions (disk):
|
|||
#@param int_ndisk nº de orden del disco
|
||||
#@see ogListPartitions
|
||||
#*/ ##
|
||||
def ogListPrimaryPartitions(*args):
|
||||
# Variables locales
|
||||
PTTYPE = None
|
||||
PARTS = None
|
||||
def ogListPrimaryPartitions (disk):
|
||||
PTTYPE = ogGetPartitionTableType (disk)
|
||||
if not PTTYPE: return None
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if len(args) == 1 and args[0] == "help":
|
||||
SystemLib.ogHelp('ogListPrimaryPartitions', 'ogListPrimaryPartitions int_ndisk', 'ogListPrimaryPartitions 1 => NTFS:10000000 EXT3:5000000 EXTENDED:1000000')
|
||||
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
|
||||
|
||||
if PTTYPE == "GPT":
|
||||
print(PARTS.rstrip(" EMPTY:0"))
|
||||
elif PTTYPE == "MSDOS":
|
||||
print(PARTS.split(" ")[0:4])
|
||||
return
|
||||
if 'GPT' == PTTYPE:
|
||||
res = []
|
||||
for idx in range (len(PARTS),0,-1):
|
||||
item = PARTS[idx-1]
|
||||
if 0==len(res) and 'EMPTY:0' == item: continue
|
||||
res.insert (0, item)
|
||||
return res
|
||||
elif 'MSDOS' == PTTYPE:
|
||||
return PARTS[0:4]
|
||||
|
||||
|
||||
#/**
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from DiskLib import ogListPrimaryPartitions
|
||||
|
||||
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 ('ogListPrimaryPartitions', 'ogListPrimaryPartitions int_ndisk', ['ogListPrimaryPartitions 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogListPrimaryPartitions (args.disk)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (' '.join (ret))
|
Loading…
Reference in New Issue