コード例 #1
0
 def getObjectStatus(self):
     self.statusLend = False
     self.statusReserve = False
     
     Query.setStatTrue("select")
     Query.setTables(["lend"])
     Query.setSelect(["*"])
     Query.setWhere([{"kind":"'%s'"% self.kind}, "AND",
                     {"k_id":self.kId}, "AND", {"status":"'lended'"}])
     request = database.dataBase().execute(Query.returnQuery())
     if len(request)>0:
         self.statusLend = True
     
     self.reserveList = []
     
     Query.setStatTrue("select")
     Query.setSelect(["u_id"])
     Query.setTables(["lend"])
     Query.setWhere([{"kind":"'%s'"% self.kind}, "AND", {"k_id":self.kId},
                      "AND", {"status":"'waiting'"}])
     Query.setAppendix("ORDER BY id")
     request = database.dataBase().execute(Query.returnQuery())        
     for i in request:
         self.reserveList.append(i[0])
         
     if len(self.reserveList)>0:
         self.statusReserve = True
     
     if self.statusLend:
         self.takeBackButton.setEnabled(True)
         
     elif self.statusReserve:
         self.lendToReserveButton.setEnabled(True)
コード例 #2
0
 def getBorrow(self):
     borrow, reserve, tborrow= "", "", 0
     Query.setStatTrue("select")
     Query.setSelect(["kind","k_id"])
     Query.setTables(["lend"])
     Query.setWhere([{"u_id":self.idNow}, "AND", {"status":"'lended'"}])
     request = database.dataBase().execute(Query.returnQuery())
     for i in request:
         Query.setStatTrue("select")
         Query.setSelect(["name"])
         Query.setTables([i[0]])
         Query.setWhere([{"id":i[1]}])
         borrowed = database.dataBase().execute(Query.returnQuery())[0][0]
         borrow += borrowed + "\n"
         
     Query.setStatTrue("select")
     Query.setSelect(["kind","k_id"])
     Query.setTables(["lend"])
     Query.setWhere([{"u_id":self.idNow}, "AND", {"status":"'waiting'"}])
     request = database.dataBase().execute(Query.returnQuery())
     for i in request:
         Query.setStatTrue("select")
         Query.setSelect(["name"])
         Query.setTables([i[0]])
         Query.setWhere([{"id":i[1]}])
         reserved = database.dataBase().execute(Query.returnQuery())[0][0]
         reserve += reserved + "\n"
         
     Query.setStatTrue("select")
     Query.setSelect(["count(id)"])
     Query.setTables(["lend"])
     Query.setWhere([{"u_id":self.idNow}, "AND (", {"status":"'lended'"}, "OR", {"status":"'returned'"}, ")"])
     tborrow = database.dataBase().execute(Query.returnQuery())[0][0]
     
     return (borrow, reserve, tborrow)
コード例 #3
0
 def reserve(self):
     Query.setStatTrue("insert")
     Query.setTables(["lend"])
     Query.setKeys(["kind", "k_id", "u_id", "status"])
     Query.setValues([self.kind, self.kId, self.uid, "waiting"])
     database.dataBase().execute(Query.returnQuery())
     self.close()
コード例 #4
0
 def takeBack(self):
     Query.setStatTrue("update")
     Query.setTables(["lend"])
     Query.setSet({"status":"returned"})
     Query.setWhere([{"kind":"'%s'"% self.kind}, "AND",
                     {"k_id":self.kId}, "AND",
                     {"status":"'lended'"}])
     database.dataBase().execute(Query.returnQuery())
     self.close()
コード例 #5
0
 def lending(self):
     Query.setStatTrue("insert")
     Query.setTables(["lend"])
     Query.setKeys(["kind", "k_id", "u_id", "lenddate",
                    "extension", "status"])
     Query.setValues([self.kind, self.kId, self.uid,
                      datetime.datetime.now(), 0, "lended"])
     database.dataBase().execute(Query.returnQuery())
     self.close()
コード例 #6
0
 def lendToReserved(self):
     self.uid = self.reserveList[0]
     Query.setStatTrue("update")
     Query.setTables(["lend"])
     Query.setSet({"lenddate":datetime.datetime.now(),
                   "extension":0,
                   "status":"lended"})
     Query.setWhere([{"kind":"'%s'"% self.kind}, "AND",
                     {"k_id":self.kId}, "AND",
                     {"status":"'waiting'"}, "AND",
                     {"u_id":self.uid}])
     database.dataBase().execute(Query.returnQuery())
     self.close()
