コード例 #1
0
    def fsinit(self):
        try:
            global GlobalConfig
            self.config = ConfigFactory.GetConfigByTable(
                GetDBTable(self.dbname))
            self.config.setDB(self.dbname)
            GlobalConfig = self.config

            if (self.dbname is None):
                self.db = DBInterface(self.config)
            else:
                self.db = DBInterface(self.config, self.dbname)
        except Exception, e:
            print "Caught exception in FSINIT:", e
コード例 #2
0
    def register_email(self):
        self.password_info = self.password.get()
        self.password_entry.delete(0, END)
        self.email_info = self.email_address.get()
        self.email_address_entry.delete(0, END)

        if (isBlank(self.email_info) or isBlank(self.password_info)):
            self.empty_filler()
            self.info_regis.configure(text="Failed",
                                      justify="center",
                                      bg="white",
                                      fg="green",
                                      font=("calibri", 11))
        else:
            db = DBInterface.DBInterface()
            log = db.login(self.username_info2, self.password_info)
            data2 = json.loads(log)
            if (data2["status"] == True):
                db.update_email(self.ID_info2, self.email_info2,
                                self.email_info, self.password_info)
                pub_cmd.publish(client, "update email")
                self.info_regis.configure(text="Success Changing Email",
                                          justify="center",
                                          bg="white",
                                          fg="green",
                                          font=("calibri", 11))
            else:
                self.info_regis.configure(text="Wrong Current Password",
                                          justify="center",
                                          bg="white",
                                          fg="green",
                                          font=("calibri", 11))
コード例 #3
0
 def handle_click_notification(self):
     
     db = DBInterface.DBInterface()
     if(self.notification == "On"):
         self.notification = "Off"
         self.button_f.config(text="Current Notification" + "\n\n" + self.notification)
         pub_cmd.publish(client, "update email")
         db.switch_notification(self.ID_info2, False)
     elif (self.notification == "Off"):
         self.notification = "On"
         self.button_f.config(text="Current Notification" + "\n\n" + self.notification)
         pub_cmd.publish(client, "update email")
         db.switch_notification(self.ID_info2, True)
コード例 #4
0
ファイル: Importer.py プロジェクト: StefanoWoerner/wacot
 def __init__(self,
              dbi=None,
              xml_filename=cfg.IMPORT_XML_FILEPATH,
              xml_ns=cfg.IMPORT_XML_NS,
              category_filename=cfg.IMPORT_CATEGORY_FILEPATH,
              categorylink_filename=cfg.IMPORT_CATEGORYLINK_FILEPATH):
     if dbi is None:
         self.__dbi = DBInterface.DBInterface()
     else:
         self.__dbi = dbi
     self.xml_filename = xml_filename
     self.xml_ns = xml_ns
     self.category_filename = category_filename
     self.categorylink_filename = categorylink_filename
コード例 #5
0
    def register_pass(self):
        self.password_info = self.password.get()
        self.password_entry.delete(0, END)
        self.password_info2 = self.password2.get()
        self.password_entry2.delete(0, END)

        if(isBlank(self.password_info) or isBlank(self.password_info2)):
            self.empty_filler()
            self.info_regis.configure(text="Failed", justify = "center", bg = "white", fg="deep sky blue", font=("calibri", 11))
        else:
            db = DBInterface.DBInterface()
            log = db.login(self.username_info2, self.password_info)
            data2 = json.loads(log)
            if(data2["status"] == True):
                db.update_password(self.ID_info2, self.password_info, self.password_info2)
                self.info_regis.configure(text="Success Changing Password", justify = "center", bg = "white", fg="deep sky blue", font=("calibri", 11))
            else:
                self.info_regis.configure(text="Wrong Current Password", justify = "center", bg = "white", fg="deep sky blue", font=("calibri", 11))
コード例 #6
0
def login_verify():

    username1 = username_verify.get()
    password1 = password_verify.get()
    username_login_entry.delete(0, END)
    password_login_entry.delete(0, END)

    global data2
    db = DBInterface.DBInterface()
    log = db.login(username1, password1)
    data2 = json.loads(log)

    if (data2["status"] == True):
        global check
        data2["username"] = username1
        login_sucess()
        check = True
    else:
        user_and_password_not_recognised()
