2022-09-07 11:49:42 +00:00
|
|
|
from ops.const import StrategyChoice
|
|
|
|
from .push import PushExecutionManager, PushHandler
|
|
|
|
from .verify import VerifyExecutionManager, VerifyHandler
|
|
|
|
from .collect import CollectExecutionManager, CollectHandler
|
|
|
|
from .change_auth import ChangeAuthExecutionManager, ChangeAuthHandler
|
|
|
|
|
|
|
|
|
|
|
|
class ExecutionManager:
|
|
|
|
manager_type = {
|
|
|
|
StrategyChoice.push: PushExecutionManager,
|
|
|
|
StrategyChoice.verify: VerifyExecutionManager,
|
|
|
|
StrategyChoice.collect: CollectExecutionManager,
|
2022-09-14 07:51:04 +00:00
|
|
|
StrategyChoice.change_password: ChangeAuthExecutionManager,
|
2022-09-07 11:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def __new__(cls, execution):
|
|
|
|
manager = cls.manager_type[execution.manager_type]
|
|
|
|
return manager(execution)
|
|
|
|
|
|
|
|
|
|
|
|
class TaskHandler:
|
|
|
|
handler_type = {
|
|
|
|
StrategyChoice.push: PushHandler,
|
|
|
|
StrategyChoice.verify: VerifyHandler,
|
|
|
|
StrategyChoice.collect: CollectHandler,
|
2022-09-14 07:51:04 +00:00
|
|
|
StrategyChoice.change_password: ChangeAuthHandler,
|
2022-09-07 11:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def __new__(cls, task, show_step_info):
|
|
|
|
handler = cls.handler_type[task.handler_type]
|
|
|
|
return handler(task, show_step_info)
|