Exemplo n.º 1
0
    def usermgt(self,name='',pwd='',group=''):
        m=hmenu(self.langconfig,self.dbf)
        db=SQLite(self.dbf)

        ### parameter treatment
        if name=='':
            if group!='':
                req='insert into groups values("{}")'.format(group)
                status=db.upd_ins(req)
        else:
            req='select rowid from groups where name="{}"'.format(group)
            idgroup=db.select(req)
            hashpwd=bcrypt.hashpw(pwd,bcrypt.gensalt())

            req='insert into users (name,hashpass,id_group)'
            req+=' values("{}","{}",{})'.format(name,hashpwd,idgroup[0][0])
            status=db.upd_ins(req)

        try:
            sname=cherrypy.session['name']
            [actions,contenu]=m.usersAndGroup()
        except Exception as err:
            logging.error("in usermgt: %s",err)
            contenu=m.unknown()
        HTMLpage=self.html["globalTemplate"].format(actions,contenu)
        return HTMLpage
Exemplo n.º 2
0
def insertPathInDb(path):
    ### insert folder into db
    reqi="insert into folder values ('{}',0)".format(path)
    db=SQLite(join(config["rootpath"],config["dbfile"]))
    return db.upd_ins(reqi)
Exemplo n.º 3
0
    print(root)
    logging.debug("searchPhoto:folder:%s",root)
    ### check/insert folder into db
    res=getPathInDb(root)
    for rep in dirs:
        if rep not in bl:
            r=getPathInDb(join(root,rep))
            if r==[]:
                insertPathInDb(join(root,rep))
                r=getPathInDb(join(root,rep))
            ### link folder father and son...
            req='insert into folderParent values({},{})'.\
                 format(res[0][0],r[0][0])
            db=SQLite(join(config["rootpath"],config["dbfile"]))
            db.upd_ins(req)



    #### no files treatment if folder is emptu
    if files==[]:
        logging.debug("no files in %s",root)
        continue

    idDir=res[0]
    for f in files:
        logging.debug("searchPhoto:%s",join(root,f))
        ####### recherche si le fichier existe deja en base
        req="select id_dir,filename from files "
        req=req+"where id_dir = {} ".format(idDir[0])
        req=req+"and filename='{}'".format(f)