refs #1874 fix usage of ogEcho

pull/21/head
Natalia Serrano 2025-04-09 17:20:03 +02:00
parent 0e979c46fa
commit 782e5c8978
2 changed files with 15 additions and 38 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.3.4] - 2025-04-09
### Fixed
- Fixed usage of ogEcho in FileSystemLib
## [0.3.3] - 2025-04-09 ## [0.3.3] - 2025-04-09
### Fixed ### Fixed

View File

@ -286,12 +286,7 @@ def ogGetFsSize (disk, par, unit='KB'):
elif unit.upper() == "TB": elif unit.upper() == "TB":
factor = 1024 * 1024 * 1024 factor = 1024 * 1024 * 1024
elif unit.upper() != "KB": elif unit.upper() != "KB":
SystemLib.ogRaiseError ( SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f"{unit} != {{ KB, MB, GB, TB }}") return
[],
ogGlobals.OG_ERR_FORMAT,
f"{unit} != {{ KB, MB, GB, TB }}"
)
return
# Obtener el tamaño del sistema de archivo (si no está formateado; tamaño = 0). # Obtener el tamaño del sistema de archivo (si no está formateado; tamaño = 0).
mnt = ogMount (disk, par) mnt = ogMount (disk, par)
@ -331,11 +326,7 @@ def ogGetFsType(disk, part):
try: try:
subprocess.run(["zfs", "mount", PART]) subprocess.run(["zfs", "mount", PART])
except FileNotFoundError: except FileNotFoundError:
SystemLib.ogRaiseError ( SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTEXEC, 'zfs')
[],
ogGlobals.OG_ERR_NOTEXEC,
'zfs'
)
return return
out = subprocess.run(["mount"], capture_output=True, text=True).stdout.splitlines() out = subprocess.run(["mount"], capture_output=True, text=True).stdout.splitlines()
for line in out: for line in out:
@ -344,11 +335,7 @@ def ogGetFsType(disk, part):
break break
if not TYPE: if not TYPE:
SystemLib.ogRaiseError ( SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'{disk} {part}')
[],
ogGlobals.OG_ERR_NOTFOUND,
f'{disk} {part}'
)
return return
# Componer valores correctos. # Componer valores correctos.
@ -592,11 +579,7 @@ def ogMountFs (disk, par):
try: try:
rc = subprocess.run(['mount', dev, mntdir, '-o', 'force,remove_hiberfile'], check=True).returncode rc = subprocess.run(['mount', dev, mntdir, '-o', 'force,remove_hiberfile'], check=True).returncode
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
SystemLib.ogRaiseError ( SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk}, {par}")
[],
ogGlobals.OG_ERR_PARTITION,
f"{disk}, {par}"
)
return return
if 0 == rc: if 0 == rc:
@ -605,26 +588,18 @@ def ogMountFs (disk, par):
try: try:
subprocess.run (['ntfsfix', '-d', par], check=True) subprocess.run (['ntfsfix', '-d', par], check=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
SystemLib.ogRaiseError ( SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk, par}")
[],
ogGlobals.OG_ERR_PARTITION,
f"{disk, par}"
)
#return #return
else: else:
try: try:
subprocess.run (['mount', par, mntdir, '-o', 'ro'], check=True) subprocess.run (['mount', par, mntdir, '-o', 'ro'], check=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
SystemLib.ogRaiseError ( SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk, par}")
[],
ogGlobals.OG_ERR_PARTITION,
f"{disk, par}"
)
#return #return
# Aviso de montaje de solo lectura. # Aviso de montaje de solo lectura.
if ogIsReadonly(disk, par): if ogIsReadonly(disk, par):
SystemLib.ogEcho("warning", f'ogMountFs: {ogGlobals.lang.MSG_MOUNTREADONLY}: "{disk}, {par}"') SystemLib.ogEcho ([], "warning", f'ogMountFs: {ogGlobals.lang.MSG_MOUNTREADONLY}: "{disk}, {par}"')
else: else:
# Montar sistema de archivos ZFS (un ZPOOL no comienza por "/"). # Montar sistema de archivos ZFS (un ZPOOL no comienza por "/").
subprocess.run(['zfs', 'mount', dev]) subprocess.run(['zfs', 'mount', dev])
@ -809,18 +784,14 @@ def ogUnmountFs(disk, par):
if MNTDIR: if MNTDIR:
# Error si la particion está bloqueada. # Error si la particion está bloqueada.
if ogIsLocked (disk, par): if ogIsLocked (disk, par):
SystemLib.ogRaiseError ( SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_LOCKED, f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}")
[],
ogGlobals.OG_ERR_LOCKED,
f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}"
)
return return
# Desmontar y borrar punto de montaje. # Desmontar y borrar punto de montaje.
try: try:
subprocess.run(["umount", PART], check=True) subprocess.run(["umount", PART], check=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
SystemLib.ogEcho("warning", f'ogUnmountFs: {ogGlobals.lang.MSG_DONTUNMOUNT}: "{disk}, {par}"') SystemLib.ogEcho ([], "warning", f'ogUnmountFs: {ogGlobals.lang.MSG_DONTUNMOUNT}: "{disk}, {par}"')
try: try:
os.rmdir(MNTDIR) os.rmdir(MNTDIR)
except: except: