From 4c634d3f9a93a3bd07aed0be7972884cf0955c07 Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 14 Jan 2008 20:46:42 +0000 Subject: [PATCH] remember if lvm is not installed --- src/cryptobox/core/blockdevice.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/cryptobox/core/blockdevice.py b/src/cryptobox/core/blockdevice.py index dccb7b0..13abc4e 100644 --- a/src/cryptobox/core/blockdevice.py +++ b/src/cryptobox/core/blockdevice.py @@ -34,6 +34,12 @@ import time import logging import cryptobox.core.settings +OPTIONAL_PROGS = { "lvm": True } +"""remember which programs don't exist to avoid calling them in vain + +change default values from "True" to "False" to disable the respective program +""" + LOGGER = logging.getLogger("CryptoBox") DEFAULT_SYSBLOCK_DIR = '/sys/block' @@ -510,6 +516,9 @@ class Blockdevice: def __get_uuid_lvm_pv(self): """determine the unique identifier of physical LVM volumes """ + if not OPTIONAL_PROGS["lvm"]: + ## pvdisplay is not installed - skip it + return None prefs = _load_preferences() try: proc = subprocess.Popen( @@ -524,6 +533,11 @@ class Blockdevice: LOGGER.warning("Failed to call '%s' via 'super' to determine " \ % prefs["Programs"]["pvdisplay"] + "UUID: %s" % err_msg) return None + if proc.returncode == 101: + ## pvdisplay is not installed + OPTIONAL_PROGS["lvm"] = False + LOGGER.warning("'lvm' is not installed - I will not try it again") + return None if proc.returncode != 0: LOGGER.warning("Execution of 'pvdisplay' failed: %s" % error) return None @@ -837,6 +851,8 @@ def find_blockdevices(top_dir): def find_lvm_pv(): """return the blockdevice names of all physical LVM volumes """ + if not OPTIONAL_PROGS["lvm"]: + return [] cache_link = ["lvm", "pv"] cached = CACHE.get(cache_link) if not cached is None: @@ -856,6 +872,11 @@ def find_lvm_pv(): except OSError, err_msg: LOGGER.info("Failed to call 'pvdisplay' via 'super': %s" % err_msg) result = [] + if proc.returncode == 101: + ## pvdisplay is not installed + OPTIONAL_PROGS["lvm"] = False + LOGGER.warning("'lvm' is not installed - I will not try it again") + return [] if proc.returncode != 0: LOGGER.info("Execution of 'pvdisplay' failed: %s" % error.strip()) result = []