refs #1503 add ogGetPartitionType
parent
1fdbdd637c
commit
5cc3176d74
|
@ -916,28 +916,12 @@ def ogGetPartitionTableType (disk):
|
||||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||||
#*/ ##
|
#*/ ##
|
||||||
def ogGetPartitionType(*args):
|
def ogGetPartitionType (disk, par):
|
||||||
# Variables locales
|
ID = ogGetPartitionId (disk, par)
|
||||||
ID = None
|
if ID is None: return None
|
||||||
TYPE = None
|
print (f'got ID ({ID})')
|
||||||
|
|
||||||
# Si se solicita, mostrar ayuda.
|
return ogIdToType (ID)
|
||||||
if len(args) == 1 and args[0] == "help":
|
|
||||||
SystemLib.ogHelp('ogGetPartitionType', 'ogGetPartitionType int_ndisk int_npartition', 'ogGetPartitionType 1 1 => NTFS')
|
|
||||||
return
|
|
||||||
|
|
||||||
# Error si no se reciben 2 parámetros.
|
|
||||||
if len(args) != 2:
|
|
||||||
SystemLib.ogRaiseError(OG_ERR_FORMAT)
|
|
||||||
return
|
|
||||||
|
|
||||||
# Detectar id. de tipo de partición y codificar al mnemónico.
|
|
||||||
ID = ogGetPartitionId(args[0], args[1])
|
|
||||||
if ID is None:
|
|
||||||
return
|
|
||||||
TYPE = ogIdToType(ID)
|
|
||||||
print(TYPE)
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
|
@ -1001,7 +985,7 @@ def ogHidePartition(*args):
|
||||||
#*/ ##
|
#*/ ##
|
||||||
def ogIdToType (ID):
|
def ogIdToType (ID):
|
||||||
# Obtener valor hexadecimal de 4 caracteres rellenado con 0 por delante.
|
# Obtener valor hexadecimal de 4 caracteres rellenado con 0 por delante.
|
||||||
ID = ID.zfill(4)
|
ID = ID.zfill(4).lower()
|
||||||
|
|
||||||
id2type = {
|
id2type = {
|
||||||
'0000': 'EMPTY',
|
'0000': 'EMPTY',
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
from SystemLib import ogHelp
|
||||||
|
from DiskLib import ogGetPartitionType
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser (add_help=False)
|
||||||
|
parser.add_argument ('disk')
|
||||||
|
parser.add_argument ('par')
|
||||||
|
|
||||||
|
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||||
|
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||||
|
ogHelp ('ogGetPartitionType', 'ogGetPartitionType int_ndisk int_nfilesys', ['ogGetPartitionType 1 1'])
|
||||||
|
sys.exit (0)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
ret = ogGetPartitionType (args.disk, args.par)
|
||||||
|
|
||||||
|
if ret is not None:
|
||||||
|
if ret == True: sys.exit (0)
|
||||||
|
elif ret == False: sys.exit (1)
|
||||||
|
else: print (ret)
|
Loading…
Reference in New Issue