[omd-commits] OMD Git: omd: omd: Improved exception handling during omd update/cp/mv ( Asking for retry/accept/abort now)
git version control
git at mathias-kettner.de
Tue Jun 5 10:50:21 CEST 2012
Module: omd
Branch: master
Commit: d7bae6f66b48afef023976d8e13066f659cf30a5
URL: http://omdistro.org/projects/omd/repository/revisions/d7bae6f66b48afef023976d8e13066f659cf30a5
Author: Lars Michelsen <lm at mathias-kettner.de>
Date: Tue Jun 5 10:49:51 2012 +0200
Commiter: Lars Michelsen <lm at mathias-kettner.de>
Date: Tue Jun 5 10:49:51 2012 +0200
omd: Improved exception handling during omd update/cp/mv (Asking for retry/accept/abort now)
---
Changelog | 2 ++
packages/omd/omd | 39 ++++++++++++++++++++++++++++++---------
2 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/Changelog b/Changelog
index 65c7899..5e9dec6 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,8 @@ This file documents the revision history for the Open Monitoring Distribution
- omd:
- Fixed problem updating omd sites without tmpfs: Not removing
whole tmp/ directory but only the contents
+ - Improved exception handling during omd update/cp/mv (Asking
+ for retry/accept/abort now)
- RPMS: Not checking for removed version during pkg release update
(Does not mean omd version update.)
- Mod-Gearman: Updated to version 1.3.0
diff --git a/packages/omd/omd b/packages/omd/omd
index 55daae0..6dfbecb 100644
--- a/packages/omd/omd
+++ b/packages/omd/omd
@@ -2579,15 +2579,36 @@ def walk_skel(root, handler, args, exclude_if_in = None, relbase = '.'):
if exclude_if_in and os.path.exists(exclude_if_in + "/" + path):
continue
- try:
- handler(path, *args)
- except Exception, e:
- sys.stderr.write(error * 40 + "\n")
- sys.stderr.write(error + " Exception %s\n" % (path))
- sys.stderr.write(error + " " + traceback.format_exc().replace('\n', "\n" + error + " ") + "\n")
- sys.stderr.write(error * 40 + "\n")
- #sys.stderr.write("Error updating %s/%s: %s\n" % (g_sitedir, path, e))
- #raise
+ todo = True
+ while todo:
+ try:
+ handler(path, *args)
+ todo = False
+ except Exception, e:
+ todo = False
+ sys.stderr.write(error * 40 + "\n")
+ sys.stderr.write(error + " Exception %s\n" % (path))
+ sys.stderr.write(error + " " + traceback.format_exc().replace('\n', "\n" + error + " ") + "\n")
+ sys.stderr.write(error * 40 + "\n")
+
+ # If running in interactive mode ask the user to terminate or retry
+ # In case of non interactive mode just throw the exception
+ if opt_conflict == 'ask':
+ options = [
+ ("retry", "Retry the operation"),
+ ("accept", "Continue with next files"),
+ ("abort", "Stop here and abort update!")
+ ]
+ choice = ask_user_choices(
+ 'Problem occured',
+ 'We detected an exception (printed above). You have the '
+ 'chance to fix things and retry the operation now.',
+ options
+ )
+ if choice == 'abort':
+ bail_out("Update aborted.")
+ elif choice == 'retry':
+ todo = True # Try again
def main_update(args, options={}):
More information about the omd-commits
mailing list