refs #1495 add ogIsDiskLocked
parent
cdb0128cd8
commit
375a3a8ad0
|
@ -1090,26 +1090,10 @@ def ogIdToType(ID):
|
|||
#@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error.
|
||||
#@note Los ficheros de bloqueo se localizan en \c /var/lock/dev, siendo \c dev el dispositivo de la partición o de su disco, sustituyendo el carácter "/" por "-".
|
||||
#*/ ##
|
||||
def ogIsDiskLocked(*args):
|
||||
# Variables locales
|
||||
DISK = None
|
||||
LOCKFILE = None
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if len(args) == 1 and args[0] == "help":
|
||||
SystemLib.ogHelp('ogIsDiskLocked', 'ogIsDiskLocked int_ndisk', 'if ogIsDiskLocked(1): ...')
|
||||
return
|
||||
|
||||
# Falso, en caso de error.
|
||||
if len(args) != 1:
|
||||
return False
|
||||
DISK = ogDiskToDev(args[0], 2)
|
||||
if DISK is None:
|
||||
return False
|
||||
|
||||
# Comprobar existencia de fichero de bloqueo para el disco.
|
||||
LOCKFILE = f"/var/lock/lock{DISK.replace('/', '-')}"
|
||||
return os.path.isfile(LOCKFILE)
|
||||
def ogIsDiskLocked (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return False
|
||||
return os.path.isfile (f'/var/lock/lock{DISK.replace('/', '-')}')
|
||||
|
||||
|
||||
#/**
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from DiskLib import ogIsDiskLocked
|
||||
|
||||
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 ('ogIsDiskLocked', 'ogIsDiskLocked int_ndisk', ['ogIsDiskLocked 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogIsDiskLocked (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