refs #1511 add ogHidePartition
parent
f7263381b9
commit
158c25f43e
|
@ -918,46 +918,21 @@ def ogGetPartitionType (disk, par):
|
||||||
#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo).
|
#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo).
|
||||||
#@exception OG_ERR_PARTITION tipo de partición no reconocido.
|
#@exception OG_ERR_PARTITION tipo de partición no reconocido.
|
||||||
#*/ ##
|
#*/ ##
|
||||||
def ogHidePartition(*args):
|
def ogHidePartition (disk, par):
|
||||||
# Variables locales
|
PART = ogDiskToDev (disk, par)
|
||||||
PART = None
|
if not PART: return None
|
||||||
TYPE = None
|
|
||||||
NEWTYPE = None
|
|
||||||
|
|
||||||
# Si se solicita, mostrar ayuda.
|
TYPE = ogGetPartitionType (disk, par)
|
||||||
if len(args) == 1 and args[0] == "help":
|
if 'NTFS' == TYPE: NEWTYPE = 'HNTFS'
|
||||||
SystemLib.ogHelp('ogHidePartition', 'ogHidePartition int_ndisk int_npartition', 'ogHidePartition 1 1')
|
elif 'FAT32' == TYPE: NEWTYPE = 'HFAT32'
|
||||||
return
|
elif 'FAT16' == TYPE: NEWTYPE = 'HFAT16'
|
||||||
|
elif 'FAT12' == TYPE: NEWTYPE = 'HFAT12'
|
||||||
# Error si no se reciben 2 parámetros.
|
elif 'WINDOWS' == TYPE: NEWTYPE = 'WIN-RESERV'
|
||||||
if len(args) != 2:
|
|
||||||
SystemLib.ogRaiseError(OG_ERR_FORMAT)
|
|
||||||
return
|
|
||||||
|
|
||||||
# Obtener el dispositivo de la partición.
|
|
||||||
PART = ogDiskToDev(args[0], args[1])
|
|
||||||
if PART is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Obtener tipo de partición.
|
|
||||||
TYPE = ogGetPartitionType(args[0], args[1])
|
|
||||||
if TYPE == "NTFS":
|
|
||||||
NEWTYPE = "HNTFS"
|
|
||||||
elif TYPE == "FAT32":
|
|
||||||
NEWTYPE = "HFAT32"
|
|
||||||
elif TYPE == "FAT16":
|
|
||||||
NEWTYPE = "HFAT16"
|
|
||||||
elif TYPE == "FAT12":
|
|
||||||
NEWTYPE = "HFAT12"
|
|
||||||
elif TYPE == "WINDOWS":
|
|
||||||
NEWTYPE = "WIN-RESERV"
|
|
||||||
else:
|
else:
|
||||||
SystemLib.ogRaiseError(OG_ERR_PARTITION, TYPE)
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, TYPE)
|
||||||
return
|
return None
|
||||||
|
|
||||||
# Cambiar tipo de partición.
|
ogSetPartitionType (disk, par, NEWTYPE)
|
||||||
ogSetPartitionType(args[0], args[1], NEWTYPE)
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
from SystemLib import ogHelp
|
||||||
|
from DiskLib import ogHidePartition
|
||||||
|
|
||||||
|
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 ('ogHidePartition', 'ogHidePartition int_ndisk int_npartition', ['ogHidePartition 1 1'])
|
||||||
|
sys.exit (0)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
ret = ogHidePartition (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