コード例 #1
0
ファイル: models.py プロジェクト: huayes/python
def insert_city(city, other):
	result = db.query("SELECT cid FROM `city` WHERE city='%s'" % (city))	
	if result:
		return False
	else:
		db.insert('city', city=city, other=other)
		return True
コード例 #2
0
ファイル: models.py プロジェクト: huayes/python
def insert_idc(idcname,city, contact,hztime, other):
	result = db.query("SELECT iid FROM `idc` WHERE idcname='%s'" % (idcname))
	if result:
		return False
	else:
		db.insert('idc', idcname=idcname, city=city, contact=contact,hztime=hztime, other=other)
		return True
コード例 #3
0
ファイル: models.py プロジェクト: huayes/python
def insert_project(project, other):
	result = db.query("SELECT pid FROM `project` WHERE project='%s'" % (project))
	if result:
		return False
	else:	
		db.insert('project', project=project, other=other)
		return True
コード例 #4
0
ファイル: mirrordb.py プロジェクト: break123/simpletpb
def add_record_to_all_resource(
    dbname,
    resource_name="N/A",
    typeL1="none",
    typeL2="none",
    magnet="",
    size="Unknown",
    hotrank=50,
    extern_info="False",
    language="EN",
    ed2k="",
):
    "插入记录"
    db.insert(
        dbname,
        resource_name=resource_name,
        typeL1=typeL1,
        typeL2=typeL2,
        magnet=magnet,
        size=size,
        hotrank=hotrank,
        extern_info=extern_info,
        language=language,
        ed2k=ed2k,
    )
コード例 #5
0
def new_host(hostname, eth0, eth1, eth2, gateway, os, project, owners, dmz,
             datacenter, hosted, eth0_vlan, eth1_vlan, status):

    try:
        print "info:host,eth0,eth1,eth2,gateway,os,project,owners,dmz,datacenter,hosted,eth0_vlan,eth1_vlan,status", hostname, eth0, eth1, eth2, gateway, os, project, owners, dmz, datacenter, hosted, eth0_vlan, eth1_vlan, status
        db.insert(tb,
                  hostname=hostname,
                  eth0=eth0,
                  eth1=eth1,
                  eth2=eth2,
                  hosted=hosted,
                  gateway=gateway,
                  os=os,
                  project=project,
                  owners=owners,
                  dmz=dmz,
                  datacenter=datacenter,
                  updated_on=datetime.datetime.now(),
                  eth0_vlan=eth0_vlan,
                  eth1_vlan=eth1_vlan,
                  status=status,
                  type='vhost')
    except Exception, e:
        raise
        return e
コード例 #6
0
 def GET(self):
     db.insert('top',
               resource_name=u'MagicZhang',
               typeL1='movie',
               typeL2='kongfu',
               magnet='zz',
               size='10B')
コード例 #7
0
ファイル: mirrordb.py プロジェクト: blessworld/kukubird
def get_user_cootoken(qq_name, qq_uid):
    "根据qget_user_cootokentoken,目前什么也不做,记录uid一下"
    cootoken = qq_uid
    try:
        cootoken = db.query('select * from ' + ComicUserinfo + ' where qq_uid="' + qq_uid + '"').list()[0]['cootoken']
    except:
        #数据库中没有这个用户
        db.insert(ComicUserinfo, qq_name = qq_name, qq_uid = qq_uid, cootoken = cootoken)
    return cootoken
コード例 #8
0
ファイル: Project.py プロジェクト: xixuebin/docmarster
def insert_project(project_name, project_descrip, html):
    pid = db.insert('project', name=project_name, create_date=now())
    print pid
    if pid:
        itemid = db.insert('item', pid=99, title=project_name, 
                          text=project_descrip, html=html, create_date=now()) 
    if pid and itemid:
        return pid
    else:
        return False
コード例 #9
0
ファイル: mirrordb.py プロジェクト: blessworld/kukubird
def set_user_browsehistory(cootoken, history):
    """
                    根据传入的cootoken设置用户历史记录
                    格式:{'comic_id':'2', 'akaname':'海贼王', 'vol':'2', 'capture':'-1'}
    """
    try:
        uid = db.query('select * from ' + ComicUserinfo + ' where cootoken="' + str(cootoken) + '"').list()[0]['uid']
        db.insert(ComicUserbrowseHistory, uid = uid, history = history).list()
    except:
        #没有这个用户
        pass
コード例 #10
0
ファイル: models.py プロジェクト: huayes/python
def insert_apply(sitename,idc,project,addr_ip,sofeware,datadir,startscrite,port,mysql_conf,mysql_ip,mysql_stype,mysql_name,mysql_use,mysql_pw,dev_name,other,jointime,modifytime,modifyman):

	# Check the ip address exists?
	if addr_ip != '':
		result = db.query("SELECT aid FROM `applications` WHERE addr_ip='%s' AND sitename='%s'"  % (addr_ip,sitename))
		if result:
			return False

	# If not enter the ip address, also saved to database.
	db.insert('applications',sitename=sitename,idc=idc,project=project,addr_ip=addr_ip,sofeware=sofeware,datadir=datadir,startscrite=startscrite,port=port,mysql_conf=mysql_conf,mysql_ip=mysql_ip,mysql_stype=mysql_stype,mysql_name=mysql_name,mysql_use=mysql_use,mysql_pw=mysql_pw,dev_name=dev_name,other=other,jointime=jointime,modifytime=modifytime,modifyman=modifyman)
	return True
コード例 #11
0
def new_tags(tagname, assignedby, status='NULL', comment='NULL', tb=tb_ctmgt):
    #def new_tags(tagname, assignedby, status='NULL', comment='NULL',tb=tb_ctmgt):

    try:
        db.insert(
            tb,
            tagname=tagname,
            assignedby=assignedby,
            status=status,
            comment=comment,
            update_on=datetime.datetime.now(),
        )
    except Exception, e:
        return e
コード例 #12
0
def new_user(username, passwd, alias=''):
    return db.insert('users',
                     username=username,
                     password=passwd,
                     alias=alias,
                     status=0,
                     created_on=datetime.datetime.now())
コード例 #13
0
ファイル: user.py プロジェクト: cash2one/language-Python
 def register(self, username, password, email):
     password1 = hashlib.md5(password).hexdigest()
     result = db.insert(table,
                        username=username,
                        password=password1,
                        email=email,
                        joindate=datetime.datetime.utcnow())
     return result
コード例 #14
0
ファイル: fetchcomicurl.py プロジェクト: blessworld/kukubird
    def GET(self):

        return '此功能已关闭'
        comic_id = web.input().comic_id        
        
        res = db.query('select * from ' + ComicResource + ' where comic_id="' + comic_id + '"').list()
        comic_aka_name = res[0]['aka_name']
        vol_no, min_capture, max_capture = mirrordb.get_comic_length(int(comic_id))
        
        #如果是卷
        if vol_no > 0:
            for vol in xrange(1, vol_no + 1):
                #先获取每一卷的totalpages
                totalpages = db.query('select  count(page) as count_page from CooComicServerComicURL where comic_id=' + 
                                      str(comic_id) + ' and vol=' + str(vol) + ' group by vol')[0]['count_page']
                for i in xrange(1, int(totalpages) + 1):
                    stri = '%03d' %(i)                
                    url = backregurl + comic_aka_name + '/vol_' + str(vol) + '/' + stri + '.jpg'
                    try:
                        #这里改一下数据库
                        db.insert(ComicURL + 'V2', vol = vol, capture = -1, 
                                  page = stri, url = url, comic_id = comic_id, quality_rank = 0)
                    except:
                        return 'URL已经录入,重复!'
                
        #话
        if min_capture > 0:
            for capture in xrange(min_capture, max_capture + 1):
                #先获取每一话的totalpages
                totalpages = db.query('select  count(page) as count_page from CooComicServerComicURL where comic_id=' + 
                                      str(comic_id) + ' and capture=' + str(capture) + ' group by capture')[0]['count_page']
                for i in xrange(1, int(totalpages) + 1):
                    stri = '%03d' %(i)                
                    url = backregurl + comic_aka_name + '/capture_' + str(capture) + '/' + stri + '.jpg'
                    try:
                        #这里改一下数据库
                        db.insert(ComicURL + 'V2', vol = -1, capture = capture, 
                                  page = stri, url = url, comic_id = comic_id, quality_rank = 0)
                    except:
                        return 'URL已经录入,重复!'
            
        #搞定了,返回一个OK页面
        return 'OK'
コード例 #15
0
def up_tags(id,
            tagname,
            assignedby,
            status,
            comment='NULL',
            update_on=datetime.datetime.now(),
            tb=tb_ctmgt):

    try:
        db.insert(
            tb,
            where='id=$id',
            vars=locals(),
            tagname=tagname,
            assignedby=assignedby,
            status=status,
            comment=comment,
            update_on=update_on,
        )
    except Exception, e:
        return e
コード例 #16
0
def add_record_to_all_resource(dbname,
                               resource_name='N/A',
                               typeL1='none',
                               typeL2='none',
                               magnet='',
                               size='Unknown',
                               hotrank=50,
                               extern_info='False',
                               language='EN',
                               ed2k=''):
    "插入记录"
    db.insert(dbname,
              resource_name=resource_name,
              typeL1=typeL1,
              typeL2=typeL2,
              magnet=magnet,
              size=size,
              hotrank=hotrank,
              extern_info=extern_info,
              language=language,
              ed2k=ed2k)
コード例 #17
0
def new_asset(logic_name,
              device_type,
              serial_number,
              hardware_info="NULL",
              layout="NULL",
              status="NULL",
              history="NULL",
              updated_on=datetime.datetime.now(),
              comment="NULL",
              tb='asset'):

    try:
        db.insert(tb,
                  logic_name=logic_name,
                  device_type=device_type,
                  serial_number=serial_number,
                  hardware_info=hardware_info,
                  layout=layout,
                  status=status,
                  history=history,
                  updated_on=updated_on,
                  comment_1=comment)
    except Exception, e:
        return e
コード例 #18
0
ファイル: models.py プロジェクト: huayes/python
def insert_host(hostname,city,project,idc,port,addr1_ip,addr1_netmask,addr1_gateway,addr1_line,addr2_ip,addr2_netmask,addr2_gateway,addr2_line,addr3_ip,addr3_netmask,addr3_gateway,addr3_line,memory,cpu,disk,buytime,servicetime,hardwareinfo,bandwidth,uses,status,company,os,other,jointime,modifytime,modifyman):

	# Check the ip address exists?
	if addr1_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr1_ip, addr1_ip, addr1_ip))
		if result:
			return 'addr'
	if addr2_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr2_ip, addr2_ip, addr2_ip))
		if result:
			return 'addr'
	if addr3_ip != '':
		result = db.query("SELECT hid FROM `hosts` WHERE addr1_ip='%s' OR addr2_ip='%s' OR addr3_ip='%s'" % (addr3_ip, addr3_ip, addr3_ip))
		if result:
			return 'addr'
	# Check hostname exists?
	if hostname != '':
		result = db.query("SELECT hid FROM hosts WHERE hostname = '%s'" % (hostname))
		if result:
			return 'hostname'

	# If not enter the ip address, also saved to database.
	db.insert('hosts',hostname=hostname,city=city,project=project,idc=idc,port=port,addr1_ip=addr1_ip,addr1_netmask=addr1_netmask,addr1_gateway=addr1_gateway,addr1_line=addr1_line,addr2_ip=addr2_ip,addr2_netmask=addr2_netmask,addr2_gateway=addr2_gateway,addr2_line=addr2_line,addr3_ip=addr3_ip,addr3_netmask=addr3_netmask,addr3_gateway=addr3_gateway,addr3_line=addr3_line,memory=memory,cpu=cpu,disk=disk,buytime=buytime,servicetime=servicetime,hardwareinfo=hardwareinfo,bandwidth=bandwidth,uses=uses,status=status,company=company,os=os,other=other,jointime=jointime,modifytime=modifytime,modifyman=modifyman)
	return True
