Skip to content

Commit 8ae6b1c

Browse files
committed
pool
1 parent 0095f25 commit 8ae6b1c

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

src/stratis_cli/_actions/_list_pool.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
# isort: THIRDPARTY
3131
from justbytes import Range
3232

33+
# isort: FIRSTPARTY
34+
from dbus_client_gen import DbusClientMissingPropertyError
35+
3336
from .._alerts import (
3437
PoolAllocSpaceAlert,
3538
PoolDeviceSizeChangeAlert,
@@ -307,23 +310,36 @@ def size_triple(mopool: Any) -> SizeTriple:
307310
"""
308311
Calculate SizeTriple from size information.
309312
"""
310-
return SizeTriple(
311-
Range(mopool.TotalPhysicalSize()),
312-
get_property(mopool.TotalPhysicalUsed(), Range, None),
313-
)
313+
try:
314+
size = Range(mopool.TotalPhysicalSize())
315+
except DbusClientMissingPropertyError: # pragma: no cover
316+
size = None
317+
318+
try:
319+
used = get_property(mopool.TotalPhysicalUsed(), Range, None)
320+
except DbusClientMissingPropertyError: # pragma: no cover
321+
used = None
322+
323+
return SizeTriple(size, used)
314324

315325
def uuid_str(self, mopool: Any) -> str:
316326
"""
317327
Return a string representation of UUID, correctly formatted.
318328
"""
319-
return self.uuid_formatter(mopool.Uuid())
329+
try:
330+
return self.uuid_formatter(mopool.Uuid())
331+
except DbusClientMissingPropertyError: # pragma: no cover
332+
return TABLE_UNKNOWN_STRING
320333

321334
@staticmethod
322335
def name_str(mopool: Any) -> str:
323336
"""
324337
Return a string representation of the pool name.
325338
"""
326-
return mopool.Name()
339+
try:
340+
return mopool.Name()
341+
except DbusClientMissingPropertyError: # pragma: no cover
342+
return TABLE_UNKNOWN_STRING
327343

328344

329345
class DefaultDetail(Default): # pylint: disable=too-few-public-methods
@@ -425,13 +441,13 @@ def _print_detail_view(
425441

426442
size_triple = Default.size_triple(mopool)
427443

444+
def size_str(value: Range | None) -> str:
445+
return TABLE_UNKNOWN_STRING if value is None else str(value)
446+
428447
print(f"Fully Allocated: {'Yes' if mopool.NoAllocSpace() else 'No'}")
429-
print(f" Size: {size_triple.total()}")
448+
print(f" Size: {size_str(size_triple.total())}")
430449
print(f" Allocated: {Range(mopool.AllocatedSize())}")
431-
print(
432-
" Used: "
433-
f"{TABLE_UNKNOWN_STRING if size_triple.used() is None else size_triple.used()}"
434-
)
450+
print(f" Used: {size_str(size_triple.used())}")
435451

436452
def display(self):
437453
"""

0 commit comments

Comments
 (0)