コード例 #7
0
 def __init__(self, type, id, upid=None):
     QtGui.QDialog.__init__(self)
     self.setupUi(self)
     
     self.type = type
     self.id = id
     if self.id == None:
         self.new = True
         self.upid = upid
     else:
         self.new = False
         
         Query.setStatTrue("select")
         Query.setSelect(["up_id"])
         if self.type == "directory":
             Query.setTables(["dirs"])
         elif self.type == "file":
             Query.setTables(["files"])
         Query.setWhere([{"id":self.id}])
         self.upid = database.dataBase().execute(Query.returnQuery())[0][0]
     
     # signals
     self.connect(self.resetButton, QtCore.SIGNAL("clicked()"), self.parse)
     self.connect(self.applyButton, QtCore.SIGNAL("clicked()"), self.applyAction)
     self.connect(self.fillFromFile, QtCore.SIGNAL("clicked()"), self.fillFileInfo)
     self.connect(self.fillFromDir, QtCore.SIGNAL("clicked()"), self.fillDirInfo)
     
     self.parse()
コード例 #8
0
 def nextAction(self):
     Query.setStatTrue("select")
     Query.setSelect(["max(id)"])
     Query.setTables(["users"])
     maxId = database.dataBase().execute(Query.returnQuery())[0][0]
     if self.idNow < maxId:
         self.idNow += 1
         self.fillInfos()
コード例 #9
0
def logs():
    if session['bool'] == True:
        with dataBase(apps.config['base']) as cursor:
            _SQL = 'SELECT * from alllogsfiles'
            cursor.execute(_SQL)
            logs = cursor.fetchall()
            return render_template(
                'table.html', FRUDT=logs)  # 'page_two.html',Logs = str(end)
    else:
        return render_template('Error.html')
コード例 #10
0
 def setId(self):
     Query.setStatTrue("select")
     Query.setSelect(["max(id)"])
     Query.setTables(["users"])
     maxId = database.dataBase().execute(Query.returnQuery())[0][0]
     if self.spinId.value() <= maxId:
         self.idNow = self.spinId.value()
         self.fillInfos()
     else:
         self.spinId.setValue(self.idNow)
コード例 #11
0
def Aunt(base, identificationKey, Email):
    with dataBase(base) as cursor:
        _SQL = 'SELECT id FROM users WHERE (identificationKey = %s AND Email = %s)'
        s = str(identificationKey)
        cursor.execute(_SQL, (s, Email))
        what = cursor.fetchone()
        integer = int(what[0])
        if ((integer % 2) == 0):
            booling = True
        else:
            booling = False
    return booling
コード例 #12
0
def main():
    #read input
    APMCdata = cAPMC(pd.read_csv('./data/Monthly_data_cmo.csv'))
    MSPdata = cMSP(pd.read_csv('./data/CMO_MSP_Mandi.csv'))

    dB = dataBase('socialCops')

    APMCdata.groupData()

    dB.updateDB("APMC", APMCdata.groupList)

    MSPdata.groupData()

    dB.updateDB("MSP", MSPdata.groupList)
コード例 #13
0
 def enablingButtons(self, settedId=None):
     self.nextButton.setEnabled(False)
     self.prevButton.setEnabled(False)
     
     Query.setStatTrue("select")
     Query.setSelect(["max(id)"])
     Query.setTables(["users"])
     maxId = database.dataBase().execute(Query.returnQuery())[0][0]
     
     if self.idNow == 1:
         self.nextButton.setEnabled(True)
     elif self.idNow == maxId:
         self.prevButton.setEnabled(True)
     else:
         self.nextButton.setEnabled(True)
         self.prevButton.setEnabled(True)
コード例 #14
0
def Reg(base, email, passwd, twoPass):
    if passwd == twoPass:
        with dataBase(base) as cursor:
            em = compile(
                '(\s|^)[A-Za-z0-9._-]{1,100}@[a-z]{1,10}.[a-z]{0,4}(\s|$)')
            val = em.match(email)
            if val:
                _SQL = 'INSERT INTO users(Email,password,identificationKey) VALUES( %s , %s , %s )'
                identificationKey = Rand()
                s = str(identificationKey)
                cursor.execute(_SQL, (email, passwd, s))
                return identificationKey
            else:
                return '0000000000000000000000000000000000000000000'
    else:
        return '0000000000000000000000000000000000000000000'
コード例 #15
0
 def fillFileInfo(self):
     self.setCursor(QtCore.Qt.WaitCursor)
     filename = QtGui.QFileDialog.getOpenFileName()
     if filename == u"":
         return
     infos = {"up_id":self.upid}
     EXP.mkFile(address=str(filename), infos=infos)
     
     Query.setStatTrue("select")
     Query.setSelect(["max(id)"])
     Query.setTables(["files"])
     self.id = database.dataBase().execute(Query.returnQuery())[0][0]
     self.new = False
     
     self.setCursor(QtCore.Qt.ArrowCursor)
     self.parse()
コード例 #16
0
 def fillDirInfo(self):
     self.setCursor(QtCore.Qt.WaitCursor)
     dirname = QtGui.QFileDialog.getExistingDirectory(options = QtGui.QFileDialog.ShowDirsOnly)
     if dirname == u"":
         return
     infos = {"up_id":self.upid,"dateinsert":datetime.datetime.now()}
     EXP.mkDir(address=str(dirname), infos=infos)
     
     Query.setStatTrue("select")
     Query.setSelect(["max(id)"])
     Query.setTables(["dirs"])
     self.id = database.dataBase().execute(Query.returnQuery())[0][0]
     self.new = False
     
     self.setCursor(QtCore.Qt.ArrowCursor)
     self.parse()
コード例 #17
0
def log(allStr, quantitly, size):
    if session['bool'] == True:
        road = 'logs/' + 'size=' + size + ' quantitly=' + quantitly + '.txt'
        dates = str(datetime.today().day) + "|" + str(
            datetime.today().month) + "|" + str(datetime.today().year)
        with open(road, 'a') as logs:
            print(allStr, file=logs)
            print('\n', file=logs)
        with dataBase(apps.config['base']) as cursor:
            _SQL = """INSERT INTO 
							alllogsfiles (Form,Route_addr,User_agent,Date,Time) 
							VALUES (%s,%s,%s,%s,%s)"""
            cursor.execute(_SQL, (str(request.form), str(
                request.remote_addr), str(request.user_agent), dates,
                                  str(time.strftime('%H:%M:%S %A'))))
    else:
        return render_template('Error.html')
コード例 #18
0
ファイル: bot.py プロジェクト: onlined/COWNotifier
  def __init__(self, conf, q):
    threading.Thread.__init__(self)
    self.token = conf['bot']['token']
    self.conf = conf
    self.q = q
    self.rdr = newsReader(conf['news']['host'], conf['news']['port'],
                          conf['news']['user'], conf['news']['pass'],
                          conf['news']['last'], conf['news']['auth'],
                          conf['news']['timezone'])
    self.db = dataBase(conf['db']['host'], conf['db']['user'],
                       conf['db']['pass'], conf['db']['name'], self.rdr)
    self.mention_manager = mentionManager(self.db, self)

    self.url = 'https://api.telegram.org/bot%s/' % self.token
    self.setWebhook(conf['bot']['url'] + '%s' % self.token,
                    conf['web']['pubkey'])
    self.registerHandlers()
    self.registerTexts()
コード例 #19
0
 def applyAction(self):
     infos = {}            
     infos["name"] = str(self.nameLine.text())
     infos["surname"] = str(self.surnameLine.text())
     infos["email"] = str(self.emailLine.text())
     infos["mobile"] = str(self.mobileLine.text())
     infos["home"] = str(self.homeLine.text())
     infos["work"] = str(self.workLine.text())
     infos["address"] = str(self.addressLine.toPlainText())
     if self.new:
         EXP.addUser(infos)
         
         Query.setStatTrue("select")
         Query.setSelect(["max(id)"])
         Query.setTables(["users"])
         self.idNow = database.dataBase().execute(Query.returnQuery())[0][0]
         
         self.spinId.setEnabled(True)
         self.fillInfosButton.setEnabled(True)
         self.new = False
     else:
         EXP.updateUser(self.idNow, infos)
     self.fillInfos()
コード例 #20
0
 def setButtonsStatus(self, string):
     if string == "":
         self.lendButton.setEnabled(False)
         self.reserveButton.setEnabled(False)
         self.uid = None
     else:
         if not self.statusLend and not self.statusReserve:
             self.lendButton.setEnabled(True)
         else:
             self.reserveButton.setEnabled(True)
             
         try:
             self.uid = int(self.idLine.text())
             Query.setStatTrue("select")
             Query.setSelect(["max(id)"])
             Query.setTables(["users"])
             maxId = database.dataBase().execute(Query.returnQuery())[0][0]
             if self.uid < 1 or self.uid > maxId:
                 self.uid = None
                 self.idLine.clear()
         except:
             self.uid = None
             self.idLine.clear()
