From 782e5c8978f3a26bfd8c51d47d25ff8a42fdc8fc Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Wed, 9 Apr 2025 17:20:03 +0200 Subject: [PATCH] refs #1874 fix usage of ogEcho --- CHANGELOG.md | 6 ++++ ogclient/lib/python3/FileSystemLib.py | 47 +++++---------------------- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0f69ac..b5bd97b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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/), 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 ### Fixed diff --git a/ogclient/lib/python3/FileSystemLib.py b/ogclient/lib/python3/FileSystemLib.py index 987ec7e..d30684a 100644 --- a/ogclient/lib/python3/FileSystemLib.py +++ b/ogclient/lib/python3/FileSystemLib.py @@ -286,12 +286,7 @@ def ogGetFsSize (disk, par, unit='KB'): elif unit.upper() == "TB": factor = 1024 * 1024 * 1024 elif unit.upper() != "KB": - SystemLib.ogRaiseError ( - [], - ogGlobals.OG_ERR_FORMAT, - f"{unit} != {{ KB, MB, GB, TB }}" - ) - return + SystemLib.ogRaiseError ([], 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). mnt = ogMount (disk, par) @@ -331,11 +326,7 @@ def ogGetFsType(disk, part): try: subprocess.run(["zfs", "mount", PART]) except FileNotFoundError: - SystemLib.ogRaiseError ( - [], - ogGlobals.OG_ERR_NOTEXEC, - 'zfs' - ) + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTEXEC, 'zfs') return out = subprocess.run(["mount"], capture_output=True, text=True).stdout.splitlines() for line in out: @@ -344,11 +335,7 @@ def ogGetFsType(disk, part): break if not TYPE: - SystemLib.ogRaiseError ( - [], - ogGlobals.OG_ERR_NOTFOUND, - f'{disk} {part}' - ) + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'{disk} {part}') return # Componer valores correctos. @@ -592,11 +579,7 @@ def ogMountFs (disk, par): try: rc = subprocess.run(['mount', dev, mntdir, '-o', 'force,remove_hiberfile'], check=True).returncode except subprocess.CalledProcessError: - SystemLib.ogRaiseError ( - [], - ogGlobals.OG_ERR_PARTITION, - f"{disk}, {par}" - ) + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk}, {par}") return if 0 == rc: @@ -605,26 +588,18 @@ def ogMountFs (disk, par): try: subprocess.run (['ntfsfix', '-d', par], check=True) except subprocess.CalledProcessError: - SystemLib.ogRaiseError ( - [], - ogGlobals.OG_ERR_PARTITION, - f"{disk, par}" - ) + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk, par}") #return else: try: subprocess.run (['mount', par, mntdir, '-o', 'ro'], check=True) except subprocess.CalledProcessError: - SystemLib.ogRaiseError ( - [], - ogGlobals.OG_ERR_PARTITION, - f"{disk, par}" - ) + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f"{disk, par}") #return # Aviso de montaje de solo lectura. 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: # Montar sistema de archivos ZFS (un ZPOOL no comienza por "/"). subprocess.run(['zfs', 'mount', dev]) @@ -809,18 +784,14 @@ def ogUnmountFs(disk, par): if MNTDIR: # Error si la particion está bloqueada. if ogIsLocked (disk, par): - SystemLib.ogRaiseError ( - [], - ogGlobals.OG_ERR_LOCKED, - f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}" - ) + SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_LOCKED, f"{ogGlobals.lang.MSG_PARTITION}, {disk} {par}") return # Desmontar y borrar punto de montaje. try: subprocess.run(["umount", PART], check=True) 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: os.rmdir(MNTDIR) except: