Esempio n. 1
0
 def RemoveExpiredItems(self):
     timenow=time.time()
     ThreeDaysAgo=time.time()-MU_MainConfig.THREEDAYS
     zset=r.zrangebyscore('expire',ThreeDaysAgo,timenow)
     hkeys=r.hkeys('queue')
     setofzset=set(zset)
     setofhkeys=set(hkeys)
     intersection=list(setofzset&setofhkeys)
     for i in range(len(hkeys)):
         if hkeys[i] not in intersection:
             title=r.hget('queue',hkeys[i])
             if hkeys[i] is MU_MainConfig.EDITEDPREFIX+title:
                 r.zrem('expire',MU_MainConfig.EDITEDPREFIX+title)
                 r.hdel('queue',hkeys[i])
                 name=r.hget('img',MU_MainConfig.EDITEDPREFIX+title)
                 os.remove('../imgcache/'+name)
                 r.hdel('img',MU_MainConfig.EDITEDPREFIX+title)
                 r.hdel('imgkey',MU_MainConfig.EDITEDPREFIX+title)
                 score=r.zscore('queuenumber',title)
                 r.zrem('queuenumber',title)
                 scorequeue=r.zrange('queuenumber',int(score)-1,-1)
                 for i in range(len(scorequeue)):
                     score=r.zscore('queuenumber',scorequeue[i])
                     r.zadd('queuenumber',scorequeue[i],score-1)
             else:
                 r.zrem('expire',MU_MainConfig.EDITEDPREFIX+title)
                 r.hdel('queue',hkeys[i])
Esempio n. 2
0
def ForbiddenItemPushed(title):
    for key in r.hkeys('queue'):
        if key==PUSHEDPREFIX+title:
            return False
            break
        else:
            pass
Esempio n. 3
0
 def GetItemToSend(self):
     KeyList=r.hkeys('queue')
     for i in range(len(KeyList)):
         ToBeSendTitle=r.hget('queue',KeyList[i])
         ToBeSendImage=r.hget('img',KeyList[i])
         r.zadd('queuenumber',ToBeSendTitle,i)
         r.hset('imgkey',ToBeSendTitle,ToBeSendImage)
Esempio n. 4
0
 def PostItem(self):
     Keys=r.hkeys('queue')
     ReadyToPostItem=r.hget('queue',Keys[0])
     UnPushed=ForbiddenItemPushed(ReadyToPostItem)
     print UnPushed
     if UnPushed is not False:
         Image='imgcache/'+r.hget('img',EDITEDPREFIX+ReadyToPostItem)
         post(status=ReadyToPostItem,pic=Image)
         r.zrem('queuenumber',ReadyToPostItem)
         r.hdel('imgkey',EDITEDPREFIX+ReadyToPostItem)
         r.hdel('queue',EDITEDPREFIX+ReadyToPostItem)
         r.hset('queue',PUSHEDPREFIX+ReadyToPostItem,ReadyToPostItem)
     else:
         pass
Esempio n. 5
0
 def FamiliarItemForbidden(self):
     pdb.set_trace()
     topics = copy.deepcopy(self.cache)
     ForbiddenCategories=r.hkeys('forbiddencategories')
     ForbiddenTopics=r.hkeys('forbiddentopics')
     ForbiddenCategoriesSet=set(ForbiddenCategories)
     rc_cats=map(GetCategory,self.cache)
     for i in range(len(topics)):
         catsset=set(rc_cats[i])
         crossed=catsset&ForbiddenCategoriesSet
         if len(ForbiddenTopics) is not 0:
             for j in range(len(ForbiddenTopics)):
                 matchflag = re.search(ForbiddenTopics[j],topics[i])
         else:
             matchflag = None
         if crossed:
             localnames = locals()
             crosslist = list(crossed)
             for k in range(len(crosslist)):
                 varname = crosslist[k]
                 if varname in dir():
                     if localnames[varname] >= 3:
                         self.cache.remove(topics[i])
                     else:
                         localnames[varname] = localnames[varname] + 1
                 else:
                     localnames[varname] = 1
         if matchflag is not None:
             localnames=locals()
             varname = matchflag.group(0)
             if varname in dir():
                 if localnames[varname] >= 3:
                     self.cache.remove(topics[i])
                 else:
                     localnames[varname] = localnames[varname] + 1
             else:
                 localnames[varname] = 1
Esempio n. 6
0
 def RemoveExpiredItems(self):
     timenow=time.time()
     ThreeDaysAgo=time.time()-12
     zset=r.zrangebyscore('expire',ThreeDaysAgo,timenow)
     hkeys=r.hkeys('queue')
     setofzset=set(zset)
     setofhkeys=set(hkeys)
     intersection=list(setofzset&setofhkeys)
     for i in range(len(hkeys)):
         if hkeys[i] not in intersection:
             r.zrem('expire',hkeys[i])
             r.hdel('queue',hkeys[i])
             name=r.hget('img',hkeys[i])
             os.remove('imgcache/'+name)
             r.hdel('img',r.hget('queue',hkeys[i]))
Esempio n. 7
0
def ForbiddenItemBanned(title):
    keywords = r.hkeys('bannedkeyword')
    for keyword in keywords:
        if re.search(keyword,title):
            return False
    return True
Esempio n. 8
0
def ForbiddenItemGet(title):
    keys = r.hkeys('queue')
    if MU_MainConfig.EDITEDPREFIX+title in keys:
        return False
    return True
Esempio n. 9
0
def ForbiddenItemPushed(title):
    keys = r.hkeys('queue')
    if MU_MainConfig.PUSHEDPREFIX+title in keys:
        return False
    return True