コード例 #21
0
from kivymd.theming import ThemeManager
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import (
    ObjectProperty,
    ListProperty,
    StringProperty,
    NumericProperty,
    BooleanProperty,
)
from kivymd.app import MDApp
import database as DB
Data = DB.dataBase()


class ContentNavigationDrawer(BoxLayout):
    screen_manager = ObjectProperty()
    nav_drawer = ObjectProperty()


class ControlDestajo(MDApp):
    def integrante(self, NombreCompleto, NumDocumento, Sexo, FotoIntegrante,
                   FotoFirma):
        Data.AddIntegrante(NombreCompleto, NumDocumento, FotoIntegrante,
                           FotoFirma)

    def lote(self, LoteTotal, LoteFaltante, op, NumReferencia, FotoPrenda1,
             FotoPrenda2, DetalleLote, Estado):
        Data.AddLote(LoteTotal, LoteFaltante, op, NumReferencia, FotoPrenda1,
                     FotoPrenda2, DetalleLote, Estado)
コード例 #22
0
        else:
            terminal_output += "<b>Check file extension. Allowed extension are txt/csv</b>"

    return '''
    <!doctype html>
    <title>COL 341 (A2): Neural Network</title>
    <div align="center">
    <h1>Upload prediction file: Neural Network</h1>
    <form method=post enctype=multipart/form-data>
        <p><input type=file name=file>
        <input type=submit value=Upload>
        </p>
    </form>
    <p>
    %s
    <p>
    </div>
    ''' % (terminal_output)


if __name__ == '__main__':
    db = dataBase()
    app.secret_key = 'super secret key'
    g_users = set(get_users(os.path.join('./data', 'usernames')))
    targets = np.genfromtxt(os.path.join('./data', 'target_labels'))
    logging.basicConfig(level=logging.INFO)
    log = logging.getLogger("COL341-A2")
    #app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
    app.config['SESSION_TYPE'] = 'filesystem'
    app.run(host='0.0.0.0')
