|
|
@@ -18,7 +18,6 @@ class EventManager(object, with_metaclass(abc.ABCMeta)):
|
|
|
|
|
|
def __init__(self, event_handler):
|
|
|
self._event_handler = event_handler
|
|
|
- self._current_step = 0
|
|
|
self._total_steps = None
|
|
|
self._percentage_steps = {}
|
|
|
|
|
|
@@ -34,10 +33,10 @@ class EventManager(object, with_metaclass(abc.ABCMeta)):
|
|
|
max_value = 0
|
|
|
if max_value == 0:
|
|
|
LOG.warn("Max percentage value set to 0 (zero)")
|
|
|
- self._current_step += 1
|
|
|
- self._percentage_steps[self._current_step] = _PercStepData(
|
|
|
+ current_step = self._event_handler.get_task_progress_step() + 1
|
|
|
+ self._percentage_steps[current_step] = _PercStepData(
|
|
|
0, max_value, perc_threshold, message_format)
|
|
|
- return self._current_step
|
|
|
+ return current_step
|
|
|
|
|
|
def set_percentage_step(self, step, value):
|
|
|
step_data = self._percentage_steps[step]
|
|
|
@@ -51,17 +50,16 @@ class EventManager(object, with_metaclass(abc.ABCMeta)):
|
|
|
step_data.perc_threshold * step_data.perc_threshold)
|
|
|
|
|
|
if perc > old_perc and self._event_handler:
|
|
|
- self._event_handler.progress_update(
|
|
|
+ self._event_handler.update_task_progress_update(
|
|
|
step, self._total_steps, step_data.message_format.format(perc))
|
|
|
self._percentage_steps[step] = _PercStepData(
|
|
|
value, step_data.max_value, step_data.perc_threshold,
|
|
|
step_data.message_format)
|
|
|
|
|
|
def progress_update(self, message):
|
|
|
- self._current_step += 1
|
|
|
if self._event_handler:
|
|
|
- self._event_handler.progress_update(
|
|
|
- self._current_step, self._total_steps, message)
|
|
|
+ self._event_handler.add_task_progress_update(
|
|
|
+ self._total_steps, message)
|
|
|
|
|
|
def info(self, message):
|
|
|
if self._event_handler:
|
|
|
@@ -79,7 +77,11 @@ class EventManager(object, with_metaclass(abc.ABCMeta)):
|
|
|
class BaseEventHandler(object, with_metaclass(abc.ABCMeta)):
|
|
|
|
|
|
@abc.abstractmethod
|
|
|
- def progress_update(self, current_step, total_steps, message):
|
|
|
+ def add_task_progress_update(self, total_steps, message):
|
|
|
+ pass
|
|
|
+
|
|
|
+ @abc.abstractmethod
|
|
|
+ def update_task_progress_update(self, step, total_steps, message):
|
|
|
pass
|
|
|
|
|
|
@abc.abstractmethod
|