Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

admin.py 2.48 KB
Newer Older
Marc Duez's avatar
Marc Duez committed
1
# coding: utf8
Marc Duez's avatar
Marc Duez committed
2
import gluon.contrib.simplejson, re
Marc Duez's avatar
Marc Duez committed
3
import os.path
4
import vidjil_utils
5

Marc Duez's avatar
Marc Duez committed
6 7 8 9 10 11 12 13
if request.env.http_origin:
    response.headers['Access-Control-Allow-Origin'] = request.env.http_origin  
    response.headers['Access-Control-Allow-Credentials'] = 'true'
    response.headers['Access-Control-Max-Age'] = 86400
    

## return admin_panel
def index():
14 15
    if auth.has_membership("admin"):
        return dict(message=T(''))
Marc Duez's avatar
Marc Duez committed
16 17 18 19
    
def worker():
    if auth.has_membership("admin"):
        return dict(message=T(''))
Marc Duez's avatar
Marc Duez committed
20 21 22 23 24
    
    
def log():
    if auth.has_membership("admin"):
        
25
        
Marc Duez's avatar
Marc Duez committed
26 27 28
        lines = []
        file = open('/var/vidjil/'+request.vars["file"])
        
29 30
        if "filter" not in request.vars :
            request.vars["filter"] = ""
Marc Duez's avatar
Marc Duez committed
31
            
32 33 34
        for row in reversed(file.readlines()) :

            if vidjil_utils.filter(row, request.vars["filter"]) :
Marc Duez's avatar
Marc Duez committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
                line = {}

                tmp = re.split('\t+| +', row) 

                line["date"] = tmp[1]
                line["date2"] = tmp[2].split(',')[0]
                line["type"] = tmp[3]
                line["file"] = tmp[5]

                if tmp[6] != "Creating":
                    line["user"] = tmp[7]
                    line["mes"] = ""
                    for i in range(8,len(tmp)):
                        line["mes"] += tmp[i] + " "
                else:
                    line["user"] = ""
                    line["mes"] = ""
                    for i in range(6,len(tmp)):
                        line["mes"] += tmp[i] + " "

                lines.append(line)

                if len(lines) >= 100 :
                    return dict(lines = lines)
            
        return dict(lines = lines
                    )
Marc Duez's avatar
Marc Duez committed
62 63 64 65 66 67 68 69 70 71 72 73 74

## to use after change in the upload folder
def repair_missing_files():
    if auth.has_membership("admin"):
        
        flist = ""
        for row in db(db.sequence_file.id>0 and db.sequence_file.data_file != None).select() : 
            seq_file = defs.DIR_SEQUENCES+row.data_file
            
            if not os.path.exists(seq_file) :
                db.sequence_file[row.id] = dict(data_file = None)
                flist += " : " + row.filename
            else :
75
                size = os.path.getsize(seq_file)
Marc Duez's avatar
Marc Duez committed
76 77 78 79
                db.sequence_file[row.id] = dict(size_file = size)
                
        res = {"success" : "true", "message" : "path of missing files have been removed from the database"+flist}
        return gluon.contrib.simplejson.dumps(res, separators=(',',':'))