コード例 #7
0
 def __init__(self,
              dbi=None,
              update=cfg.COAUTH_UPDATE,
              limit=cfg.COAUTH_LIMIT,
              interval_size=cfg.COAUTH_INTERVAL_SIZE,
              initial_interval_size=cfg.COAUTH_INITIAL_INTERVAL_SIZE,
              initial_offset=cfg.COAUTH_INITIAL_OFFSET,
              count_power=cfg.COAUTH_COUNT_POWER,
              time_power=cfg.COAUTH_TIME_POWER):
     if dbi is None:
         self.__dbi = DBInterface.DBInterface()
     else:
         self.__dbi = dbi
     self.update = update
     self.limit = limit
     self.interval_size = interval_size
     self.initial_interval_size = initial_interval_size
     self.initial_offset = initial_offset
     self.count_power = count_power
     self.time_power = time_power
コード例 #8
0
def register_user():

    username_info = username.get()
    password_info = password.get()
    email_info = email_address.get()

    username_entry.delete(0, END)
    password_entry.delete(0, END)
    email_address_entry.delete(0, END)

    db = DBInterface.DBInterface()

    if (isBlank(username_info) or isBlank(password_info)
            or isBlank(email_info)):
        empty_filler()
        info_regis.configure(text="Registration Failed",
                             justify="center",
                             bg="white",
                             fg="green",
                             font=("calibri", 11))
    else:
        reg = db.register(username_info, email_info, password_info)
        data = json.loads(reg)

        if (data["status"] == True):
            pub_cmd.publish(client, "update email")
            info_regis.configure(text="Registration Success",
                                 justify="center",
                                 bg="white",
                                 fg="green",
                                 font=("calibri", 11))
        else:
            user_info_exist(data["err"])
            info_regis.configure(text="Registration Failed",
                                 justify="center",
                                 bg="white",
                                 fg="green",
                                 font=("calibri", 11))
コード例 #9
0
#!/bin/env python

from Config import *
from DBInterface import *

db = DBInterface("cds.db", AudioConfig)

print db.getEntries({}, ["genre"], True)
コード例 #10
0
 def __init__(self, dbi=None, human_bot_threshold=cfg.HUMAN_BOT_THRESHOLD):
     if dbi is None:
         self.__dbi = DBInterface.DBInterface()
     else:
         self.__dbi = dbi
     self.human_bot_threshold = human_bot_threshold
コード例 #11
0
import pandas
import time

from playUSpider import *
from DBInterface import *
from DataAnalysis import *
from datetime import datetime

if __name__ == "__main__":
    playU = playUSpider()
    playU = playU.contentList()
    DBInterface = DBInterface()

    # 補上忘記跑的檢查資料庫的部分
    DBInterface.check_db_and_table()

    DataAnalysis = DataAnalysis()

    # get something on PlayU and put into DataPack. by.可愛的下畫線亞裔黑白相間的熊
    for item in playU:
        DBInterface.storeContent(item.get('title'), item.get('description'), datetime.strptime(item.get('date'), '%B %d, %Y'), item.get('readtime'))

    # 把東西全都Print到Console上

    # print(DBInterface.getContent()) # SELECT * FROM table_

    # print(DataAnalysis.pandaEatData()) # pandas parsed table_

    # print(DataAnalysis.andlyseReadtime())

    # 來正經的做資料輸出
コード例 #12
0
 def __init__(self, db_path: str):
     self.db_interface = DBInterface.DBInterface(db_path)
     self.communicator = Communicator.Communicator(self.db_interface)
     # @TODO Check if communicator is working, else disable API features but work otherwise
     self.model = Model.Model(self.db_interface)
コード例 #13
0
def test_db_connection():
    d = DBInterface()
    d.connect()
    pass
