From: David Lehman dlehman@redhat.com
--- blivet/actionlist.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/blivet/actionlist.py b/blivet/actionlist.py index 224bb58..db9f586 100644 --- a/blivet/actionlist.py +++ b/blivet/actionlist.py @@ -21,6 +21,7 @@ #
import copy +from functools import wraps
from .deviceaction import ActionCreateDevice from .deviceaction import action_type_from_string, action_object_from_string @@ -35,6 +36,21 @@ log = logging.getLogger("blivet")
+def with_flag(flag_attr): + def run_func_with_flag_attr_set(func): + @wraps(func) + def wrapped_func(*args, **kwargs): + setattr(args[0], flag_attr, True) + try: + return func(*args, **kwargs) + finally: + setattr(args[0], flag_attr, False) + + return wrapped_func + + return run_func_with_flag_attr_set + + class ActionList(object, metaclass=SynchronizedMeta): _unsynchronized_methods = ['process']
@@ -43,6 +59,7 @@ def __init__(self, addfunc=None, removefunc=None): self._remove_func = removefunc self._actions = [] self._completed_actions = [] + self.processing = False
def __iter__(self): return iter(self._actions) @@ -278,6 +295,7 @@ def _find_active_devices_on_action_disks(self, devices=None): devices = [a.name for a in active if any(d in disks for d in a.disks)] return devices
+ @with_flag("processing") def process(self, callbacks=None, devices=None, dry_run=None): """ Execute all registered actions.
anaconda-patches@lists.fedorahosted.org