diff options
Diffstat (limited to 'src/lib/Server')
-rwxr-xr-x | src/lib/Server/Reports/importscript.py | 22 |
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) |