コード例 #14
0
ファイル: app.py プロジェクト: QuasarX1/Shallow-Blue
# Specific Imports---------------------------------------------------------------------------------------------------------
from flask import Flask, render_template, redirect, url_for, session, flash, send_from_directory
from functools import wraps

# Creating the Flask object------------------------------------------------------------------------------------------------
app = Flask(__name__)

# Adding the app config data
app.config["SECRET_KEY"] = ""
for i in range(0, 10):
    app.config["SECRET_KEY"] += string.printable[random.SystemRandom().randint(0, len(string.printable) - 1)]

# Creating the database object---------------------------------------------------------------------------------------------
rootDirectory = os.path.dirname(__file__)
database = DBInterface.DBInterface(os.path.join(rootDirectory, "Data/DatabaseLocation.txt"), rootDirectory)

# Make the WSGI interface available at the top level so wfastcgi can get it
wsgi_app = app.wsgi_app

# Custom Decorators---------------------------------------------------------------------------------------------------------
def testLogin(func):
    @wraps(func)# Used to preserve the 'signiture' of the function when it is added to app
    def wrapper(*args, **kwargs):
        loggedIn = False

        if "userID" in session:
            loggedIn = True

        return func(loggedIn, *args, **kwargs)
コード例 #15
0
# Get the database name
def usage(prog):
    print "Usage: %s dbfile" % progname
    sys.exit(1)


import sys
from Config import *
from DBInterface import *
progname = sys.argv[0]
if (len(sys.argv) < 2):
    usage(progname)

dbname = sys.argv[1]
config = ConfigFactory.GetConfigByTable(GetDBTable(dbname))
db = DBInterface(config, dbname)
cols = config.getSettableCols()
files = [entr[0] for entr in db.getEntries({}, ["filename"])]

root = Tk()
root.protocol("WM_DELETE_WINDOW", cleanup)
root.title("Set Database Tags (v0.1)")

# create Menu
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=cleanup)
menubar.add_cascade(label="File", menu=filemenu)
root.config(menu=menubar)
コード例 #16
0
 def __init__(self, db_path: str):
     self.db_interface = DBInterface.DBInterface(db_path)
     self.communicator = self._make_communicator()
     self._commit_new_token(
     )  # Instantiating communicator means new refresh token
コード例 #17
0
#!/bin/env python

from Config import *
from DBInterface import *

config = Config("InfoTable", Config.Audio)

db = DBInterface(":memory:", config)
db.clear()
db.printStats()

###
from TagLoader import *
l = TagLoaderFactory.GetLoader("zztop.flac")
entry = l.getTags("zztop.flac")
db.addEntries((entry, ))
###
db.printStats()
db.dumpDB()

print db.getEntries({})
fname = {}
fname["filename"] = "zztop.flac"
print db.getEntries(fname)
print db.getEntries(fname, ["album"])

fname["filename"] = "fump.mp3"
print db.getEntries(fname)
コード例 #18
0
entry1DB = {"filename": SimpleDBValue("/filename1")}

entry2 = {
    "filename": "/filename2",
    "title": "title2",
    "artist": "artist2",
    "album": "album2",
    "year": "year2",
    "genre": "genre2",
    "track": "track2",
    "format": "format2"
}
entry2DB = {"filename": SimpleDBValue("/filename2")}

config = AudioConfig()
db = DBInterface(config, dbfile)
db.clear()

# Call addEntry for an entry
db.addEntries((entry1, ), config.mainTable.getName())

# Call getentry, ensure entry matches entry1
res = db.getEntries(entry1DB, entry1.keys())
if (verifyEntry(res[0], entry1)):
    print "-------> Initial add okay."

# Call updateoraddEntries for the given entry
db.updateOrAddEntries(table=config.mainTable.getName(),
                      match_tag=entry1DB,
                      entries=(entry15, ))
コード例 #19
0
'''This module contains classes used by pool core to interact with the rest of the pool.
   Default implementation do almost nothing, you probably want to override these classes
   and customize references to interface instances in your launcher.
   (see launcher_demo.tac for an example).
'''
import time
from twisted.internet import reactor, defer
from lib.util import b58encode

