forked from pool/python-rtslib-fb
- Update to version v2.2.2: * Explicitly set build target wheel packages * Fix the program name in pyproject.toml * Fix and update pre-commit ruf check * Add PyPA publish and pre-commit check workflows * Add rtslib_fb import compability * Silently ignore OSError on close * fixup! Fix various issues found by ruff linter rules * Add ruff rules, pre-commit config * Convert codebase to pathlib * Fix various issues found by ruff linter rules * Refactor code to Python>=3.9 to pass pyupgrade * Fix issues found by ruff pep8-naming rules * Fix issues found by ruff pycodestyle rules * Use f-strings * Fixing issues found by ruff Pyflakes rules * Move to PEP-621; Drop -fb from module name * rtslib: explicitely import "kmod.error" and "kmod.Kmod" * rtslib/LUN: add some ALUA property Also, updated the SPEC file, and removed patch no longer needed, since the problem is no longer present: * rtslib-Fix-handling-of-sysfs-RW-attrs-that-are-actually-RO.patch Added three commits, one from upstream, the others submitted there: * Install-targetctl-as-an-entrypoint.patch (added from upstream) * Remove-use-of-usr-bin-python.patch (submitted upstream) * Fix-issue-with-Path-open-needs-parenthesis.patch (submitted upstream) OBS-URL: https://build.opensuse.org/request/show/1255725 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-rtslib-fb?expand=0&rev=81
86 lines
3.3 KiB
Diff
86 lines
3.3 KiB
Diff
From e70542fec8f78d156cee101bc8680ddabbbbd7f6 Mon Sep 17 00:00:00 2001
|
|
From: Lee Duncan <lduncan@suse.com>
|
|
Date: Mon, 24 Mar 2025 11:21:59 -0700
|
|
Subject: [PATCH] Fix issue with Path(...).open: needs parenthesis
|
|
|
|
There are places where the code does this pattern:
|
|
|
|
with Path(some_path).open as f:
|
|
... (do stuff)
|
|
|
|
But that generates an error message like:
|
|
|
|
/> restoreconfig temp.json
|
|
Traceback (most recent call last):
|
|
File "/usr/bin/targetcli", line 8, in <module>
|
|
sys.exit(main())
|
|
~~~~^^
|
|
File "/usr/lib/python3.13/site-packages/targetcli/targetcli_shell.py", line 313, in main
|
|
shell.run_interactive()
|
|
~~~~~~~~~~~~~~~~~~~~~^^
|
|
File "/usr/lib/python3.13/site-packages/configshell/shell.py", line 899, in run_interactive
|
|
self._cli_loop()
|
|
~~~~~~~~~~~~~~^^
|
|
File "/usr/lib/python3.13/site-packages/configshell/shell.py", line 728, in _cli_loop
|
|
self.run_cmdline(cmdline)
|
|
~~~~~~~~~~~~~~~~^^^^^^^^^
|
|
File "/usr/lib/python3.13/site-packages/configshell/shell.py", line 842, in run_cmdline
|
|
self._execute_command(path, command, pparams, kparams)
|
|
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
File "/usr/lib/python3.13/site-packages/configshell/shell.py", line 817, in _execute_command
|
|
result = target.execute_command(command, pparams, kparams)
|
|
File "/usr/lib/python3.13/site-packages/configshell/node.py", line 1405, in execute_command
|
|
return method(*pparams, **kparams)
|
|
File "/usr/lib/python3.13/site-packages/targetcli/ui_root.py", line 207, in ui_command_restoreconfig
|
|
errors = self.rtsroot.restore_from_file(savefile, clear_existing,
|
|
target, storage_object)
|
|
File "/usr/lib/python3.13/site-packages/rtslib/root.py", line 490, in restore_from_file
|
|
with Path(restore_file).open as f:
|
|
^^^^^^^^^^^^^^^^^^^^^^^
|
|
TypeError: 'method' object does not support the context manager protocol
|
|
|
|
Adding empty parenthesis after the "open" fixes the issue.
|
|
---
|
|
rtslib/root.py | 4 ++--
|
|
scripts/convert-to-json | 2 +-
|
|
2 files changed, 3 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/rtslib/root.py b/rtslib/root.py
|
|
index 749a80620e65..b05d380a6c50 100644
|
|
--- a/rtslib/root.py
|
|
+++ b/rtslib/root.py
|
|
@@ -190,7 +190,7 @@ class RTSRoot(CFSNode):
|
|
current = self.dump()
|
|
|
|
try:
|
|
- with Path(save_file).open as f:
|
|
+ with Path(save_file).open() as f:
|
|
saveconf = json.loads(f.read())
|
|
except OSError as e:
|
|
if e.errno == errno.ENOENT:
|
|
@@ -487,7 +487,7 @@ class RTSRoot(CFSNode):
|
|
if not restore_file:
|
|
restore_file = default_save_file
|
|
|
|
- with Path(restore_file).open as f:
|
|
+ with Path(restore_file).open() as f:
|
|
config = json.loads(f.read())
|
|
return self.restore(config, target, storage_object,
|
|
clear_existing=clear_existing,
|
|
diff --git a/scripts/convert-to-json b/scripts/convert-to-json
|
|
index daa82daf705b..7677350f3040 100755
|
|
--- a/scripts/convert-to-json
|
|
+++ b/scripts/convert-to-json
|
|
@@ -318,7 +318,7 @@ def parse(txt, cur):
|
|
elif txt[cur] == "fabric":
|
|
cur = parse_fabric(txt, cur)
|
|
|
|
-with Path("/etc/target/scsi_target.lio").open as f:
|
|
+with Path("/etc/target/scsi_target.lio").open() as f:
|
|
txt = f.read()
|
|
txt = split(txt)
|
|
cur = parse(txt, 0)
|
|
--
|
|
2.43.0
|
|
|