refs #1500 add ogUnlockDisk
parent
8b11b4e08d
commit
e12cc1150f
|
@ -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("/", "-")}')
|
||||
|
||||
|
||||
#/**
|
||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue