Esempio n. 1
0
def fetch(request):
    leancloud.init(LEAN_CLOUD_ID, LEAN_CLOUD_SECRET)

    query = leancloud.Query('Chairman')

    allDataCompleted = False
    batch = 0
    limit = 1000
    while not allDataCompleted:
        query.limit(limit)
        query.skip(batch * limit)
        query.add_ascending('createdAt')
        resultList = query.find()
        if len(resultList) < limit:
            allDataCompleted = True
            leancloud.Object.destroy_all(resultList)
        batch += 1

    fetcher = Fetcher()
    fetcher.fetch_cc()
    fetcher.fetch_douyu()
    fetcher.fetch_longzhu()
    fetcher.fetch_quanmin()
    fetcher.fetch_xiongmao()
    fetcher.fetch_zhanqi()
    fetcher.fetch_huya()

    for chairman in fetcher.chairmans:
        try:
            chairman.save()
        except Exception, e:
            print e
Esempio n. 2
0
    def handle(self, *args, **options):
        redis_instance = redis.StrictRedis(host=REDIS_HOST,
                                           db=REDIS_DB,
                                           password=REDIS_PASSWORD)
        # redis_instance = redis.StrictRedis(host='127.0.0.1', db=7)
        for key in redis_instance.scan_iter("Chairman:*"):
            redis_instance.delete(key)

        fetcher = Fetcher()
        fetcher.fetch_cc()
        fetcher.fetch_douyu()
        fetcher.fetch_longzhu()
        fetcher.fetch_quanmin()
        fetcher.fetch_xiongmao()
        fetcher.fetch_zhanqi()
        fetcher.fetch_huya()

        for chairman in fetcher.chairmans:
            try:
                if chairman.is_valid():
                    chairman.save()
                else:
                    print chairman.errors
            except Exception, e:
                print e
Esempio n. 3
0
def refresh_rank():
    redis_instance = redis.StrictRedis(host=REDIS_HOST, db=REDIS_DB, password=REDIS_PASSWORD)
    for key in redis_instance.scan_iter("Chairman:*"):
        redis_instance.delete(key)

    fetcher = Fetcher()
    fetcher.fetch_cc()
    fetcher.fetch_douyu()
    fetcher.fetch_longzhu()
    fetcher.fetch_quanmin()
    fetcher.fetch_xiongmao()
    fetcher.fetch_zhanqi()
    fetcher.fetch_huya()

    for chairman in fetcher.chairmans:
        if chairman.is_valid():
            chairman.save()
        else:
            print chairman.errors
Esempio n. 4
0
def fetch(request):
    fetcher = Fetcher()
    fetcher.fetch_cc()
    fetcher.fetch_douyu()
    fetcher.fetch_longzhu()
    fetcher.fetch_quanmin()
    fetcher.fetch_xiongmao()
    fetcher.fetch_zhanqi()
    fetcher.fetch_huya()

    # chairmans_set = SortedSet('chairmans_set')
    # charimans_hash = Hash('chairmans_hash')
    for chairman in fetcher.chairmans:
        try:
            if chairman.is_valid():
                # charimans_hash[chairman.id] = chairman
                # chairmans_set.add(chairman, chairman.num)
                chairman.save()
            else:
                print chairman.errors
        except Exception, e:
            print e