diff --git a/client/lib/engine/bin/DiskLib.py b/client/lib/engine/bin/DiskLib.py index eefbfac..9493ac4 100755 --- a/client/lib/engine/bin/DiskLib.py +++ b/client/lib/engine/bin/DiskLib.py @@ -918,46 +918,21 @@ def ogGetPartitionType (disk, par): #@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo). #@exception OG_ERR_PARTITION tipo de partición no reconocido. #*/ ## -def ogHidePartition(*args): - # Variables locales - PART = None - TYPE = None - NEWTYPE = None +def ogHidePartition (disk, par): + PART = ogDiskToDev (disk, par) + if not PART: return None - # Si se solicita, mostrar ayuda. - if len(args) == 1 and args[0] == "help": - SystemLib.ogHelp('ogHidePartition', 'ogHidePartition int_ndisk int_npartition', 'ogHidePartition 1 1') - return - - # Error si no se reciben 2 parámetros. - 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" + TYPE = ogGetPartitionType (disk, par) + if 'NTFS' == TYPE: NEWTYPE = 'HNTFS' + elif 'FAT32' == TYPE: NEWTYPE = 'HFAT32' + elif 'FAT16' == TYPE: NEWTYPE = 'HFAT16' + elif 'FAT12' == TYPE: NEWTYPE = 'HFAT12' + elif 'WINDOWS' == TYPE: NEWTYPE = 'WIN-RESERV' else: - SystemLib.ogRaiseError(OG_ERR_PARTITION, TYPE) - return + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, TYPE) + return None - # Cambiar tipo de partición. - ogSetPartitionType(args[0], args[1], NEWTYPE) - return + ogSetPartitionType (disk, par, NEWTYPE) #/** diff --git a/client/shared/functions/ogHidePartition b/client/shared/functions/ogHidePartition new file mode 100755 index 0000000..2a97ce1 --- /dev/null +++ b/client/shared/functions/ogHidePartition @@ -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)