summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-05-26 18:22:59 +0000
committerSol Jerome <solj@ices.utexas.edu>2010-05-26 15:37:25 -0500
commitb3f4b34e8bf3634b812b83f15b675c626b0b1472 (patch)
tree99e82b0943c8a7efe8f78ebc84cc80ed5e5e6759
parent0400240d17193819815c24b7e38ef5981a9cff97 (diff)
downloadbcfg2-b3f4b34e8bf3634b812b83f15b675c626b0b1472.tar.gz
bcfg2-b3f4b34e8bf3634b812b83f15b675c626b0b1472.tar.bz2
bcfg2-b3f4b34e8bf3634b812b83f15b675c626b0b1472.zip
DBStats: Handle errors in load_stats
If any of the sql database insertsor selects failed, the all of the data for the client at that point was lost. This uses an empty Reason object to preserve the rest of the data. git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5866 ce84e21b-d406-0410-9b95-82705330c041
-rwxr-xr-xsrc/lib/Server/Reports/importscript.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lib/Server/Reports/importscript.py b/src/lib/Server/Reports/importscript.py
index ae8b6e402..8cc38268e 100755
--- a/src/lib/Server/Reports/importscript.py
+++ b/src/lib/Server/Reports/importscript.py
@@ -123,15 +123,21 @@ def load_stats(cdata, sdata, vlevel, quick=False, location=''):
else:
rls = []
- if rls:
- rr = rls[0]
- if vlevel > 0:
- print "Reason exists: %s"% (rr.id)
- else:
- rr = Reason(**kargs)
+ try:
+ if rls:
+ rr = rls[0]
+ if vlevel > 0:
+ print "Reason exists: %s"% (rr.id)
+ else:
+ rr = Reason(**kargs)
+ rr.save()
+ if vlevel > 0:
+ print "Created reason: %s" % rr.id
+ except Exception, ex:
+ print "Failed to create reason for %s: %s" % (x.get('name'), ex)
+ rr=Reason(current_exists=x.get('current_exists',
+ default="True").capitalize()=="True")
rr.save()
- if vlevel > 0:
- print "Created reason: %s" % rr.id
links = Entries.objects.filter(name=x.get('name'),
kind=x.tag)