Пример #1
0
 def download_data(cls,
                   freq,
                   instr,
                   symbols=None,
                   country=None,
                   outputsize=None,
                   start=None):
     av = cls.get_av_instance(freq, instr)
     if country is not None:
         raw_data = SQL.get_symbols_per_country(country)
         symbols = [item[0] for item in raw_data]
     for symbol in symbols:
         try:
             param = av.get_api_query(freq, symbol, outputsize)
             print('Downloading ' + symbol + ' data')
             json = av.download_json(param, symbol)
             print(symbol + ' data downloaded')
             data = av.generate_tuple(json, symbol, instr, freq)
             data = av.tz_to_utc(data)
             SQL.insert_price_data(data, freq)
             print(symbol + ' data inserted in database')
         except NameError:
             print('Symbol ' + symbol +
                   ' does not exist in Alpha Vantage database')
             time.sleep(1)
     SQL.remove_price_duplicates(freq)
     print('Duplicates removed')
     print('Done')
Пример #2
0
class Survey_Info(object):
    def __init__(self, siteid):
        """
		Survey information for siteid
		"""
        self.db = SQL()
        self.siteid = siteid

    def get_dic(self, code):
        """
		Reads preparer values from json
		Inserts code and json values into dictionary
		"""
        dic = self.db.get_site_dic(self.siteid)

        with open(self.db.get_json_file(self.siteid), 'r') as fpu:
            preparer = json.load(fpu)

        for dv in dic.values():
            if isinstance(dv, dict):
                for k, v in dv.items():
                    if v == vl.json_code:
                        dv[k] = code
                    if v == vl.json_first_name:
                        dv[k] = preparer[vl.json_first_name]
                    elif v == vl.json_last_name:
                        dv[k] = preparer[vl.json_last_name]
                    elif v == vl.json_email:
                        dv[k] = preparer[vl.json_email]
                    elif v == vl.json_phone_number:
                        dv[k] = preparer[vl.json_phone_number]
                    elif v == vl.json_postal_code:
                        dv[k] = preparer[vl.json_postal_code]

        return dic
Пример #3
0
def load_by_id(home_username, friend_id):
    sql_instance = SQL()
    result = sql_instance.get_individual_friend_by_id(home_username, friend_id)
    return Friend(username=result[0],
                  user_id=result[1],
                  first_name=result[2],
                  last_name=result[3])
Пример #4
0
 def _is_registered(self):
     sql = SQL()
     sql._query_("SELECT user, password FROM user WHERE user_id = '" + str(self.uid) + "'")
     data = sql.get_last_result()
     if data is not None:
         return True
     return False
Пример #5
0
class Trabajadores(trabajadores.Ui_Dialog,
                 QDialog):
    def __init__(self):
        super(Trabajadores, self).__init__()
        self.setupUi(self)
        """
        self.tableWidget.setRowCount(10)
        self.tableWidget.setColumnCount(10)
        """
        self.trabajadores = SQL().personalShift
        self.__row = 0
        self.tableWidget.setRowCount(len(self.trabajadores.keys()))
        for t, sch in self.trabajadores.items():
            self.append([t, sch.capitalize()])

    def append(self, item, column=0, table=None):
        if type(item) == list:
            for i in item:
                newItem = QTableWidgetItem(i)
                self.tableWidget.setItem(self.__row, column, newItem)
                column += 1
            index_increment = 1
        else:
            newItem = QTableWidgetItem(item)
            index_increment = 1
            self.tableWidget.setItem(self.__row, column, newItem)
        self.__row += index_increment
Пример #6
0
def remove_price_duplicates(freq):
    """
    :param freq: price frequency of the price table to be cleaned
    Remove the duplicates entries of the price table
    """
    SQL.remove_price_duplicates(freq)
    print('Duplicates removed')
Пример #7
0
 def get_info(self, symbol):
     """
     Provides additional info to be inserted in the price data tuple
     """
     dv_id = SQL.get_data_vendor_id(self.name)
     symbol_id = SQL.get_symbol_id(symbol)
     now = dt.datetime.now()
     return dv_id, symbol_id, now
Пример #8
0
 def __init__(self):
     SQL.__init__(self)
     self.hostname = get_config('postgresql_host', 'localhost')
     self.port = get_config('postgresql_port', '5432')
     self.username = get_config('postgresql_user', 'postgres')
     self.password = get_config('postgresql_pass', 'postgres')
     self.dbname = get_config('postgresql_db', 'syscall_popularity')
     self.db = None
     self.tables = []
Пример #9
0
 def register(self, data):
     # Parse input into dict, so we know all values are correctly specified
     dat = dict()
     for x in range(0, len(data), 2):
         dat[data[x]] = data[x+1]
     # Begin with the process
     sql = SQL()
     query = "SELECT registrar(" + str(self.uid) + ", '" + dat['user'] + "','" + dat['password'] + "')"
     return sql.function(query)
Пример #10
0
def delete_user():
    a = items['delete_number']
    delete_number = a.get()
    label = items['delete_label']
    if delete_number != '':

        SQL().user_operation(number=delete_number, delete=True)
        items['delete_number'].delete(0, last='end')
        label.config(text=delete_number + ' Успешно удален', fg='green')
        print(SQL().get_users())
Пример #11
0
 def __init__(self):
     self.table_name = 'admins'
     self.sql = SQL()
     self.id = None
     self.account = None
     self.password = None
     self.power = None
     self.phone = None
     self.email = None
     self.info = None
Пример #12
0
def newQuery():
    sql = SQL()
    sql.connect()
    data = request.get_json()
    if "currQuery" not in session:
        session["currQuery"] = ""
    oldQuery = session["currQuery"]
    newData = driver.new_tables(sql, oldQuery, data)
    session["currQuery"] = newData["currentQuery"]
    return jsonify(newData)
Пример #13
0
def fill_simulated_kiln(size):
    kiln_state = []
    wasted_fraction = []
    firing_cycle = SQL().get_best_firing_cycle(mode='LEFT_TO_SIMULATE')
    for x in range(1, 8):
        state, fraction = fill_simulated_shelf(x, firing_cycle, size)
        kiln_state.append(state)
        wasted_fraction.append(fraction)
        with SQL() as sql:
            for a, b in state.iteritems():
                sql.add_to_moulding_order(a, b)
Пример #14
0
def load_all_friends(home_username):
    sql_instance = SQL()
    results = sql_instance.get_friends(username=home_username)
    friends = []
    for friend in results:
        friends.append(
            Friend(username=friend[0],
                   user_id=friend[1],
                   first_name=friend[2],
                   last_name=friend[3]))
    return friends
Пример #15
0
def fire_wheels():
    next_kiln = SQL().get_setting('LAST_REAL_KILN_USED')
    while True:
        next_kiln = get_next_kiln(next_kiln)
        params = SQL().get_kiln_params(next_kiln)
        if int(params[1]) > 0:
            break
    fill_kiln(params[3])
    with SQL() as s:
        s.update_kiln_column_value(next_kiln, 'RUNS_LEFT', int(params[2]) - 1)

    with SQL() as s:
        s.update_setting('LAST_REAl_KILN_USED', next_kiln)
Пример #16
0
def getTable():
    sql = SQL()
    sql.connect()
    data = request.get_json()

    print(data)
    tableName = data["table"]
    page = int(data['page'])
    if "currQuery" not in session:
        session["currQuery"] = ""
    query = session["currQuery"]
    tableData = driver.get_table(sql, query, page, tableName)
    return jsonify(tableData)
Пример #17
0
    def __init__(self, siteid, headless=False):
        """
		class Survey
		"""
        self.db = SQL()
        self.siteid = siteid
        self.headless = headless
        self.file_path = os.path.dirname(os.path.abspath(__file__))

        if self.db.validate_site_info(self.siteid):
            self.url = self.db.get_site_url(siteid)
            self.json_file = self.db.get_json_file(siteid)
            self.init_driver()
            self.run()

        self.__del__()
Пример #18
0
 def update_data(self, data):
     # Parse input into dict, so we know all values are correctly specified
     values = dict()
     for x in range(0, len(data), 2):
         values[data[x]] = data[x+1]
     # Begin with the process
     query = "SELECT actualiza(" + str(self.uid)
     if 'user' in values and 'password' in values:
         query += ", '" + values['user'] + "','" + values['password'] + "')"
     elif 'user' in values:
         query += ", '" + values['user'] + "', NULL)"
     elif 'password' in values:
         query += ", NULL, '" + values['password'] + "')"
     else:
         query += ", NULL, NULL)"
     sql = SQL()
     return sql.function(query)
