Exemplo n.º 1
0
def key_check_new():
    logging.info('----------开始更新----------')
    base_dir = Config.get_config_field()['updating_dir']
    updating_list = os.listdir(base_dir)
    # start_index = updating_list.index('NTRD') + 1
    for key in updating_list:
        try:
            start = Utility.find_num(DBItemService.db_find_max_code(key)) + 1
            global retry
            retry = 0
            for cur_num in range(start, 1000):
                item = Item(key, cur_num)
                if retry > int(Config.get_config_field()["retry_times"]):
                    logging.info("番号处理完毕" + key)
                    break
                search_by_code(item, True, 'updating')
                if cur_num % 20 == 0:
                    DBItemService.db_commit(item.get_key)
        except Exception as e:
            logging.error(e)
        finally:
            DBItemService.db_commit(key)

            db_key = DBKeyService.copy_to_db(key)
            DBKeyService.db_update(db_key)
            DBKeyService.db_commit(db_key.key_)

            Utility.delete_extra_file(key, 'updating')
    logging.info('----------更新结束----------')
Exemplo n.º 2
0
def search_keys():
    logging.info('----------开始按Key搜索----------')
    for keyset in Config.get_key_list():
        if not os.path.exists(keyset.get_key_path):
            os.makedirs(keyset.get_key_path)
        global retry
        retry = 0
        for cur_num in range(keyset.get_start, keyset.get_end):
            item = Item(keyset.get_key, cur_num)
            if retry > int(Config.get_config_field()["retry_times"]):
                logging.info("番号处理完毕" + keyset.get_key)
                break
            search_by_code(item, True, 'download')
            if cur_num % 20 == 0:
                DBItemService.db_commit(item.get_key)
        DBItemService.db_commit(keyset.get_key)
        Utility.delete_extra_file(keyset.get_key, 'download')
    logging.info('----------按Key搜索结束----------')