Exemplo n.º 1
0
def jstie(db):
    """
		新版本的Tie过程
	"""
    url = request.GET.get('url', '').strip()
    title = request.GET.get('title', '').strip()
    tag = request.GET.get('tag', '').strip()
    catid = int(request.GET.get('category', '').strip())
    notes = request.GET.get('notes', '').strip()
    isheart = request.GET.get('heart', '').strip()

    if not url or isdeny(url):
        #返回1x1的数据,表示正确,实为吞没
        response['Content-Type'] = 'image/png'
        return png_1x1

    if ulen(url) > 1024: url = ulenget(url, 1024)
    if ulen(title) > 1024: title = ulenget(title, 1024)
    if tag:
        tag = refineTag(tag)
        if ulen(tag) > 1024: tag = ulenget(tag, 1024)
    if ulen(notes) > 1024: notes = ulenget(notes, 1024)

    try:
        catid = int(catid)
        #检查这个catid是否存在
        db.execute('SELECT ID FROM CATEGORY WHERE ID=%s', catid)
        v = db.getone()
        if not v: raise Exception("invalid catid param")  #非法用户插入,选用默认的结果.
    except:
        catid = getdefaultcatid(db)

    heart = 0
    if isheart: heart = 1
    shortid = 0
    if url:
        shortid = getshorturlid(url)

    db.execute(
        'INSERT INTO URLS(IS_HEART,IS_ARCHIVED,ARCHIVED_OK,CATEGORY_ID,URL,SHORT_URL_ID,TITLE,TAG,NOTES,TIE_TIME) VALUES(%s,0,0,%s,%s,%s,%s,%s,%s,%s)',
        (heart, catid, url, shortid, title, tag, notes, nt()))
    recordid = db.insert_id()

    if needarchive(db) and archiveapiok(db) and url:
        db.execute('UPDATE URLS SET IS_ARCHIVED=2 WHERE ID=%s', recordid)

    db.commit()
    response['Content-Type'] = 'image/png'
    return png_1x1
Exemplo n.º 2
0
def jstie(db):
	"""
		新版本的Tie过程
	"""
	url = request.GET.get('url','').strip()
	title = request.GET.get('title','').strip()
	tag = request.GET.get('tag','').strip()
	catid = int(request.GET.get('category','').strip())
	notes = request.GET.get('notes','').strip()
	isheart = request.GET.get('heart','').strip()

	if not url or isdeny(url):
		#返回1x1的数据,表示正确,实为吞没
		response['Content-Type'] = 'image/png'
		return png_1x1

	if ulen(url) > 1024: url = ulenget(url,1024)
	if ulen(title) > 1024: title=ulenget(title,1024)
	if tag:
		tag = refineTag(tag)
		if ulen(tag) > 1024: tag = ulenget(tag,1024)
	if ulen(notes) > 1024: notes= ulenget(notes,1024)

	try:
		catid = int(catid)
		#检查这个catid是否存在
		db.execute('SELECT ID FROM CATEGORY WHERE ID=%s',catid)
		v = db.getone()
		if not v: raise Exception("invalid catid param") #非法用户插入,选用默认的结果.
	except:
		catid = getdefaultcatid(db)

	heart = 0
	if isheart: heart = 1
	shortid = 0
	if url:
		shortid = getshorturlid(url)

	db.execute('INSERT INTO URLS(IS_HEART,IS_ARCHIVED,ARCHIVED_OK,CATEGORY_ID,URL,SHORT_URL_ID,TITLE,TAG,NOTES,TIE_TIME) VALUES(%s,0,0,%s,%s,%s,%s,%s,%s,%s)',(heart,catid,url,shortid,title,tag,notes,nt()))
	recordid = db.insert_id()

	if needarchive(db) and archiveapiok(db) and url:
		db.execute('UPDATE URLS SET IS_ARCHIVED=2 WHERE ID=%s',recordid)

	db.commit()
	response['Content-Type'] = 'image/png'
	return png_1x1
Exemplo n.º 3
0
 def importalink(db, catid, alink):
     title, url, tag = alink
     shortid = getshorturlid(url)
     db.execute(
         'INSERT INTO URLS(IS_HEART,IS_ARCHIVED,ARCHIVED_OK,CATEGORY_ID,URL,SHORT_URL_ID,TITLE,TAG,NOTES,TIE_TIME) VALUES(0,0,0,%s,%s,%s,%s,%s,%s,%s)',
         (catid, url, shortid, title, tag, '', nt()))
Exemplo n.º 4
0
	def importalink(db,catid,alink):
		title,url,tag = alink
		shortid = getshorturlid(url)
		db.execute('INSERT INTO URLS(IS_HEART,IS_ARCHIVED,ARCHIVED_OK,CATEGORY_ID,URL,SHORT_URL_ID,TITLE,TAG,NOTES,TIE_TIME) VALUES(0,0,0,%s,%s,%s,%s,%s,%s,%s)',(catid,url,shortid,title,tag,'',nt()))
Exemplo n.º 5
0
            tl, vl, _ = create_loaders(
                data_path,
                train_size,
                bs,
                max_subj,
                ch_type,
                data_type,
                num_workers=nw,
                debug=debug,
                chunkload=chunkload,
            )
            tpb, et = train(net, tl, vl, "", lr=learning_rate, timing=True)
            perfs.append((nw, bs, tpb, et))

        for x in sorted(perfs, key=lambda x: x[-1]):
            print("\n", (x[0], x[1], nt(x[2]), nt(x[3])))

    else:
        print(net)

        # We create loaders and datasets (see dataloaders.py)
        trainloader, validloader, testloader = create_loaders(
            data_path,
            train_size,
            batch_size,
            max_subj,
            ch_type,
            data_type,
            seed=seed,
            num_workers=num_workers,
            chunkload=chunkload,