Пример #1
0
    def get_items_ids(self, response):

        redis = redis_resource()
        _id = redis.rpop(response.persist['category'])
        while _id:
            _id = int(_id)
            payload = {'ids[]': _id}
            self.crawl(response.url + '/load-more' + '/?' + str(uuid.uuid1()),
                       data=payload,
                       method='POST',
                       callback=self.get_item)
            redis.sadd(consumedKey(response.persist['category']), _id)
            _id = redis.rpop(response.persist['category'])
Пример #2
0
def exec_custom_cmd(script_file):
    if os.path.exists(script_file) and os.path.isfile(script_file):
        chk_and_set_exe(script_file)
        # output = subprocess.check_output(script_file, shell=False)
        # return output
        p = Popen(script_file, stdout=PIPE)
        c_pid = p.pid
        output = p.communicate()[0]
        rc = p.wait()
        if rc == 0:
            result = output
            deploy_type = json.loads(redis.rpop('deploy_type'))
            recipients = json.loads(redis.rpop('recipients'))
            carbon_copy = json.loads(redis.rpop('carbon_copy'))
            functions = json.loads(redis.rpop('functions'))
            restart_service = json.loads(redis.rpop('restart_service'))
            subject = json.loads(redis.rpop('subject'))
            name = json.loads(redis.rpop('name'))
            repo_name = json.loads(redis.rpop('repo_name'))
            commit_id = json.loads(redis.rpop('commit_id'))
            commit_msg = json.loads(redis.rpop('commit_msg'))
            _deploy_log = DeployLog(
                project=repo_name,
                version=commit_id,
                deployer=name,
                environment='30环境' if deploy_type == 'weekfix' else '31环境',
                summary=commit_msg)
            db.session.add(_deploy_log)
            db.session.commit()
            if restart_service:
                restarted_phpfpm_service.delay()
            send_async_email.delay('*****@*****.**',
                                   recipients,
                                   carbon_copy,
                                   subject,
                                   'deploy',
                                   name=name,
                                   repo_name=repo_name,
                                   commit_id=commit_id,
                                   introduce=commit_msg,
                                   functions=functions,
                                   deploy_type=deploy_type,
                                   result=result)
        else:
            raise subprocess.CalledProcessError()
Пример #3
0
def tweet_and_shout(api_session, redis, key, timeout=600):
    """"""
    for tweet_id in redis.lrange("%s:%s" % (LOLCOIFFEURS_LIST, key), 0, -1):
        tweet_dict = redis.hgetall("%s:tweet:%s" % (LOLCOIFFEURS_LIST, tweet_id))
 
        # Tracking answered tweets in a brand new set, and posting
        # a reply to it
        print "replying tweet : %s" % (tweet_id)
        redis.sadd((LOLCOIFFEURS_LIST + ":%s:answered" % (key)), tweet_id)
#        api_session.PostUpdate("@%s %s" % (tweet_dict["username"], RESPONSE), in_reply_to_status_id=tweet_id)
        # Popping out element from the left of the list
        # as we answer it
        redis.rpop("%s:%s" % (LOLCOIFFEURS_LIST, key))
 
        # Wait timeout before replying again
        sleep(timeout)
 
    return
Пример #4
0
def tweet_and_shout(api_session, redis, key, timeout=600):
    """"""
    for tweet_id in redis.lrange("%s:%s" % (LOLCOIFFEURS_LIST, key), 0, -1):
        tweet_dict = redis.hgetall("%s:tweet:%s" %
                                   (LOLCOIFFEURS_LIST, tweet_id))

        # Tracking answered tweets in a brand new set, and posting
        # a reply to it
        print "replying tweet : %s" % (tweet_id)
        redis.sadd((LOLCOIFFEURS_LIST + ":%s:answered" % (key)), tweet_id)
        #        api_session.PostUpdate("@%s %s" % (tweet_dict["username"], RESPONSE), in_reply_to_status_id=tweet_id)
        # Popping out element from the left of the list
        # as we answer it
        redis.rpop("%s:%s" % (LOLCOIFFEURS_LIST, key))

        # Wait timeout before replying again
        sleep(timeout)

    return
Пример #5
0
def main():
    redis = Redis(host='127.0.0.1', port=6379)
    #while True:
   	#time.sleep(1)
    res = redis.rpop('test')
    if res == None:
       	pass
    else:
       	print str(res) 
    read10('/home/wlw/ffmpeg/img1')
    pass
Пример #6
0
def main():
    redis = Redis(host='127.0.0.1', port=6379)
    #while True:
    #time.sleep(1)
    res = redis.rpop('test')
    if res == None:
        pass
    else:
        print str(res)
    read10('/home/wlw/ffmpeg/img1')
    pass
Пример #7
0
def redis_consumer(listKey, hashKey, redis):
    while True:
        # 一直不停从Redis的List中取数据,直到取空
        title = redis.rpop(listKey)
        if title == None:
            return
        # 拿到标题后,根据标题拿到url
        url = redis.hget(hashKey, title)
        print(url)
        t = get_page_info(url)
        # 定义储存文件的目录
        dirS = 'D:/myCode/python/crawler/news/'
        # 调用序列化方法
        file = serialize_to_file(dirS, title + '.txt', t)
        print("输出文件:" + file)