import lib.settings as settings
import lib.logger
log = lib.logger.get_logger('interfaces')

import DBInterface
dbi = DBInterface.DBInterface()
dbi.init_main()

class WorkerManagerInterface(object):
    def __init__(self):
        self.worker_log = {}
        self.worker_log.setdefault('authorized', {})
        self.job_log = {}
        self.job_log.setdefault('None', {})
        return

    def authorize(self, worker_name, worker_password):
        # Important NOTE: This is called on EVERY submitted share. So you'll need caching!!!
        return dbi.check_password(worker_name, worker_password)

    def get_user_difficulty(self, worker_name):
        wd = dbi.get_user(worker_name)
コード例 #20
0
ファイル: dbi_testing.py プロジェクト: kenryhou2/Team6
def main():
    # Create DBInterface object
    dbi = DBInterface.DBInterface()

    # Correct user info
    raw = dbi.login(user="******", pswd="test")
    data = json.loads(raw)
    print("correct_login: "******"\n")

    # Incorrect username
    raw = dbi.login(user="******", pswd="test")
    data = json.loads(raw)
    print("incorrect_login_username: "******"\n")

    # Incorrect password
    raw = dbi.login(user="******", pswd="incorrect_pswd")
    data = json.loads(raw)
    print("incorrect_login_password: "******"\n")

    # Username and email taken
    raw = dbi.register(user="******",
                       email="*****@*****.**",
                       pswd="temp")
    data = json.loads(raw)
    print("failed_register_username_email_taken: " + str(data) + "\n")

    # Username taken
    raw = dbi.register(user="******", email="*****@*****.**", pswd="temp")
    data = json.loads(raw)
    print("failed_register_username_taken: " + str(data) + "\n")

    # Email taken
    raw = dbi.register(user="******", email="*****@*****.**", pswd="temp")
    data = json.loads(raw)
    print("failed_register_email_taken: " + str(data) + "\n")

    # Good register
    user = ''.join(random.choice(string.ascii_lowercase) for i in range(10))
    email = ''.join(random.choice(string.ascii_lowercase) for i in range(10))
    pswd = ''.join(random.choice(string.ascii_lowercase) for i in range(10))
    raw = dbi.register(user=user, email=email, pswd=pswd)
    data = json.loads(raw)
    print("good_register: " + str(data) + "\n")

    # Login with new account
    raw = dbi.login(user=user, pswd=pswd)
    data = json.loads(raw)
    print("login_with_new_account: " + str(data) + "\n")
    iD = data['id']
    notif = data['notification']

    # Update with wrong password
    new_user = ''.join(
        random.choice(string.ascii_lowercase) for i in range(10))
    raw = dbi.update_username(iD=iD,
                              old_user=user,
                              new_user=new_user,
                              pswd="wrong")
    data = json.loads(raw)
    print("update_wrong_pass: "******"\n")

    # Update username
    new_user = ''.join(
        random.choice(string.ascii_lowercase) for i in range(10))
    raw = dbi.update_username(iD=iD,
                              old_user=user,
                              new_user=new_user,
                              pswd=pswd)
    data = json.loads(raw)
    print("update_username: "******"\n")

    # Update email
    new_email = ''.join(
        random.choice(string.ascii_lowercase) for i in range(10))
    raw = dbi.update_email(iD=iD,
                           old_email=email,
                           new_email=new_email,
                           pswd=pswd)
    data = json.loads(raw)
    print("update_email: " + str(data) + "\n")

    # Update password
    new_pswd = ''.join(
        random.choice(string.ascii_lowercase) for i in range(10))
    raw = dbi.update_password(iD=iD, old_pswd=pswd, new_pswd=new_pswd)
    data = json.loads(raw)
    print("update_password " + str(data) + "\n")

    # Switch notifcation
    raw = dbi.switch_notification(iD=iD, notification=(not notif))
    data = json.loads(raw)
    print("switch_notification " + str(data) + "\n")

    # Login with updated credentials.
    raw = dbi.login(user=new_user, pswd=new_pswd)
    data = json.loads(raw)
    print("login_updated: " + str(data) + "\n")