Ignore:
Timestamp:
21 Nov 2012, 22:37:03 (12 years ago)
Author:
Henrik Bettermann
Message:

Rework logging of batch processing. Remove redundant text but add name of import file.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/batching.py

    r9701 r9706  
    7070        return
    7171
    72     def updateEntry(self, obj, row, site):
     72    def updateEntry(self, obj, row, site, filename):
    7373        """Update obj to the values given in row.
    7474
     
    7676        """
    7777        items_changed = super(AccessCodeBatchProcessor, self).updateEntry(
    78             obj, row, site)
     78            obj, row, site, filename)
    7979        # Log actions...
    8080        location_field = self.location_fields[0]
    81         grok.getSite()['accesscodes'].logger.info('%s - %s - Batch updated: %s'
    82             % (self.name, row[location_field], items_changed))
     81        grok.getSite()['accesscodes'].logger.info(
     82            '%s - %s - %s - updated: %s'
     83            % (self.name, filename, row[location_field], items_changed))
    8384        return
    8485
     
    180181        return None
    181182
    182     def updateEntry(self, obj, row, site):
     183    def updateEntry(self, obj, row, site, filename):
    183184        """Update obj to the values given in row.
    184185
     
    215216
    216217        items_changed += super(AccessCodeProcessor, self).updateEntry(
    217             obj, row, site)
     218            obj, row, site, filename)
    218219
    219220        # Log actions...
    220         grok.getSite()['accesscodes'].logger.info('%s - %s - AC updated: %s'
    221             % (self.name, row['representation'], items_changed))
    222         return
     221        grok.getSite()['accesscodes'].logger.info(
     222            '%s - %s - %s - updated: %s'
     223            % (self.name, filename, row['representation'], items_changed))
     224        return
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/tests/test_batching.py

    r9283 r9706  
    111111        logcontent = open(self.logfile).read()
    112112        self.assertTrue(
    113             'system - AccessCodeBatch Processor - CLR-1 - '
    114             'Batch updated: num=1, creator=system, used_num=1, '
     113            'system - AccessCodeBatch Processor - sample_batch_data - '
     114            'CLR-1 - updated: '
     115            'num=1, creator=system, used_num=1, '
    115116            'entry_num=3, creation_date=2012-04-28 07:28:48.719026+00:00, '
    116117            'prefix=CLR, cost=0.0, disabled_num=0'
     
    167168        logcontent = open(self.logfile).read()
    168169        self.assertTrue(
    169             'INFO - system - AccessCode Processor - CLR-1-1625368961 - '
    170             'AC updated: state=used, batch_serial=33, random_num=1625368961, '
     170            'INFO - system - AccessCode Processor - sample_ac_data - '
     171            'CLR-1-1625368961 - updated: state=used, '
     172            'batch_serial=33, random_num=1625368961, '
    171173            'cost=100.0, owner=K1000009'
    172174            in logcontent)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/batching.py

    r9701 r9706  
    221221        pass
    222222
    223     def updateEntry(self, obj, row, site):
     223    def updateEntry(self, obj, row, site, filename):
    224224        """Update obj to the values given in row.
    225225        """
     
    264264        # apply other values...
    265265        items_changed += super(ApplicantProcessor, self).updateEntry(
    266             obj, row, site)
     266            obj, row, site, filename)
    267267
    268268        # Log actions...
     
    270270        if self.getLocator(row) == 'container_code':
    271271            parent.__parent__.logger.info(
    272                 'Applicant imported: %s' % items_changed)
     272                '%s - %s - imported: %s' % (self.name, filename, items_changed))
    273273        else:
    274274            parent.__parent__.logger.info(
    275                 'Applicant updated: %s' % items_changed)
     275                '%s - %s - updated: %s' % (self.name, filename, items_changed))
    276276        return items_changed
    277277
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py

    r9293 r9706  
    304304        # create applicant with given application_number
    305305        self.assertTrue(
    306             'Applicant imported: applicant_id=dp2011_1234, password=mypwd1, '
     306            'Applicant Processor - sample_applicant_data - imported: '
     307            'applicant_id=dp2011_1234, password=mypwd1, '
    307308            'reg_number=1001, firstname=Aaren, middlename=Peter, lastname=Pieri, '
    308309            'sex=m, course1=CERT1, date_of_birth=1990-01-02, email=xx@yy.zz' in
     
    311312        # not shown in the log file
    312313        self.assertTrue(
    313             'Applicant imported: reg_number=1003, firstname=Aaren, '
     314            'Applicant Processor - sample_applicant_data - imported: '
     315            'reg_number=1003, firstname=Aaren, '
    314316            'middlename=Alfons, lastname=Berson, sex=m, course1=CERT1, '
    315317            'date_of_birth=1990-01-04, email=xx@yy.zz' in
     
    369371        # reg_number is locator
    370372        self.assertTrue(
    371             'Applicant updated: reg_number=1001, firstname=Aaren' in
     373            'Applicant Processor - sample_applicant_data_update - updated: '
     374            'reg_number=1001, firstname=Aaren' in
    372375            logcontent)
    373376        # applicant_id is locator
    374377        self.assertTrue(
    375             'Applicant updated: state=admitted, reg_number=6666, '
     378            'Applicant Processor - sample_applicant_data_update - updated: '
     379            'state=admitted, reg_number=6666, '
    376380            'firstname=Alfons, applicant_id=dp2011_2345' in
    377381            logcontent)
  • main/waeup.kofa/trunk/src/waeup/kofa/authentication.py

    r9313 r9706  
    426426        return
    427427
    428     def updateEntry(self, obj, row, site):
     428    def updateEntry(self, obj, row, site, filename):
    429429        """Update obj to the values given in row.
    430430        """
     
    451451        # Log actions...
    452452        items_changed = ', '.join(changed)
    453         grok.getSite().logger.info('%s - %s - updated: %s'
    454             % (self.name, row['name'], items_changed))
     453        grok.getSite().logger.info('%s - %s - %s - updated: %s'
     454            % (self.name, filename, row['name'], items_changed))
    455455        return
    456456
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/batching.py

    r9312 r9706  
    6262        return
    6363
    64     def updateEntry(self, obj, row, site):
     64    def updateEntry(self, obj, row, site, filename):
    6565        """Update obj to the values given in row.
    6666        """
     
    8585        location_field = self.location_fields[0]
    8686        items_changed = ', '.join(changed)
    87         grok.getSite()['hostels'].logger.info('%s - %s - Record updated: %s'
    88             % (self.name, row[location_field], items_changed))
     87        grok.getSite()['hostels'].logger.info(
     88            '%s - %s - %s - updated: %s'
     89            % (self.name, filename, row[location_field], items_changed))
    8990        return
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r9534 r9706  
    504504        logcontent = open(self.logfile).read()
    505505        self.assertTrue(
    506             "Hostel Processor - block-a-upper-hostel - "
    507             "Record updated: beds_for_pre=['G'], floors_per_block=1, "
     506            "Hostel Processor - sample_hostel_data - block-a-upper-hostel - "
     507            "updated: "
     508            "beds_for_pre=['G'], floors_per_block=1, "
    508509            "beds_for_final=['A', 'B'], rooms_per_floor=32, "
    509510            "blocks_for_male=[], hostel_id=block-a-upper-hostel, "
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r9701 r9706  
    185185        return None
    186186
    187     def updateEntry(self, obj, row, site):
     187    def updateEntry(self, obj, row, site, filename):
    188188        """Update obj to the values given in row.
    189189        """
     
    230230        # apply other values...
    231231        items_changed += super(StudentProcessor, self).updateEntry(
    232             obj, row, site)
     232            obj, row, site, filename)
    233233
    234234        # Log actions...
     
    238238            # Create mode: the record contains the student_id
    239239            parent.logger.info(
    240                 '%s - Student record updated: %s'
    241                 % (obj.student_id, items_changed))
     240                '%s - %s - %s - updated: %s'
     241                % (self.name, filename, obj.student_id, items_changed))
    242242        else:
    243243            # Create mode: the student does not yet exist
    244             parent.logger.info('Student data imported: %s' % items_changed)
     244            # XXX: It seems that this never happens because student_id
     245            # is always set.
     246            parent.logger.info(
     247                '%s - %s - %s - imported: %s'
     248                % (self.name, filename, obj.student_id, items_changed))
    245249        return items_changed
    246250
     
    418422        return student.get('studycourse')
    419423
    420     def updateEntry(self, obj, row, site):
     424    def updateEntry(self, obj, row, site, filename):
    421425        """Update obj to the values given in row.
    422426        """
    423427        items_changed = super(StudentStudyCourseProcessor, self).updateEntry(
    424             obj, row, site)
     428            obj, row, site, filename)
    425429        parent = self.getParent(row, site)
    426430        parent.__parent__.logger.info(
    427             '%s - Study course updated: %s'
    428             % (parent.student_id, items_changed))
     431            '%s - %s - %s - updated: %s'
     432            % (self.name, filename, parent.student_id, items_changed))
    429433        # Update the students_catalog
    430434        notify(grok.ObjectModifiedEvent(obj.__parent__))
     
    503507        return
    504508
    505     def updateEntry(self, obj, row, site):
     509    def updateEntry(self, obj, row, site, filename):
    506510        """Update obj to the values given in row.
    507511        """
    508512        items_changed = super(StudentStudyLevelProcessor, self).updateEntry(
    509             obj, row, site)
     513            obj, row, site, filename)
    510514        student = self.getParent(row, site).__parent__
    511515        student.__parent__.logger.info(
    512             '%s - Study level updated: %s'
    513             % (student.student_id, items_changed))
     516            '%s - %s - %s - updated: %s'
     517            % (self.name, filename, student.student_id, items_changed))
    514518        return
    515519
     
    574578        return level.get(row['code'])
    575579
    576     def updateEntry(self, obj, row, site):
     580    def updateEntry(self, obj, row, site, filename):
    577581        """Update obj to the values given in row.
    578582        """
    579583        items_changed = super(CourseTicketProcessor, self).updateEntry(
    580             obj, row, site)
     584            obj, row, site, filename)
    581585        parent = self.getParent(row, site)
    582586        student = self.getParent(row, site).__parent__.__parent__
    583587        student.__parent__.logger.info(
    584             '%s - Course ticket in %s updated: %s'
    585             % (student.student_id, parent.level, items_changed))
     588            '%s - %s - %s - %s - updated: %s'
     589            % (self.name, filename, student.student_id, parent.level, items_changed))
    586590        return
    587591
     
    690694        return entry
    691695
    692     def updateEntry(self, obj, row, site):
     696    def updateEntry(self, obj, row, site, filename):
    693697        """Update obj to the values given in row.
    694698        """
    695699        items_changed = super(StudentOnlinePaymentProcessor, self).updateEntry(
    696             obj, row, site)
     700            obj, row, site, filename)
    697701        student = self.getParent(row, site).__parent__
    698702        student.__parent__.logger.info(
    699             '%s - Payment ticket updated: %s'
    700             % (student.student_id, items_changed))
     703            '%s - %s - %s - updated: %s'
     704            % (self.name, filename, student.student_id, items_changed))
    701705        return
    702706
     
    798802        return None
    799803
    800     def updateEntry(self, obj, row, site):
     804    def updateEntry(self, obj, row, site, filename):
    801805        """Update obj to the values given in row.
    802806        """
     
    804808        vals_to_set = dict((key, val) for key, val in row.items()
    805809                           if key not in ('current_session','current_level'))
    806         super(StudentVerdictProcessor, self).updateEntry(obj, vals_to_set, site)
     810        super(StudentVerdictProcessor, self).updateEntry(
     811            obj, vals_to_set, site, filename)
    807812        parent = self.getParent(row, site)
    808813        # Set current_vedict in corresponding studylevel
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9467 r9706  
    666666        # Logging message from updateEntry,
    667667        self.assertTrue(
    668             'INFO - system - K1000000 - Study level '
    669             'updated: level=100, level_verdict=C, level_session=2009'
     668            'INFO - system - StudentStudyLevel Processor - '
     669            'sample_studylevel_data - K1000000 - updated: '
     670            'level=100, level_verdict=C, level_session=2009'
    670671            in logcontent)
    671672
     
    788789        self.assertEqual(courseticket.semester, 1)
    789790        shutil.rmtree(os.path.dirname(fin_file))
    790 
    791791        logcontent = open(self.logfile).read()
    792792        # Logging message from updateEntry,
    793793        self.assertTrue(
    794             'INFO - system - K1000000 - Course ticket in 100 updated: code=COURSE1, '
     794            'INFO - system - CourseTicket Processor - '
     795            'sample_courseticket_data - K1000000 - 100 - '
     796            'updated: code=COURSE1, '
    795797            'mandatory=False, score=3'
    796798            in logcontent)
     
    968970        # Logging message from updateEntry
    969971        self.assertTrue(
    970             'INFO - system - K1000001 - Payment ticket updated: '
     972            'INFO - system - Student Payment Processor - '
     973            'sample_payment_data - K1000001 - updated: '
    971974            'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, '
    972975            'p_category=schoolfee, amount_auth=19500.0, p_current=True, '
     
    975978            in logcontent)
    976979        self.assertTrue(
    977             'INFO - system - K1000001 - Payment ticket updated: '
     980            'INFO - system - Student Payment Processor - '
     981            'sample_payment_data - K1000001 - updated: '
    978982            'p_item=BTECHBDT, creation_date=2010-02-15 13:19:01+00:00, '
    979983            'p_category=schoolfee, amount_auth=19500.6, p_current=True, '
     
    10891093        logcontent = open(self.logfile).read()
    10901094        self.assertMatches(
    1091             '... INFO - system - X666666 - Study course updated: current_verdict=0...',
     1095            '... INFO - system - Verdict Processor (special processor, '
     1096            'update only) - sample_verdict_data - X666666 - '
     1097            'updated: current_verdict=0...',
    10921098            logcontent)
    10931099        self.assertMatches(
  • main/waeup.kofa/trunk/src/waeup/kofa/university/batching.py

    r9701 r9706  
    9292        pass
    9393
    94     def updateEntry(self, obj, row, site):
     94    def updateEntry(self, obj, row, site, filename):
    9595        """Update obj to the values given in row.
    9696        """
     
    120120        # apply other values...
    121121        items_changed += super(FacultyProcessor, self).updateEntry(
    122             obj, row, site)
     122            obj, row, site, filename)
    123123
    124124        # Log actions...
    125125        location_field = self.location_fields[0]
    126         grok.getSite().logger.info('%s - %s - Record updated: %s'
    127             % (self.name, row[location_field], items_changed))
     126        grok.getSite().logger.info('%s - %s - %s - updated: %s'
     127            % (self.name, filename, row[location_field], items_changed))
    128128        return items_changed
    129129
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py

    r9265 r9706  
    205205        return None
    206206
    207     def updateEntry(self, obj, row, site):
     207    def updateEntry(self, obj, row, site, filename):
    208208        """Update obj to the values given in row.
    209209
     
    350350                # student_ids and applicant_ids which have been
    351351                # generated in the respective __init__ methods before.
    352                 self.updateEntry(obj, row, site)
     352                self.updateEntry(obj, row, site, base)
    353353                try:
    354354                    self.addEntry(obj, row, site)
     
    387387                        failed_writer, string_row, update_errors)
    388388                    continue
    389                 self.updateEntry(obj, row, site)
     389                self.updateEntry(obj, row, site, base)
    390390            finished_writer.writerow(string_row)
    391391
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.txt

    r8330 r9706  
    218218    ...     stoneville[row['name']] = obj
    219219    ...
    220     ...   def updateEntry(self, obj, row, site):
     220    ...   def updateEntry(self, obj, row, site, filename):
    221221    ...     # This is not strictly necessary, as the default
    222222    ...     # updateEntry method does exactly the same
Note: See TracChangeset for help on using the changeset viewer.