Esempio n. 1
0
def hello():
    conn = db_wrapper()

    DIRECTORY = "../yilun/static/Portrait/"
    nameList = []
    visitList = []
    pathList = []
    for f in os.listdir(DIRECTORY):
        if os.path.splitext(f)[1].lower() in ('.jpg', '.jpeg'):
            nameList.append(f.split(".")[0])
            # countList.append(conn.name_count(f.split(".")[0]))
            visitList.append(f.split(".")[0])
            pathList.append('/static/' + f.split(".")[0] + '.jpg')

    totalNum = conn.total_count()
    ageAve = conn.age_average()
    genRto = conn.gender_ratio()
    glsRto = conn.glass_ratio()
    maxVisit = conn.max_visit()
    # print(nameList)
    # print(ageAve)
    return render_template('index1.html',
                           name_List=nameList,
                           visit_List=visitList,
                           var2=pathList,
                           total_count=totalNum,
                           age_Ave=ageAve,
                           gen_Rto=genRto,
                           gls_Rto=glsRto,
                           max_visit=maxVisit,
                           max_visitor=maxVisit[0],
                           max_time=maxVisit[4])
def initialize_db(dbname='icheckmovies.db'):
    db = db_wrapper.db_wrapper(dbname)
    db.init_table("lists", create_lists)
    db.init_table("list_tags", create_list_tags)
    db.init_table("list_progress", create_list_progress)
    db.init_table("films", create_films)
    db.init_table("film_tags", create_film_tags)
    db.init_table("film_progress", create_film_progress)
    db.init_table("list_items", create_list_items)
Esempio n. 3
0
def import_all(db_file):
    db = db_wrapper.db_wrapper(name=db_file)

    db.set_update_sql("films", "INSERT OR REPLACE INTO {0} VALUES(NULL, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)")
    db.set_update_sql("film_tags", "INSERT OR REPLACE INTO {0} VALUES(NULL, ?, ?, CURRENT_TIMESTAMP)")
    db.set_update_sql("film_progress", "INSERT OR REPLACE INTO {0} VALUES(NULL, ?, ?, ?, CURRENT_TIMESTAMP)")
    db.set_update_sql("list_items", "INSERT OR REPLACE INTO {0} VALUES(NULL, ?, ?, CURRENT_TIMESTAMP)")

#    import_one_list(db, BASE_URL, "/lists/top+250/")
#    import_one_list(db, BASE_URL "/lists/the+criterion+collection/")
#    quit()
    for item in db.get_cursor().execute("SELECT * FROM lists").fetchall():
        import_one_list(db, BASE_URL item[1])
        time.sleep(1)
    db.close_db()
Esempio n. 4
0
import wx

from db_wrapper import db_wrapper
from window import window

db_wrap = db_wrapper()
#print("TABLE NAMES")
#[print(x) for x in db_wrap.table_names]

#print("\nMATERIAL_NAMES")
#[print(x) for x in db_wrap.material_names]

test_data = db_wrap.get_table_data_raw('Steel_Thermal_Conductivity')
app = wx.App()
window(None, 'Material Properties GUI', db_wrap)
app.MainLoop()
        # Description does not always exist
        if len(description_tag.contents) > 0:
            # TODO: Better strategy for handling problematic characters
            description = description_tag.contents[0].encode('utf-8', 'ignore')
        else:
            description = None

        tags = []
        for tag in item.find_all('a', attrs={'class': 'tagNamespaceCategory'}):
            tags.append(tag.contents[0])

        user = item.find('a', attrs={'class': 'tagNamespaceUser'}).contents[0]

        db.update_db("lists", [href, name, None, favs_dislikes[0], favs_dislikes[1], str(description), user])

        # Purge the old tags and include the active list of tags
        db.get_cursor().execute("DELETE FROM list_tags WHERE list_link=?", (href,))
        for tag in tags:
            db.update_db("list_tags", [href, tag])

    next_link = soup.find('li', attrs={'class': 'next'}).find('a')
    if next_link is not None:
        fetch_list_and_add(db, base_path + next_link['href'])

    #db.print_db("lists")
    #db.print_db("list_tags")

db = db_wrapper.db_wrapper(name="icheckmovies.db")
fetch_list_and_add(db, base_path=BASE_URL + LIST_PATH, start_url=BASE_URL + LIST_PATH + "?tags=user:icheckmovies")
    ins = twitter_collect_data()
    ins.setup_credential()
    inserted_users_list = []

    r = ins.api.request('statuses/user_timeline', {
        'user_id': '@{0}'.format(702243),
        'counts': '{0}'.format(200)
    })
    ans = json.loads(r.text)
    print(len(ans))
    users_list = []

    start = time.time()

    db = db_wrapper()

    #db.create_messagesEn()
    #get-user_ids
    users_list = db.retrieve_users()
    #check if you have inserted ay of them before
    already_inserted = db.already_inserted()
    print('already inserted: ', len(already_inserted))
    print('type users_list: ', type(users_list[0]), ' type al_ins',
          type(already_inserted[0]))
    need_to_be_inserted = [
        user for user in users_list if str(user) not in already_inserted
    ]
    print(len(need_to_be_inserted))
    # Start inserting the remaining.
    print 'users_list size: ', len(users_list)
Esempio n. 7
0
 def __init__(self):
     self.video_capture = cv2.VideoCapture(0)
     self.db = db_wrapper.db_wrapper()