Пример #8
0
def on_draw(*args):
    window.clear()
    msg = redis.rpop("vertex_list")
    if msg:
        as_json = json.loads(msg)
        ray_coords = as_json.get("ray_coords", [])
        ray_colors = as_json.get("ray_colors", [])
        circles = as_json.get("circles", [])
        if not ray_coords:
            ray_coords = []
            ray_colors = []
        vertex_list = pyglet.graphics.vertex_list(int(len(ray_coords) / 2),
                                                  ('v2f', ray_coords),
                                                  ('c3B', ray_colors))
        vertex_list.draw(pyglet.gl.GL_LINES)
        for circle in circles:
            vl = pyglet.graphics.vertex_list(int(len(circle['coords'][1]) / 2),
                                             tuple(circle['coords']),
                                             tuple(circle['colors']))
            vl.draw(pyglet.gl.GL_POLYGON)
Пример #9
0
def re_map(msg_id, dbName):
    start_id = int(msg_id) - 10
    end_id = int(msg_id) + 10
    sql = "select * from main.message WHERE type =3 and talker='9990246678@chatroom' and msgId >=" + str(
        start_id) + " and msgId<=" + str(end_id) + ";"
    data = query(dbName, sql)
    for i in range(0, len(data)):
        tailorImg(decodeDbName, data[i][0], data[i][1])
    redis.lpush(has_done_key, msg_id)


if __name__ == "__main__":
    uin = '-1763681588'
    imei = '861795037451492'
    fileName = 'reMap_EnMicroMsg_' + str(imei) + 'reMap.db'
    decodeDbName = 'reMap_decrypted_' + fileName

    # cpFile(uin, str(fileName))
    #
    # key = getKey(uin, imei)
    #
    # r = decrypt(key, fileName, decodeDbName)

    list_len = redis.llen(redis_key)

    for i in range(0, list_len):
        msg_id = redis.rpop(redis_key)
        print "但前处理" + str(msg_id)
        re_map(msg_id, decodeDbName)
Пример #10
0
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/3/8 5:05 下午
# @Author : wangHua
# @Software: PyCharm

import redis
from settings import REDIS_CONFIG
from utils.Singleton import singleton


@singleton
class Redis:
    db = None

    def __init__(self):
        Redis.pool = redis.ConnectionPool(**REDIS_CONFIG)
        self.db = redis.Redis(connection_pool=Redis.pool)

    def __getattr__(self, key):
        def not_find(*args, **kwargs):
            return getattr(self.db, key)(*args, **kwargs)

        return not_find


if __name__ == '__main__':
    redis = Redis()
    redis.lpush('test', 'aaa')
    print(redis.rpop('test'))
Пример #11
0
redis.lpush("mylist","a","b","c")
#lrange
print("lrange")
lrange=redis.lrange("mylist",0,-1)
print(lrange)
#LPOP
print("Lpop")
lpop=redis.lpop("mylist")
print(lpop)
#lrange
print("lrange")
lrange=redis.lrange("mylist",0,-1)
print(lrange)
#RPOP
print("Rpop")
rpop=redis.rpop("mylist")
print(rpop)
#lrange
print("lrange")
lrange=redis.lrange("mylist",0,-1)
print(lrange)
#LSET
print("Lset")
redis.lset("mylist",-1,"lset")
#lrange
print("lrange")
lrange=redis.lrange("mylist",0,-1)
print(lrange)
#LREM
print("LREM")
redis.lrem("mylist",-1,"lset")
Пример #12
0
#!/usr/bin/env python
import redis
import time

redis = redis.Redis(host='127.0.0.1', port=6379, db=0)

while 1:
    res = redis.rpop("queue")
    if res is None:
        time.sleep(5)
    else:
        print('process started ' + res.decode())
    # начало выполнение работы
        time.sleep(10)
    # конец выполения работы
        redis.set('/status/' + res.decode(), '1', int(time.time()) + 10)
        print('process finished' + res.decode())
 
Пример #13
0
Файл: qr.py Проект: tavisrudd/qr
 def pop(self):
     """Pop an element"""
     popped = redis.rpop(self.key)
     log.debug('Popped ** %s ** from key ** %s **' % (popped, self.key))
     return popped 	
Пример #14
0
Файл: qr.py Проект: tavisrudd/qr
 def pop_front(self):
     """Pop an element from the front of the deque"""
     popped = redis.rpop(self.key)
     log.debug('Popped ** %s ** from key ** %s **' % (popped, self.key))
     return popped 
Пример #15
0
Файл: qr.py Проект: tavisrudd/qr
 def pop(self):
     popped = redis.rpop(self.key)
     log.debug('Popped ** %s ** from key ** %s **' % (popped, self.key))
     return popped
Пример #16
0
print(redis.get("counter")) # 2
redis.decr("counter")
print(redis.get("counter")) #1

# List : possible to duplicate values
redis.rpush("members", "r1") 
redis.rpush("members", "r2")
redis.lpush("members", "l1")
redis.lpush("members", "l2")
print(redis.lrange("members", 0, 0))
print(redis.lrange("members", 0, 1))
print(redis.lrange("members", 0, 2))
print(redis.llen("members"))
print(redis.lrange("members",0, redis.llen("members")-1))
print(redis.lindex("members",3))
print(redis.rpop("members"))
print(redis.lpop("members"))
print(redis.llen("members"))
print(redis.lrange("members",0, redis.llen("members")-1))
redis.delete("members") 

#Sets  : impossible to duplicate values
redis.sadd("members", "s1")
redis.sadd("members", "s1")
redis.sadd("members", "s2")
redis.sadd("members", "s3")
redis.sadd("members", "s4")
redis.sadd("members", "s5")
print(redis.smembers("members"))
redis.delete("members")