Пример #19
0
 def download_data(cls, freq, instr, symbols, outputsize=None, start=None):
     po = Poloniex()
     for symbol in symbols:
         try:
             param = cls.get_api_query(freq, symbol, start)
             print('Downloading ' + symbol + ' data')
             json = po.download_json(param, symbol)
             print(symbol + ' data downloaded')
             data = po.generate_tuple(json, symbol, instr, freq)
             SQL.insert_price_data(data, freq)
             print(symbol + ' data inserted in database')
         except NameError:
             print('Error while querying ' + symbol)
             time.sleep(1)
     SQL.remove_price_duplicates(freq)
     print('Duplicates removed')
     print('Done')
Пример #20
0
    def __init__(self):
        database = SQL()
        database.loadChekInOutTable()

        self.matriz = database.data_matrix
        self.personal = sorted(jornada_personal.keys())
        dates = database.dates
        self.dates = [d for d in dates if d > datetime.date(2014, 1, 1)]
        self.start_date = self.dates[0]
        self.stop_date = self.dates[-1]
        self.exceptions = None
        self.workers_not_found = None
        self.days_of_work = {}  # contendrá los días de trabajo del archivo empaquetados en la clase Workday
        self.validateCheck()
        self.content = ()
        self.thisday = DiasNoLaborables()
        self.organizar_por_fecha()
Пример #21
0
def PayChecker():
    while True:
        users_db = SQL('users.db')
        paylist = users_db.SelectPayUsers()
        for i in paylist:
            cht_id = i[0]
            if (float(i[3]) * 10**-8) >= (float(i[6].split('_')[3])):
                try:
                    paidout_value = str(
                        round(float(i[6].split('_')[3]) * 10**8) - 10)
                    print(paidout_value)
                    url = 'https://bitaps.com/api/use/redeemcode'
                    parameters = {
                        'redeemcode': str(i[2]),
                        'address': btc_adress,
                        'amount': 'All available',
                        'custom_fee': '50'
                    }
                    response = requests.post(url, data=json.dumps(parameters))
                    print(response.text)

                    tg.send_message(chat_id=i[0],
                                    text='Payment received. Your adress: ')
                    temp = i[6].split('_')
                    f = open('text.txt', 'r+')
                    sold = open('sold.txt', 'a')
                    count = len(f.readlines())
                    f.seek(0)
                    for j in range(count):
                        line = f.readline()
                        if line.split('|')[:3] == temp[:3]:
                            f.seek(int(f.tell()) - len(line) - 1)
                            f.write(' ' * (len(line) - 1))
                            f.write('\n')
                            sold.write(line[:-1] + '* -' + time.ctime() + '\n')
                            sold.close()
                            tg.send_message(chat_id=cht_id, text=str(line))
                            f.close()
                            users_db.EditPayStatus(cht_id, 5)
                            break
                except Exception as e:
                    tg.send_message(chat_id=i[0], text=e)

        print('PAYCHECK')
        time.sleep(10)
Пример #22
0
def add_user():

    name = items['name'].get()
    user_id = items['id'].get()
    number = items['number'].get()
    label = items['text_label']
    if name != '' and user_id != '' and number != '':
        result = SQL().user_operation(user_id, name, number)

        if result:
            print(SQL().get_users())
            label.config(text='Новый пользователь ' + result + ' добавлен',
                         fg='green')
            SQL().get_users()
        else:
            label.config(text='Такой пользователь уже есть ', fg='red')
    else:
        label.config(text='Не все поля заполнены')
Пример #23
0
    def work_with_bonus(self, label, entry):

        result = SQL().get_user(number=entry.get())
        print(result)
        if not result:
            label.config(text='Такого пользователя нет')
            return 0
        else:
            label.config(text='Пользователь найден')
Пример #24
0
 def __init__(self):
     self.table_name = 'articles'
     self.sql = SQL()
     self.tags = [('NOTICE', '通知'), ('SHOW', '展示'), ('EXP', '经验'),
                  ('LOG', '日志')]
     self.flags = [('ONLINE', '在线发布文档'), ('OFFLINE', '离线发布文档'),
                   ('SYSTEM', '系统文档'), ('BACKUP', '备份文档')]
     self.id = None
     self.title = None
     self.author = None
     self.tag = None
     self.flag = None
     self.create_time = None
     self.update_time = None
     self.txt_markdown = None
     self.txt_html = None
     self.reading_times = None
     self.admin_id = None
Пример #25
0
    def test_insertTickerData(self):
        from sql import SQL
        s = SQL()
        s.connect()
        r = s.insertTickerData("TEST", 123.34, 1000, "2017-11-24 13:00:00")
        s.close()

        self.assertEqual(r, 1)
