refs #1500 add ogUnlockDisk

pull/1/head
Natalia Serrano 2025-02-12 11:27:01 +01:00
parent 8b11b4e08d
commit e12cc1150f
2 changed files with 26 additions and 24 deletions

View File

@ -1552,30 +1552,10 @@ def ogUnhidePartition(*args):
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
#@note El fichero de bloqueo se localiza en \c /var/lock/disk, siendo \c disk el dispositivo del disco, sustituyendo el carácter "/" por "-".
#*/ ##
def ogUnlockDisk(*args):
# Variables locales
DISK = None
LOCKFILE = None
# Si se solicita, mostrar ayuda.
if len(args) == 1 and args[0] == "help":
SystemLib.ogHelp('ogUnlockDisk', 'ogUnlockDisk int_ndisk', 'ogUnlockDisk 1')
return
# Error si no se recibe 1 parámetro.
if len(args) != 1:
SystemLib.ogRaiseError(OG_ERR_FORMAT)
return
# Obtener partición.
DISK = ogDiskToDev(args[0])
if DISK is None:
return
# Borrar archivo de bloqueo exclusivo.
LOCKFILE = f"/var/lock/lock{DISK.replace('/', '-')}"
os.remove(LOCKFILE)
return
def ogUnlockDisk (disk):
DISK = ogDiskToDev (disk)
if not DISK: return None
os.remove (f'/var/lock/lock{DISK.replace("/", "-")}')
#/**

View File

@ -0,0 +1,22 @@
#!/usr/bin/python3
import sys
import argparse
from SystemLib import ogHelp
from DiskLib import ogUnlockDisk
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 ('ogUnlockDisk', 'ogUnlockDisk int_ndisk', ['ogUnlockDisk 1'])
sys.exit (0)
args = parser.parse_args()
ret = ogUnlockDisk (args.disk)
if ret is not None:
if ret == True: sys.exit (0)
elif ret == False: sys.exit (1)
else: print (ret)