source: WAeUP_SRP/base/skins/waeup_utilities/ti_507_resolve.py @ 3361

Last change on this file since 3361 was 3361, checked in by joachim, 17 years ago

improve logging

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1## Script (Python) "ti_507_resolve"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: ti_507_resolve.py 3361 2008-03-20 09:19:20Z joachim $
11"""
12"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18
19mtool = context.portal_membership
20member = mtool.getAuthenticatedMember()
21if str(member) not in ('admin','joachim'):
22    return
23
24
25import logging
26import DateTime
27logger = logging.getLogger('Skins.ti_507_resolve')
28from Products.AdvancedQuery import Eq, Between, Le,In
29aq_students = context.students_catalog.evalAdvancedQuery
30aq_portal = context.portal_catalog_real.evalAdvancedQuery
31students_folder = context.portal_url.getPortalObject().campus.students
32
33request = context.REQUEST
34session = request.SESSION
35response = request.RESPONSE
36setheader = request.RESPONSE.setHeader
37logger.info('start')
38count = 0
39found = 0
40commit_after = 100000
41certificates = context.getCertificatesDict()
42students = context.students_catalog()
43wrong = []
44missing_courses = []
45wrong_modes = {}
46for student in students:
47    count += 1
48    if student.entry_mode and student.course:
49        certificate = certificates.get(student.course,None)
50        if certificate is None:
51            if student.course not in missing_courses:
52                missing_courses += student.course,
53                logger.info('missing course %s' % student.course)
54            continue
55        entry_mode = student.entry_mode
56        study_mode = certificate.get('study_mode','xxx')
57        if entry_mode != study_mode:
58            w_count =  wrong_modes.get((entry_mode,study_mode),0)
59            if w_count == 0:
60                logger.info('%s != %s' % (student.entry_mode,
61                                          study_mode))
62            w_count += 1
63            wrong_modes[(entry_mode,study_mode)] = w_count
64            wrong += student.id,
65    if wrong and not (len(wrong) % commit_after):
66        logger.info('found %d wrong of %d' % (len(wrong),count))
67for k,v in wrong_modes.items():
68    logger.info('wrong mode %s counted %d' % (k,v))
69logger.info('missing courses %s' % (', '.join(missing_courses)))
70logger.info('found %d wrong of %d' % (len(wrong),count))
Note: See TracBrowser for help on using the repository browser.