예제 #1
0
파일: MetaData.py 프로젝트: drxbate/M1
def getData(name,*args):
    tag = "metadata:%s"%name
    if type(args)==str:
        tag+=":"+args
    else:
        for i in args:
            tag+=":"+i
    return RedisCli.get(tag)
예제 #2
0
파일: MetaData.py 프로젝트: drxbate/M1
def getKeys(name,*filters):
    tag = "metadata:%s"%name
    if type(filters)==str:
        tag+=":"+filters
    else:
        for i in filters:
            tag+=":"+i
    return RedisCli.keys(tag)
예제 #3
0
파일: QrCode.py 프로젝트: drxbate/q2k
def regist_url(url,bites=8,hours=48):
    
    md5=utility.md5code(url)
    
    cinfo = dict(state=0,code="",url=url,expire=0)
    cinfo.update(RedisCli.hgetall("Q2k:Urls:%s"%md5))
    if cinfo["state"]=="0":
        if cinfo["code"]=="":
            while True:
                code = utility.generateCode(bites)
                if not exists(code):
                    break
                time.sleep(0.1)
            cinfo["code"]=code
         
    
        RedisCli.hset("Q2k:Codes", cinfo["code"],url)
        RedisCli.hset("Q2k:Urls:%s"%md5,"code",cinfo["code"])
        RedisCli.hset("Q2k:Urls:%s"%md5,"state",1)
    
    #默认将过期时间向后延期
    RedisCli.hset("Q2k:Urls:%s"%md5,"expire",time.time()+hours*60*60)
    return cinfo["code"]
    
예제 #4
0
파일: Profile.py 프로젝트: drxbate/M1
def removeHashTable(uid, name, *keys):
    tag = "profile:%s:%s" % (uid, name)
    if keys != None and len(keys) > 0:
        RedisCli.hdel(tag, *keys)
    else:
        RedisCli.hdel(tag)
예제 #5
0
파일: Profile.py 프로젝트: drxbate/M1
def updateHashTable(uid, name, key="", value="", **dict):
    tag = "profile:%s:%s" % (uid, name)
    if dict != None and len(dict) > 0:
        RedisCli.hmset(tag, dict)
    if name != None:
        RedisCli.hset(tag, key, value)
예제 #6
0
파일: Profile.py 프로젝트: drxbate/M1
def getHashTable(uid, name):
    tag = "profile:%s:%s" % (uid, name)
    return RedisCli.hgetall(tag)
예제 #7
0
파일: Profile.py 프로젝트: drxbate/M1
def removeFromArray(uid, name, value):
    tag = "profile:%s:%s" % (uid, name)
    RedisCli.lrem(tag, value)
예제 #8
0
파일: QrCode.py 프로젝트: drxbate/q2k
def apply(url,bites,hours):
    md5=utility.md5code(url)
    RedisCli.hset("Q2k:Urls:%s"%md5,"state",0)
    RedisCli.rpush("Q2k:Queue:Apply",json.dumps(dict(url=url,bites=bites,hours=hours)))
예제 #9
0
파일: Profile.py 프로젝트: drxbate/M1
def appendToArray(uid, name, *value):
    tag = "profile:%s:%s" % (uid, name)
    RedisCli.lpush(tag, *value)
예제 #10
0
파일: Profile.py 프로젝트: drxbate/M1
def putProfile(uid, name, value):
    tag = "profile:%s:%s" % (uid, name)
    RedisCli.set(tag, value)
예제 #11
0
파일: Profile.py 프로젝트: drxbate/M1
def getProfile(uid, name, *args):
    tag = "profile:%s:%s" % (uid, name)
    return RedisCli.get(tag)
예제 #12
0
파일: QrCode.py 프로젝트: drxbate/q2k
def get_url(code):
    return RedisCli.hget("Q2k:Codes",code)
예제 #13
0
파일: QrCode.py 프로젝트: drxbate/q2k
def get_code(url):
    md5=utility.md5code(url)
    data = RedisCli.hgetall("Q2k:Urls:%s"%md5)
    data["state"] = int(data["state"])
    return data
예제 #14
0
파일: QrCode.py 프로젝트: drxbate/q2k
def get_apply_url():
    s=RedisCli.lpop("Q2k:Queue:Apply")
    if s!=None:
        return json.loads(s)    
예제 #15
0
파일: data_city.py 프로젝트: drxbate/q2k
001006045,控江                                    
001006046,鞍山                                    
001006542,新江湾城                                
001007016,曹家渡                                  
002028999,天虹百货
002028a00,左岸商业街
002028a01,星州街
002028a02,高和路
002028a03,湖畔商圈
002027a04,珠江路
002027a05,金枫路
002027a06,汾湖路

"""

if __name__=="__main__":
    for k in RedisCli.keys("metadata:district:*"):
        RedisCli.delete(k)

    for i in data.split("\n"):
        if i=="":
            continue
        cd,name=i.split(",",2)
        if len(cd)==3:
            RedisCli.set("metadata:district:%s"%cd,name.encode("utf8"))
        elif len(cd)==6:
            RedisCli.set("metadata:district:%s:%s"%(cd[:3],cd[3:]),name.encode("utf8"))
        elif len(cd)==9:
            RedisCli.set("metadata:district:%s:%s:%s"%(cd[:3],cd[3:6],cd[6:]), name.encode("utf8"))
            
    
예제 #16
0
파일: Profile.py 프로젝트: drxbate/M1
def getArray(uid, name):
    tag = "profile:%s:%s" % (uid, name)
    c = RedisCli.llen(tag)
    ll = RedisCli.lrange(tag, 0, -1)
    return ll
예제 #17
0
파일: systags.py 프로젝트: drxbate/M1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2015年8月17日

@author: ruixidong
'''

from ObjectModules.Profile import Mark,Marks
from DataAccess.Handler import RedisCli
from DataAccess import Profile

tags=[dict(__id__="cs01",text="诚意客户",style="mark-style-1",icon="flag",iconColor="red"),
      dict(__id__="cs02",text="独家委托",style="mark-style-1",icon="flag",iconColor="red"),
      dict(__id__="cs03",text="多次带看",style="mark-style-1",icon="flag",iconColor="red"),
      dict(__id__="cs04",text="老客户",style="mark-style-1",icon="flag",iconColor="red"),
      ]

if __name__=="__main__":
    RedisCli.delete("profile:__global__:cust:mark")
    
    for i in tags:
        m = Mark()
        m.__id__=i["__id__"]
        m.icon = i["icon"]
        m.iconColor = i["iconColor"]
        m.style = i["style"]
        m.text = i["text"]
        Profile.updateHashTable("__global__", "mark", m.__id__,Mark.serialize(m))
예제 #18
0
파일: QrCode.py 프로젝트: drxbate/q2k
def exists(code):
    return RedisCli.hexists("Q2k:Codes", code)