Beispiel #1
0
def get_data(view, name):
    """ 
        Get data from the Database & output to display
        @view : textbox to output
        @name : name query to get data
    """
    cp = nc.NuCrypt()
    conn = md.create_connection("%s/connection.db" % (config.root))
    if conn is not None:
        result = md.select_from(conn, name)

        if result:
            for row in result:
                output = "Id : {id} \nName : {name} \nURL : {url}\nType : {type}\nUser name : {user} \nPassword : {passw}\n\n".format(
                    name=row[1],
                    url=row[5],
                    user=row[3],
                    passw=cp.decrypt(row[4]),
                    type=row[2],
                    id=row[0])

                view.insert('end', output)
        else:
            view.insert('end', 'No recoard found for: "{q}"\n'.format(q=name))
    conn.close()
Beispiel #2
0
def entryInsert(event, fields):
    """
        Add Data to fields on after enter id on update tab
        @event : focusout event
        @field : filed dictionry to particular data
    """

    element = event.widget
    val = event.widget.get()
    conn = md.create_connection("%s/connection.db" % (config.root))
    cp = nc.NuCrypt()

    # Get data from the database
    results = md.execute_query(
        conn, "select * from credential where id='{ID}'".format(ID=val))
    if results[0] is not None:
        fields['name'].delete(0, 'end')
        fields['name'].insert(0, results[0][1])

        fields['type'].delete(0, 'end')
        fields['type'].insert(0, results[0][2])

        fields['username'].delete(0, 'end')
        fields['username'].insert(0, results[0][3])

        fields['password'].delete(0, 'end')
        fields['password'].insert(0, cp.decrypt(results[0][4]))

        fields['url'].delete(0, 'end')
        fields['url'].insert(0, results[0][5])
Beispiel #3
0
def register_page():
    form = RegistrationForm(request.form)

    if request.method == 'POST' and form.validate():
        print(form.username.data, form.email.data, form.password.data)
        username = form.username.data
        name = form.name.data
        password = sha256_crypt.encrypt(str(form.password.data))
        email = form.email.data

        conn, c = create_connection()
        c.execute('SELECT count(*) FROM users WHERE username = (?)',
                  (username, ))
        x = c.fetchone()
        close_connection(conn)

        if x[0] > 0:
            print("User already found")
            return render_template('register.html',
                                   form=form,
                                   user=session.get('username', None))
        else:
            insert_user(username, password, name, email)
            print("Added user")
            gc.collect()

            session['logged_in'] = True
            session['username'] = username

            return redirect(url_for('index'))

    return render_template('register.html',
                           form=form,
                           user=session.get('username', None))
Beispiel #4
0
def main():
    conn = create_connection(DATABASE)

    if conn is not None:
        create_table(conn, sql_create_links_table)

        links = select_all_links(conn)
        all_html(links)
Beispiel #5
0
def add_data(*args, **kwargs):
    """ Add a connection to Database 
        notes: name and connection type save in lowercaase letters
    """
    conn = md.create_connection("%s/connection.db" % (config.root))
    if conn is not None:
        md.create_table(conn)
        md.insert_data(conn, args[0])
        #  Refresh the connection list
        args[1].delete(0, 'end')
        listInsert(args[1])
    clearField(args[0])
    conn.close()
Beispiel #6
0
def listInsert(element):
    """ 
        Get Available connection and insert into given listbox
    """
    conn = md.create_connection("%s/connection.db" % (config.root))

    result = md.execute_query(conn, "select distinct name from credential")
    if result:
        i = 0
        for row in result:
            element.insert(i, row[0].capitalize())
            i + 1
    else:
        element.insert('end', "You don\'t have any connection yet :)")
    conn.close()
Beispiel #7
0
def main():
    conn = create_connection()
    if conn is not None:
        soup = get_content(SITE_PROTOCOL+SITE_NAME)
        if soup != None:
            links = get_all(get_page_links(soup))
            
            create_table_links(conn)
            insertion_of_links_in_table(conn,links)
            select_all_links(conn)

            create_table_words(conn)
            create_files_for_html(links)
            
            rates = rate_words(links)
            create_table_for_words(conn,rates)
            select_all_words(conn)
Beispiel #8
0
def main():
    conn = create_connection(DATABASE)

    if conn is not None:
        create_table(conn, sql_create_links_table)

        soup = get_content(SITE_PROTOCOL + SITE_NAME)
        links = get_page_links(soup, conn)
        select_all_links(conn)
        l = recollect_links(links)
        create_html_files(l)

        onlyfiles = [
            join("/home/monika/parser/python_parser/foodtime.am", f)
            for f in listdir("/home/monika/parser/python_parser/foodtime.am")
            if isfile(join("/home/monika/parser/python_parser/foodtime.am", f))
        ]

        for i in onlyfiles:
            write_db(i)
Beispiel #9
0
def update_data(*args, **kwargs):
    """
        Connection update
    """
    cp = nc.NuCrypt()
    data = args[0]
    query = "update credential set name='{name}', type='{type}', user='******', password='******', url='{url}' where id={id};".format(
        name=data['name'].get().lower(),
        type=data['type'].get().lower(),
        user=data['user'].get(),
        password=cp.encrypt(data['password'].get()),
        url=data['url'].get(),
        id=data['id'].get())
    con = md.create_connection("%s/connection.db" % (config.root))
    if con is not None:
        try:
            result = md.execute_query(con, query)
            con.commit()
        except Error as e:
            pass
            # print(e)

    clearField(data)
    con.close()