コード例 #19
0
ファイル: fetchcomicurl.py プロジェクト: blessworld/kukubird
 def GET(self):
     comic_aka_name = web.input().comic_aka_name
     regurl = web.input().comicurl
     vol_no = web.input().vol
     capture_no = web.input().capture
     totalpages = web.input().totalpages
     vol_capture_name = web.input().volcapturename
     begin_page_no = web.input().beginpageno
     
     comic_id = -1
     res = db.query('select * from ' + ComicResource + ' where aka_name="' + comic_aka_name + '"').list()
     try:
         comic_id = res[0]['comic_id']
     except:
         #没有这部漫画,先插入
         db.insert(ComicResource, aka_name= comic_aka_name, hotrank = 10)
         comic_id = db.query('select * from ' + ComicResource + ' where aka_name="' + comic_aka_name + '"').list()[0]['comic_id']
     
     urllist = []
     try:
         page_url_no_length = int(regurl[regurl.find('*') + 1])
     except:
         return render.error('地址格式错误!', '/createcomicpage')
     
     for i in xrange(int(begin_page_no), int(totalpages) + int(begin_page_no)):
         strformat = "%0" + str(page_url_no_length) + "d"
         stri = strformat % (i,)
         stri = str(stri)
         striV2 = "%03d" %(i - int(begin_page_no) + 1)
         url = regurl[:regurl.find('*') - 1] + stri + regurl[regurl.find('*') + 3:]
         urlV2 = ''
         if int(vol_no) > 0:
             urlV2 = backregurl + comic_aka_name + '/vol_' + str(vol_no) + '/' + striV2  + regurl[regurl.find('*') + 3:].lower()
         elif int(capture_no) > 0:
             urlV2 = backregurl + comic_aka_name + '/capture_' + str(capture_no) + '/' + striV2 + regurl[regurl.find('*') + 3:].lower()
         urllist.append(url)
         try:
             db.insert(ComicURL.replace('V2', ''), vol = vol_no, capture = capture_no, 
                       page = i, url = url, comic_id = comic_id, quality_rank = 0, vol_capture_name = vol_capture_name)
             db.insert(ComicURL.replace('V2', '') + 'V2', vol = vol_no, capture = capture_no, 
                       page = i, url = urlV2, comic_id = comic_id, quality_rank = 0, vol_capture_name = vol_capture_name)                
         except:
             return render.error('URL已经录入,重复!', '/createcomicpage')
         
     #搞定了,返回一个OK页面
     return render.ok(urllist)
コード例 #20
0
ファイル: models.py プロジェクト: huayes/python
def addHistory(content,description,delman,deltime):
	db.insert('history',content=content,description=description,delman=delman,deltime=deltime)
コード例 #21
0
ファイル: test.py プロジェクト: kele2013/tpbmirror
 def GET(self):
     db.insert('top', resource_name=u'MagicZhang', typeL1='movie', typeL2='kongfu', magnet='zz', size='10B')
コード例 #22
0
ファイル: mirrordb.py プロジェクト: luotao19861229/simpletpb
def add_record_to_all_resource(dbname, resource_name = 'N/A', typeL1 = 'none', 
                               typeL2 = 'none', magnet = '', size = 'Unknown', hotrank = 50, extern_info = 'False', 
                               language = 'EN', ed2k = ''):
    "插入记录"
    db.insert(dbname, resource_name = resource_name, typeL1 = typeL1, typeL2 = typeL2, magnet = magnet, size = size, 
              hotrank = hotrank, extern_info = extern_info, language = language, ed2k = ed2k)
コード例 #23
0
ファイル: Item.py プロジェクト: five3/docmaster
def insert_item(pid, item_name, item_order, item_content, html, is_visible):
    return db.insert('item', pid=pid, title=item_name, item_order=item_order, 
                       text=item_content, html=html, is_visible=is_visible, create_date=now()) 
コード例 #24
0
ファイル: user.py プロジェクト: top/python
	def register(self, username, password, email):
		password1 = hashlib.md5(password).hexdigest()
		result = db.insert(table, username=username, password=password1, email=email, joindate=datetime.datetime.utcnow())
		return result
コード例 #25
0
ファイル: model.py プロジェクト: iSource/Blue
def add(table, **kw):
    return db.insert(table, **kw)
コード例 #26
0
ファイル: models.py プロジェクト: huayes/python
def insert_user(privilege,username,password,createtime,lastlogin,loginip,phone,email,other):
	db.insert('users',privilege=privilege,username=username,password=password,createtime=createtime,lastlogin=lastlogin,loginip=loginip,phone=phone,email=email,other=other)
コード例 #27
0
ファイル: Project.py プロジェクト: pjdhanhan/docmaster
def insert_project(project_name, project_descrip, html):
    pid = db.insert("project", name=project_name, description=project_descrip, create_date=now())
    if pid:
        return pid
    else:
        return False
コード例 #28
0
ファイル: Login.py プロジェクト: five3/docmaster
def login_record(ip):
    return db.insert('login', ip=ip, time=now())
コード例 #29
0
ファイル: Login.py プロジェクト: five3/docmaster
def login_fail(name, times):
    if times < 2:
        return db.insert('loginfail', times=times, name=name)
    else:
        return db.update('loginfail', times=times, where='name=$name', vars=locals())