Пример #26
0
def fill_kiln(size):
    kiln_state = []
    wasted_fraction = []
    firing_cycle = SQL().get_best_firing_cycle(mode='MOULDED')
    for x in range(1, 8):
        state, fraction = fill_shelf(x, firing_cycle, size)
        kiln_state.append(state)
        wasted_fraction.append(fraction)
    #print kiln_state, wasted_fraction
    return kiln_state
Пример #27
0
 def start(self):
     try:
         SQL.add_user(self.user_id)
         SQL.add_category('other',
                          self.user_id)  # для несортированных расходов
         SQL.add_category('income', self.user_id)  # для доходов
         SQL.add_category('fixed_income',
                          self.user_id)  # для постоянных доходов
     except Exception:
         print("Unsuccessful, undefined error")
         return 0
     else:
         return 1
Пример #28
0
def api_symbol_check(country=None, input_symbols=None):
    if country is not None:
        raw_data = SQL.get_symbols_per_country(country)
        symbols = [item[0] for item in raw_data]
        for symbol in symbols:
            if symbol not in ['AC.PA', 'AI.PA', 'AIR.PA', 'AMS:MT', 'ATO.PA', 'CS.PA', 'BNP.PA', 'EN.PA', 'CAP.PA',
                              'CA.PA', 'ACA.PA', 'BN.PA', 'ENGI.PA', 'EI.PA', 'KER.PA', 'OR.PA', 'VTX:LHN', 'LR.PA',
                              'MC.PA', 'ML.PA', 'ORA.PA', 'RI.PA', 'UG.PA', 'PUB.PA', 'RNO.PA', 'SAF.PA', 'SGO.PA',
                              'SAN.PA', 'SU.PA', 'GLE.PA', 'SW.PA', 'SOLB.PA', 'STM.PA', 'FTI.PA', 'FP.PA', 'AMS:UL',
                              'FR.PA', 'VIE.PA', 'DG.PA', 'VIV.PA']:
                import_data('Alpha Vantage', '1min', 'stock', [symbol], 'compact')
Пример #29
0
 def __init__(self):
     super(Trabajadores, self).__init__()
     self.setupUi(self)
     """
     self.tableWidget.setRowCount(10)
     self.tableWidget.setColumnCount(10)
     """
     self.trabajadores = SQL().personalShift
     self.__row = 0
     self.tableWidget.setRowCount(len(self.trabajadores.keys()))
     for t, sch in self.trabajadores.items():
         self.append([t, sch.capitalize()])
Пример #30
0
 def __init__(self):
     # Подключение SQL сервера, инициализация UI.
     self.SQL_server, self.app = SQL('Diary'), QtWidgets.QApplication(sys.argv)
     self.cursor, self.entered, self.main_window, self.ui, self.is_student, self.id, self.month_id = \
         self.SQL_server.conn.cursor(), False, QtWidgets.QMainWindow(), \
         Ui_Login(), True, 0, datetime.now().month
     self.ui.setupUi(self.main_window)
     self.main_window.show()
     self.ui.button_enter.clicked.connect(self.login_button_pressed)
     self.ui.button_register.clicked.connect(lambda: webbrowser.open("https://docs.google.com/forms/d/17OsG-ncuNbhOrxpRrUZKgSHclN2EpyKTEvcKgew-fng"))
     locale.setlocale(locale.LC_ALL, ('RU', 'UTF8'))
     self.main()
Пример #31
0
def update_kiln_data():
    from sql import SQL
    import openpyxl
    wb = openpyxl.load_workbook('settings/kiln.xlsx')
    sh = wb.active

    with SQL() as sql:
        sql.delete_kiln_data()
        for x in range(2, sh.max_row + 1):
            sql.add_kiln_params(
                sh.cell(row=x, column=1).value,
                sh.cell(row=x, column=2).value,
                sh.cell(row=x, column=3).value)
Пример #32
0
 def get_users(self):
     conn = sqlite3.connect(DATABASE_LOCATION)
     bliss = SQL(conn)
     member_groups = bliss.all("SELECT group_id FROM node_group_links WHERE node_id=?", (self.node_id, ))
     allowed_ids = []
     for m in member_groups:
         for u in bliss.all("SELECT user_id FROM node_group_permissions WHERE node_group_id=?", (m, )):
             allowed_ids.append(bliss.one("SELECT access_id FROM users WHERE id=?", (u, )))
     for u in bliss.all("SELECT user_id FROM node_permissions WHERE node_id=?", (self.node_id, )):
         allowed_ids.append(bliss.one("SELECT access_id FROM users WHERE id=?", (u,)))
     return allowed_ids
