Example #1
0
def skoleGetChildren():
    '''Returns of list of "available" children in the system'''
    global _children

    # reset list of children
    _children = None

    # reset login
    surllib.resetSkoleLogin()

    # ensure that we are logged in
    surllib.skoleLogin()  # done automatically later

    config.log(u'Henter liste af børn')

    if not _children:
        data = surllib.skoleGetURL(url(), asSoup=True, noCache=True)
        if not data:
            return []

        _children = {}
        for a in data.findAll('a'):
            href = a['href']
            name = a.span.text

            if name in NAMES_IGNORE:
                config.log(u'Ignorerer [%s]' % name)
                continue

            _children[name] = href

    return sorted(_children.keys())
Example #2
0
def skoleDocuments():
    global bs

    surllib.skoleLogin()
    config.log(u'Kigger efter nye dokumenter')

    # read the initial page
    bs = surllib.skoleGetURL(urlMain(), True, True)
    docFindDocuments(bs)
Example #3
0
def skoleWeekplans():
    global bs

    surllib.skoleLogin()
    config.log(u'Kigger efter nye ugeplaner')

    # read the initial page
    bs = surllib.skoleGetURL(urlMain(), True, True)
    wpFindWeekplans(bs)
Example #4
0
def getChildren():
    '''Returns of list of "available" children in the system'''
    global _children

    def ckey(n): return tuple(n.rsplit(' ', 1)[::-1])

    if not _children:
        _children = dict()
        seen = set()

        config.log(u'Henter liste af børn')
        data = surllib.skoleLogin()

        # Name of "First child"
        fst = data.find(id="sk-personal-menu-button").text.strip()

        for a in data.findAll('a', href=re.compile('^(/[^/]*){3}/Index$')):
            url = a['href'].rsplit('/', 1)[0].rstrip('/')
            if url in seen:
                continue
            seen.add(url)
            name = a.text.strip() or fst
            if name not in _children:
                config.log(u'Barn %s => %s' % (name, url), 2)
                _children[name] = url
        cns = sorted(_children.keys(), key=ckey)
        config.log(u'Følgende børn blev fundet: ' + u', '.join(cns))

    return sorted(_children.keys(), key=ckey)
Example #5
0
def getChildren():
    '''Returns of list of "available" children in the system'''
    global _children

    def ckey(n):
        return tuple(n.rsplit(' ', 1)[::-1])

    if not _children:
        _children = dict()
        seen = set()

        config.log(u'Henter liste af børn')
        data = surllib.skoleLogin()

        # Name of "First child"
        fst = data.find(id="sk-personal-menu-button").text.strip()

        for a in data.findAll('a', href=re.compile('.*/Index$')):
            url = a['href'].rsplit('/', 1)[0].rstrip('/')
            if url in seen:
                continue
            seen.add(url)
            name = a.text.strip() or fst
            if name not in _children:
                config.log(u'Barn %s => %s' % (name, url), 2)
                _children[name] = url
        cns = sorted(_children.keys(), key=ckey)
        config.log(u'Følgende børn blev fundet: ' + u', '.join(cns))

    return sorted(_children.keys(), key=ckey)
Example #6
0
def skoleDialogue():
    surllib.skoleLogin()
    br = surllib.getBrowser()

    for tray in TRAYS:
        config.log(u'Behandler beskeder i bakken %s' % tray)

        url = 'https://%s%s%s' % (config.HOSTNAME, URL_BOX_PREFIX, tray)

        # Read the initial page, and search for messages
        config.log(u'Bakke-URL: %s' % url)
        resp = br.open(url)
        data = resp.read()
        # ensure that we get only mgss for the current child
        br.select_form(name='FrontPage_Form1')
        br['R1'] = ('klasse',)
        resp = br.submit()
        data = resp.read()

        diaFindMessages(data)
Example #7
0
def skoleDialogue():
    surllib.skoleLogin()
    br = surllib.getBrowser()

    for tray in TRAYS:
        config.log(u'Behandler beskeder i bakken %s' % tray)

        url = 'https://%s%s%s' % (config.HOSTNAME, URL_BOX_PREFIX, tray)

        # Read the initial page, and search for messages
        config.log(u'Bakke-URL: %s' % url)
        resp = br.open(url)
        data = resp.read()
        # ensure that we get only mgss for the current child
        br.select_form(name='FrontPage_Form1')
        br['R1'] = ('klasse', )
        resp = br.submit()
        data = resp.read()

        diaFindMessages(data)
