X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fprojects%2Fbackupninja.git;a=blobdiff_plain;f=src%2Flib%2Fbackupninja%2Fhandlers%2F__init__.py;h=22f9589ee5c97636df2d0817236096c9f2d0aa54;hp=29dc75631823ed79d5ecda18b99698d6dcacb782;hb=HEAD;hpb=96f1913c89c0d934c9b75ff9fae2c0eda44e4823 diff --git a/src/lib/backupninja/handlers/__init__.py b/src/lib/backupninja/handlers/__init__.py index 29dc756..22f9589 100644 --- a/src/lib/backupninja/handlers/__init__.py +++ b/src/lib/backupninja/handlers/__init__.py @@ -47,7 +47,7 @@ class Action(object): which is a combination of a action type and a specific action configuration). """ - def __init__(self): + def __init__(self, logger): # Subclasses should overwrite this with their default config # See backupninja.config.load_config for the structure of this # value. @@ -55,6 +55,10 @@ class Action(object): # Assume we'll run succesfully. If anything fails in the # meanwhile, set this to True. self.failed = False + # A logger object for this action. In the future, this might + # become a specific logger, that includes the action name and + # type. + self.log = logger def run(self, **kwargs): """ @@ -103,10 +107,11 @@ class Action(object): except ConfigParser.NoOptionError: raise config.ConfigError("Option '%s' in section '%s' is mandatory, please configure it" % (option, section)) -def create_action(ty): +def create_action(ty, **kwargs): """ Create a new (subclass of) Action object for an action with the - given type. + given type. Any extra keyword arguments are passed to the + constructor. If the handler class for this type cannot be loaded, an exception is thrown. @@ -133,7 +138,7 @@ def create_action(ty): % (module.__file__)) # Call the "handler" function to create the actual action - action = module.handler() + action = module.handler(**kwargs) # Check if the handler returned is really a subclass of Action if not isinstance(action, Action):