Changeset 4878


Ignore:
Timestamp:
23 Jan 2010, 08:33:21 (15 years ago)
Author:
uli
Message:
  • Don't display errors in logfiles any more (they are added in .pending files instead).
  • Rename 'warnings' to 'warn_num'.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/trunk/src/waeup/utils/batching.py

    r4877 r4878  
    201201                timedelta, timedelta/(num or 1)))
    202202        fd.write("Processed: %s lines (%s successful/ %s failed)\n" % (
    203                 num, num - len(warnings), len(warnings)
     203                num, num - warnings, warnings
    204204                ))
    205         fd.write("-" * 70 + '\n')
    206         failnum = 1
    207         for linenum, text in sorted(warnings.items()):
    208             fd.write("line %s (%s): %s\n" % (failnum, linenum, text))
    209             failnum += 1
    210         fd.close()
    211205        return
    212206
     
    240234        failed_writer.writerow(dict([(x,x) for x in failed_headers]))
    241235       
    242         warnings = dict()
    243236        num =0
     237        num_warns = 0
    244238        site = grok.getSite()
    245239        for raw_row in reader:
     
    249243                copy.deepcopy(string_row), converters)
    250244            if len(conv_warnings):
    251                 warnings[num] = ', '.join(conv_warnings)
     245                num_warns += 1
    252246                self.writeFailedRow(failed_writer, string_row, conv_warnings)
    253                 #failed_writer.writerow(string_row)
    254247                continue
    255248               
    256249            if mode == 'create':
    257250                if not self.parentsExist(row, site):
    258                     warnings[num] = "Not all parents do exist yet. Skipping"
     251                    num_warns += 1
    259252                    self.writeFailedRow(
    260253                        failed_writer, string_row,
     
    262255                    continue
    263256                if self.entryExists(row, site):
    264                     warnings[num] = 'This object already exists. Skipping.'
     257                    num_warns += 1
    265258                    self.writeFailedRow(
    266259                        failed_writer, string_row,
     
    273266            elif mode == 'remove':
    274267                if not self.entryExists(row, site):
    275                     warnings[num] = "Cannot remove: no such entry."
     268                    num_warns += 1
    276269                    self.writeFailedRow(
    277270                        failed_writer, string_row,
     
    282275                obj = self.getEntry(row, site)
    283276                if obj is None:
    284                     warnings[num] = "Cannot update: no such entry."
     277                    num_warns += 1
    285278                    self.writeFailedRow(
    286279                        failed_writer, string_row,
     
    296289            os.rename(failed_path, path)
    297290            failed_path = path
    298         self.createLogfile(path, failed_path, num, warnings, mode, user,
     291        self.createLogfile(path, failed_path, num, num_warns, mode, user,
    299292                           timedelta)
    300         if len(warnings) == 0:
     293        if num_warns == 0:
    301294            del failed_writer
    302295            os.unlink(failed_path)
    303         return (num, warnings)
     296        return (num, num_warns)
    304297
    305298class FacultyProcessor(BatchProcessor):
Note: See TracChangeset for help on using the changeset viewer.