Example #8
0
def skoleFrontpage():
    surllib.skoleLogin()

    config.log('Behandler forsiden')

    url = 'http://%s/Infoweb/Fi2/Forside.asp' % config.HOSTNAME
    data = surllib.skoleGetURL(url, asSoup=True, noCache=True)

    br = surllib.getBrowser()
    aurl = br.geturl()
    if u'Personoplysninger.asp' in aurl:
        # We are actually asked to confirm our personal data
        config.log(u'Bekræfter først vores personlige data')
        skoleConfirmPersonalData(data)

        data = surllib.skoleGetURL(url, asSoup=True, noCache=True)

    # find main table
    maint = []
    for mt in data.findAll('table'):
        if mt.findParents('table') or mt.has_key('bgcolor'):
            continue
        txt = mt.text
        if len(txt) < 30 and txt.lower().startswith(u'forældreintra for '):
            continue  # just the title
        maint.append(mt)
    assert(len(maint) == 1)  # assume exactly one main table

    maint = maint[0]

    # find interesting table tags
    itags = []
    for tag in maint:
        for ttag in tag.findAll('table'):
            if ttag.text:
                itags.append(ttag)

    g = []
    for itag in itags:
        t = _getTitle(itag)
        if t is None:
            # not a title
            if not g:
                # In some cases (slideshows), the real title may be missing
                g.append((itags[0].text, []))
            g[-1][1].append(itag)
        else:
            # we have a new title
            g.append((t, []))

    for (t, xs) in g:
        ignore = len(xs) == 0 or t in TITLE_IGNORE
        config.log(u'Kategori [%s]%s' %
                   (t, ' (hoppes over)' if ignore else ''))
        if ignore:
            continue

        if t == TITLE_COVERPIC:
            assert(len(xs) == 1)  # exactly one cover picture
            skoleCoverPic(xs[0])
            continue
        elif t == TITLE_BBB:
            # BBB news are split
            # ignore first table which is a wrapper around all entries
            xs = xs[1:]
            map(skoleFrontBBB, xs)
        elif t == TITLE_NEWS:
            # News from...
            skoleNewsFrom(xs)
        else:
            # send msg if something has changed
            for x in xs:
                skoleOtherStuff(t, x)
Example #9
0
def skoleFrontpage():
    surllib.skoleLogin()

    config.log('Behandler forsiden')

    url = 'http://%s/Infoweb/Fi2/Forside.asp' % config.HOSTNAME
    data = surllib.skoleGetURL(url, asSoup=True, noCache=True)

    br = surllib.getBrowser()
    aurl = br.geturl()
    if u'Personoplysninger.asp' in aurl:
        # We are actually asked to confirm our personal data
        config.log(u'Bekræfter først vores personlige data')
        skoleConfirmPersonalData(data)

        data = surllib.skoleGetURL(url, asSoup=True, noCache=True)

    # find main table
    maint = []
    for mt in data.findAll('table'):
        if mt.findParents('table') or mt.has_key('bgcolor'):
            continue
        txt = mt.text
        if len(txt) < 30 and txt.lower().startswith(u'forældreintra for '):
            continue  # just the title
        maint.append(mt)
    assert (len(maint) == 1)  # assume exactly one main table

    maint = maint[0]

    # find interesting table tags
    itags = []
    for tag in maint:
        for ttag in tag.findAll('table'):
            if ttag.text:
                itags.append(ttag)

    g = []
    for itag in itags:
        t = _getTitle(itag)
        if t is None:
            # not a title
            if not g:
                # In some cases (slideshows), the real title may be missing
                g.append((itags[0].text, []))
            g[-1][1].append(itag)
        else:
            # we have a new title
            g.append((t, []))

    for (t, xs) in g:
        ignore = len(xs) == 0 or t in TITLE_IGNORE
        config.log(u'Kategori [%s]%s' %
                   (t, ' (hoppes over)' if ignore else ''))
        if ignore:
            continue

        if t == TITLE_COVERPIC:
            assert (len(xs) == 1)  # exactly one cover picture
            skoleCoverPic(xs[0])
            continue
        elif t == TITLE_BBB:
            # BBB news are split
            # ignore first table which is a wrapper around all entries
            xs = xs[1:]
            map(skoleFrontBBB, xs)
        elif t == TITLE_NEWS:
            # News from...
            skoleNewsFrom(xs)
        else:
            # send msg if something has changed
            for x in xs:
                skoleOtherStuff(t, x)