Пример #33
0
 def loadBots(hash):
     # Load all bots matching hash
     bots = []
     s = SQL()
     s.connect()
     rows = s.fetchBots(hash)
     for r in rows:
         #print("LOAD bot " + r['name'] + " --> " + r['data'])
         lb = LongBot(r['name'], r['data'])
         bots.append(lb)
     s.close()
     return bots
Пример #34
0
    def update_results(self):
        with SQL() as sql:
            orders = sql.get_moulding_order()
        if self.results_frame:
            self.results_frame.destroy()

        self.results_frame = table.DrawTable(self, len(orders), 2)
        self.results_frame.pack(side="top", fill="x")

        row = 0
        for x in orders:
            for i in range(0, 2):
                self.results_frame.set(row, i, x[i])
            row += 1
Пример #35
0
    def fetch(freq):
        fCnt = 0
        if freq in ("hourly", "daily"):
            # Do daily stuff
            try:
                s = SQL()
                s.connect()
                rows = s.fetchFromSource(freq)
                http = urllib3.PoolManager()
                #print("Fetch sources" + str(len(rows)))
                for r in rows:
                    try:
                        cache = None
                        try:
                            cache = LongBot.getData(r['url'])
                        except Exception as e:
                            #print("Not in cache i guess")
                            None

                        if not cache:
                            print("INFO\tNot cached, loading " + r['url'])
                            res = http.request('GET', r['url'])
                            if res.status == 200:
                                Processor = getattr(
                                    importlib.import_module("process_" +
                                                            r['handler']),
                                    "Processor")
                                pres = Processor.process(str(res._body))
                                print(str(pres))
                                if pres['valid']:
                                    LongBot.setData(pres['ticker'],
                                                    pres['last'])
                                    fCnt = fCnt + 1
                                    LongBot.setData(r['url'], True)
                            else:
                                print("WARN\tCould not download from " +
                                      r['url'])
                                print(str(res._body))
                        else:
                            print("INFO\tCached, not loading " + r['url'])
                            fCnt = fCnt + 1
                    except Exception as e:
                        print("ERROR\t" + r['name'] + "\t" + str(e))
                http.clear()
            except Exception as e:
                print(str(e))
            finally:
                s.close()
        return fCnt
Пример #36
0
def BalanceUpdater():
    while True:
        users_db = SQL('users.db')
        paylist = users_db.SelectAllUsers()
        for i in paylist:
            users_db.UpdateBalance(i[0], i[2])
            if users_db.GetUser(i[0])[4] > i[4]:
                tg.send_message(chat_id=i[0], text='Payment recived.')
                users_db.EditPayStatus(i[0], 2)
        print('BALANCECHECK')
        time.sleep(15)
Пример #37
0
class YubiServeHandler:
    def __init__(self, sql_connection, params, vclass):
        self.sql = SQL(sql_connection)
        self.params = params
        self.vclass = vclass

    def sign_message(self, answer, api_key):
        data = ['%s=%s' % (k, v) for (k, v) in answer.iteritems()]
        data.sort()
        data = '&'.join(data)

        otp_hmac = hmac.new(api_key, str(data), hashlib.sha1)
        otp_hmac = base64.b64encode(otp_hmac.digest())

        return otp_hmac

    def build_answer(self, stat, answer, api_key=''):
        answer['status'] = stat
        answer['h'] = self.sign_message(answer, api_key)

        data = '\r\n'.join(['%s=%s' % (k, v) for (k, v) in answer.iteritems()])
        data += '\r\n'

        return data

    def do_validate(self):
        answer = {'t': time.strftime("%Y-%m-%dT%H:%M:%S"), 'otp': ''}

        # API id and OTP are required
        if 'id' not in self.params or 'otp' not in self.params:
            return self.build_answer(status.MISSING_PARAMETER, answer)

        # ensure API id is valid
        if not self.sql.select('get_api_secret', [self.params['id']]):
            return self.build_answer(status.NO_SUCH_CLIENT, answer)

        api_key = base64.b64decode(self.sql.result[0])

        # do token validation
        vclass = self.vclass(self.sql)
        stat = vclass.set_params(self.params, answer)
        if stat == status.OK:
            stat = vclass.validate()
        return self.build_answer(stat, answer, api_key)
