projects
/
matthijs
/
projects
/
backupninja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
config: Restructure config loading to allow defaults.
[matthijs/projects/backupninja.git]
/
src
/
lib
/
backupninja
/
action.py
diff --git
a/src/lib/backupninja/action.py
b/src/lib/backupninja/action.py
index de36c4ba713fb7a5198d5abdc9d0792fdbfe6427..b4245f4c236b6a2961ecc6dc8932dd96f4956712 100644
(file)
--- a/
src/lib/backupninja/action.py
+++ b/
src/lib/backupninja/action.py
@@
-21,6
+21,7
@@
""" Running backup actions """
""" Running backup actions """
+import os
import logging as log
from backupninja import config
import logging as log
from backupninja import config
@@
-35,39
+36,39
@@
def run_all_actions(opts, global_config):
"""
log.info('Running all actions')
try:
"""
log.info('Running all actions')
try:
- actions = config.list_actions(opts)
+ action
_config
s = config.list_actions(opts)
except OSError, e:
log.critical('Unable to list actions: %s', e)
return
except OSError, e:
log.critical('Unable to list actions: %s', e)
return
- actions.sort()
+ action
_config
s.sort()
- for action
in action
s:
- run_action(action, opts, global_config)
+ for action
_config in action_config
s:
+ run_action(action
_config
, opts, global_config)
-def run_action(action, opts, global_config):
+def run_action(action
_config
, opts, global_config):
"""
"""
- Run a single action. opts are the parsed commandline options,
+ Run a single action. action_config is the full path to its
+ configuration file. opts are the parsed commandline options,
global_config is the parsed global configuration.
"""
global_config is the parsed global configuration.
"""
- log.info('Running action "%s"', action)
# Split the action filename
# Split the action filename
- parts =
action
.split('.')
+ parts =
os.path.basename(action_config)
.split('.')
if (len(parts) != 2):
if (len(parts) != 2):
- log.error('Invalid action filename: "%s". Should be in the form name.type, where type is a valid handler.' % action)
+ log.error('Invalid action filename: "%s". Should be in the form name.type, where type is a valid handler.' % action
_config
)
return
(action_name, action_ty) = parts
return
(action_name, action_ty) = parts
-
- # Get the config for this action
- action_config = config.get_action_config(opts, action)
+ log.info('Running action "%s.%s"', action_name, action_ty)
try:
# Create a handler for this action
try:
# Create a handler for this action
- handler = handlers.create_handler(action_ty, action_config)
+ handler = handlers.create_handler(action_ty)
+ # Let the handler load its configuration file
+ handler.load_config(action_config)
# Run it
handler.run(test=opts.test)
handler.finish(test=opts.test)
except Exception, e:
# Run it
handler.run(test=opts.test)
handler.finish(test=opts.test)
except Exception, e:
- log.error('Running action "%s
" failed: %s', action
, e)
+ log.error('Running action "%s
.%s" failed: %s', action_name, action_ty
, e)
import traceback
log.debug(traceback.format_exc())
import traceback
log.debug(traceback.format_exc())