👁 查看:suivi_icone.py
路径:/virtual/bigbrother/public_html/edream-c.com/cr/PLUGINS/suivi_icone.py
大小:2.75 KB · 修改:2014-04-13 19:50:28 · 权限:0644 · 可写
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#    TOMUSS: The Online Multi User Simple Spreadsheet)
#    Copyright (C) 2008-2011 Thierry EXCOFFIER, Universite Claude Bernard
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#    Contact: Thierry.EXCOFFIER@bat710.univ-lyon1.fr

from .. import plugin
from .. import utilities
from .. import files
from . import suivi_student

try:
    import PIL.Image
    ok = True
except ImportError:
    utilities.warn("No Python module PIL")
    ok = False

def student_icone(server):
    """Generate an icon summarising the student information
    from all the tables."""
    if not ok:
        return
    
    login = server.the_student
    
    prst = []
    note = []
    ues = suivi_student.the_ues(server.year, server.semester, login)
    if not ues:
        server.the_file.write(str(files.files['tip.png']))
        return
    for t in ues:
        for line in t.get_lines(login):
            prst += t.lines.line_indicator(line, what='Prst')
            note += t.lines.line_indicator(line, what='Note')

    prst.sort()
    prst = [v[1] for v in prst]
    
    note.sort()
    note = [v[1] for v in note]
                
    n = max(int(len(prst)**0.5), int(len(note)**0.5), 3) + 1
    s = [(238, 238, 238)] * ((2*n+1) * n)
    for i in range(n): s[n+i*(2*n+1)] = (255, 255, 255)

    for i, vv in enumerate(prst):
        vv = int(vv * 255)
        s[int(i/n)*(2*n+1) + i%n] = (255-vv, vv, 128)

    for i, vv in enumerate(note):
        vv = int(vv * 255)
        s[int(i/n)*(2*n+1) + i%n + n+1] = (255-vv, vv, 128)

    im = PIL.Image.new("RGB", (2*n+1, n))
    im.putdata(s)
    im.save(server.the_file, 'PNG')
    
plugin.Plugin('icone', '/{_I}',
              function=student_icone,
              # launch_thread=True,
              authenticated=False,
              mimetype = 'image/png',
              cached = True,
              )

plugin.Plugin('icone_withticket', '/{?}/{_I}',
              function=student_icone,
              authenticated=False,
              # launch_thread=True,
              mimetype = 'image/png',
              cached = True,
              )

ページが見つかりませんでした – Lumiere Shop
ここを指しているリンクに誤りがあったようです。検索してみるのはいかがですか ?
お買い物カゴ