Exemple #1
0
def monitor_download_status():
    redis_queue = RedisMsgQueue()
    while True:
        all_files_old_json = redis_queue.hash_get_all(
            consts.constant_manager.DOWNLOAD_STATUS_QUEUE_NAME)
        for hash_sign in all_files_old_json.keys():
            all_files_old_json[hash_sign] = from_string_to_json(
                all_files_old_json[hash_sign])
            all_files_old_json[hash_sign]['now_size'] = get_file_size(
                all_files_old_json[hash_sign]['absolute_path'])
        time.sleep(10)  # 5分钟下载中文件大小不变化,认为下载服务异常挂掉,删除下载队列
        all_files_new_json = redis_queue.hash_get_all(
            consts.constant_manager.DOWNLOAD_STATUS_QUEUE_NAME)
        for hash_sign in all_files_new_json:
            all_files_new_json[hash_sign] = from_string_to_json(
                all_files_new_json[hash_sign])
            all_files_new_json[hash_sign]['now_size'] = get_file_size(
                all_files_new_json[hash_sign]['absolute_path'])
            if int(all_files_new_json[hash_sign]['now_size']) - int(
                    all_files_old_json[hash_sign]['now_size']) == 0:
                redis_queue.hash_del(
                    consts.constant_manager.DOWNLOAD_STATUS_QUEUE_NAME,
                    hash_sign)
        logging.debug('monitor download queue')
    pass
Exemple #2
0
def downloading(file_name):
    # todo:兼容其他是否下載的驗證方式
    redis_queue = RedisMsgQueue()
    if get_hash_sign(file_name) in redis_queue.hash_get_all(
            consts.constant_manager.DOWNLOAD_STATUS_QUEUE_NAME).keys():
        return True
    return False
Exemple #3
0
def demo_redis():
    redis_queue = RedisMsgQueue()
    aa = redis_queue.hash_get_all(
        consts.constant_manager.DOWNLOAD_STATUS_QUEUE_NAME)
    pass