コード例 #23
0
    def applyAction(self):
        ddata, diff = {}, {}
        if self.new:
            self.infos = {"size":0}
            ddata["size"] = 0
        typedict = {0:"book",1:"ebook",2:"image",3:"music",4:"video",5:"other"}
        if self.type == "directory":
            ddata["name"] = str(self.dirInfoName.text())
            ddata["tags"] = str(self.dirInfoTags.text())
            ddata["description"] = str(self.dirInfoDescription.toPlainText())
            ddata["datecreate"] = self.dirInfoDateCreate.dateTime().toPyDateTime()
            ddata["datemodify"] = self.dirInfoDateModify.dateTime().toPyDateTime()
            ddata["dateaccess"] = self.dirInfoDateAccess.dateTime().toPyDateTime()
            ddata["dateinsert"] = self.dirInfoDateInsert.dateTime().toPyDateTime()
            

        elif self.type == "file":
            if self.infoSizeSpin.value() != self.infos["size"]:
                size = self.infoSizeSpin.value()
                sizemode = self.infoSizeSpin.suffix()
                modes = {u" b":1,u" Kb":1024,u" Mb":1024**2,u" Gb":1024**3}
                ddata["size"] = int(size * modes[str(sizemode)])
            
            ddata["name"] = str(self.infoNameEdit.text())
            ddata["datecreate"] = self.infoDateCreate.dateTime().toPyDateTime()
            ddata["datemodify"] = self.infoDateModify.dateTime().toPyDateTime()
            ddata["dateaccess"] = self.infoDateAccess.dateTime().toPyDateTime()
            ddata["dateinsert"] = self.infoDateInsert.dateTime().toPyDateTime()
            ddata["tags"] = str(self.infoTagsEdit.text())
            
            ddata["type"] = typedict[self.infoTypeCombo.currentIndex()]
            
            if ddata["type"] == "book":
                ddata["author"] = str(self.detailBookAuthor.text())
                ddata["imprintinfo"] = str(self.detailBookImprintInfo.text())
                ddata["callnumber"] = str(self.detailBookCallNumber.text())
                ddata["page"] = self.detailBookPageSpin.value()
                ddata["year"] = self.detailBookYearSpin.value()
                
            elif ddata["type"] == "ebook":
                ddata["author"] = str(self.detailEBookAuthor.text())
                ddata["title"] = str(self.detailEBookTitle.text())
                ddata["page"] = self.detailEBookPageSpin.value()
                ddata["year"] = self.detailEBookYearSpin.value()
                
            elif ddata["type"] == "image":
                ddata["height"] = self.detailImageHeightSpin.value()
                ddata["width"] = self.detailImageWidthSpin.value()
                
            elif ddata["type"] == "music":
                ddata["title"] = str(self.detailMusicTitle.text())
                ddata["artist"] = str(self.detailMusicArtist.text())
                ddata["album"] = str(self.detailMusicAlbum.text())
                ddata["date"] = self.detailMusicYear.value()
                ddata["tracknumber"] = self.detailMusicTrack.value()
                ddata["genre"] = str(self.detailMusicGenre.text())
                ddata["bitrate"] = self.detailMusicBitrate.value()*1000
                ddata["samplerate"] = self.detailMusicSampleRate.value()
                ddata["length"] = int(self.detailMusicLength.text())
                
            elif ddata["type"] == "video":
                ddata["title"] = str(self.detailVideoTitle.text())
                ddata["length"] = int(self.detailVideoLength.text())
                ddata["height"] = self.detailVideoHeight.value()
                ddata["width"] = self.detailVideoWidth.value()
                    
            if not self.new and ddata["type"] != self.infos["type"]:
                oldType = self.infos["type"]
                if oldType != "other":
                    Query.setStatTrue("delete")
                    Query.setTables([libilge.typeDb[oldType]])
                    Query.setWhere([{"f_id":self.id}])
                    database.dataBase().execute(Query.returnQuery())
                    
                    oldKeys = getKeys(libilge.typeDb[oldType])
                    for i in oldKeys.keys():
                        if i != "f_id":
                            self.infos.pop(i)
                        
                newType = ddata["type"]
                newKeys = getKeys(libilge.typeDb[newType])
                for i in newKeys.keys():
                    if i != "f_id":
                        self.infos[i] = newKeys[i]
                        
                dirnow = EXP.dirNow
                EXP.chDir(id=self.upid)
                EXP.update(updated=self.infos["name"],
                           parameters={"type":ddata["type"]})
                EXP.dirNow = dirnow
                
                self.infos["type"] = ddata["type"]
        
        if self.new:
            ddata["up_id"] = self.upid
            Query.setStatTrue("select")
            Query.setSelect(["max(id)"])
            
            if self.type == "file":
                EXP.mkFile(infos=ddata)
                Query.setTables(["files"])
                
            if self.type == "directory":
                EXP.mkDir(infos=ddata)
                Query.setTables(["dirs"])
                
            self.id = database.dataBase().execute(Query.returnQuery())[0][0]
            self.new = False
            
            self.infos["name"] = ddata["name"]
            
            for i in ddata.keys():
                if not i in ["name", "size", "type", "description",
                             "datecreate","datemodify", "dateaccess",
                             "dateinsert"]:
                    diff[i] = ddata[i]
        
        else:
            for i in ddata.keys():
                if ddata[i] != self.infos[i]:
                    diff[i] = ddata[i]
        
        if len(diff.keys()) > 0:
            dirnow = EXP.dirNow
            EXP.chDir(id=self.upid)
            EXP.update(updated=self.infos["name"], parameters=diff)
            EXP.dirNow = dirnow
            
        self.parse()
コード例 #24
0
ファイル: bridge.py プロジェクト: osmank3/bilge-katalog-old
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import os
import sys
import gettext
import datetime
import database

#For using unicode utf-8
reload(sys).setdefaultencoding("utf-8")

#For multilanguage support
gettext.install("bilge-katalog", unicode=1)

DB = database.dataBase()
Query = database.EditQuery()

TransKeysQuene = ["id", "name", "surname", "email", "mobile", "home", "work", 
                  "address", "size", "type", "description", "title",
                  "artist", "album", "date", "tracknumber", "genre", "bitrate",
                  "samplerate", "length", "author", "page", "year",
                  "callnumber", "imprintinfo", "width", "height", "datecreate",
                  "datemodify", "dateaccess", "dateinsert", "tags",
                  "lendstatus", "totallend", "totalreserve"]

TransKeys = {   "id"            :   _("Identify"),
                "name"          :   _("Name"),
                "surname"       :   _("Surname"),
                "email"         :   _("E-mail"),
                "mobile"        :   _("Mobile Number"),