Пример #38
0
    def __init__(self, driver, uri=None, connection=None):  # FIXME ugly hack
        """Initializing function

        driver (string) - either 'SQLITE' or 'LDAP'
        uri (string) - OPTIONAL The location of the SQLITE databse file or the
            LDAP uri
        connection (object) - OPTIONAL SQL Connection
        """
        self.driver = driver
        if driver not in self.__drivers:
            self.driver = 'SQLITE'

        if self.driver == 'SQLITE' and not connection:
            sql_connection = connect_to_db(uri)
            self.sql = SQL(sql_connection)
        elif self.driver == 'SQLITE' and connection:
            self.sql = connection
        elif self.driver == 'LDAP':
            self.ldap = LDAPConnection()
Пример #39
0
 def show_grades(self):
     sql = SQL()
     sql._query_("SELECT user, password FROM user WHERE user_id = '" + str(self.uid) + "'")
     data = sql.get_last_result()
     self.sii.set_userdata(data['user'], data['password'])
     return self.sii.get_grades()
Пример #40
0
 def delete(self):
     query = 'SELECT eliminar(' + str(self.uid) + ')'
     sql = SQL()
     return sql.function(query)
Пример #41
0
class Backend(object):

    __drivers = ['SQLITE', 'LDAP']

    def __init__(self, driver, uri=None, connection=None):  # FIXME ugly hack
        """Initializing function

        driver (string) - either 'SQLITE' or 'LDAP'
        uri (string) - OPTIONAL The location of the SQLITE databse file or the
            LDAP uri
        connection (object) - OPTIONAL SQL Connection
        """
        self.driver = driver
        if driver not in self.__drivers:
            self.driver = 'SQLITE'

        if self.driver == 'SQLITE' and not connection:
            sql_connection = connect_to_db(uri)
            self.sql = SQL(sql_connection)
        elif self.driver == 'SQLITE' and connection:
            self.sql = connection
        elif self.driver == 'LDAP':
            self.ldap = LDAPConnection()

    def get_key(self, userid):
        """Function that fetches the aeskey, internalname, counter and timestamp
        from the data storage.

        Params:
            userid (string)  - the userid (keyid) extracted from the OTP

        Returns:
            key (tuple) - (aeskey, internalname, counter, time) if the supplied
                userid matches an entry in the Data Storage
        """
        if self.driver == 'SQLITE':
            if not self.sql.select('yubico_get_key', [userid]):
                return status.BAD_OTP
            aeskey, internalname, counter, time = self.sql.result
        elif self.driver == 'LDAP':
            dn, entry = self.ldap.search('yubico_get_key', [userid])[0]
            aeskey = entry['aeskey'][0]
            internalname = entry['internalname'][0]
            counter = int(entry['counter'][0])
            time = int(entry['time'][0])

        return (aeskey, internalname, counter, time)

    def update_counter(self, count, timestamp, userid):
        """Function that updates the counter in the data.

        Params:
            count (int) - the new count to updated
            timestamp (int) - the timestamp from the otp
            userid (string) - the userid for the key for which the counter has
                to be updated.
        """
        if self.driver == 'SQLITE':
            self.sql.update('yubico_update_counter',
                            [count, timestamp, userid])
        elif self.driver == 'LDAP':
            dn, entry = self.ldap.search('yubico_get_key', [userid])[0]
            self.ldap.update_d(dn, {'counter': str(count),
                                    'time': str(timestamp)})

    def get_user_keys(self, username):
        """LDAP only function that retrieves the keys of a user.

        Params:
            username (string) - the uid of the user in ldap
        """
        if self.driver == 'LDAP':
            dn, entry = self.ldap.search('get_keys', username)[0]
            return entry['gluuOTPMetadata']

    def update_key(self, username, key):
        """LDAP only function that updates the particular key of the user.

        Params:
            username (string) - the user whose key is to be updated
            key (string) - the key dict as string with updated values
        """
        dn, entry = self.ldap.search('get_keys', username)
        # NOTE This way of updating restricts to one OTP key per person
        self.ldap.update(dn, 'gluuOTPMetadata', key)
Пример #42
0
 def __init__(self, sql_connection, params, vclass):
     self.sql = SQL(sql_connection)
     self.params = params
     self.vclass = vclass