예제 #1
0
def delete_easy_logs_cache():
    dtu.get_cached(EasyLogsConstants.CACHE_LOCAL,
                   lambda: None,
                   just_delete=True)
    dtu.get_cached(EasyLogsConstants.CACHE_CLOUD,
                   lambda: None,
                   just_delete=True)

    cache_dir = dtu.get_duckietown_cache_dir()
    fn = os.path.join(cache_dir, "candidate_cloud.yaml")

    if os.path.exists(fn):
        dtu.logger.info(f"Removing {fn}")
        os.unlink(fn)
예제 #2
0
def rosbag_info_cached(filename: str) -> BagInfoDict:
    def f():
        return rosbag_info(filename)

    basename = os.path.basename(filename)
    cache_name = "rosbag_info/" + basename
    return get_cached(cache_name, f, quiet=True)
예제 #3
0
def get_easy_algo_db() -> EasyAlgoDB:
    if EasyAlgoDB._singleton is None:
        cache_algos = dtu.DuckietownConstants.use_cache_for_algos
        EasyAlgoDB._singleton = (dtu.get_cached("EasyAlgoDB", EasyAlgoDB)
                                 if cache_algos else EasyAlgoDB(
                                     use_as_singleton=True))
    return EasyAlgoDB._singleton
예제 #4
0
def get_ipfs_hash_cached(filename):
    def f():
        return get_ipfs_hash(filename)

    basename = os.path.basename(filename)
    cache_name = "get_ipfs_hash/" + basename
    return dtu.get_cached(cache_name, f, quiet=True)
예제 #5
0
def get_easy_logs_db2(do_not_use_cloud: bool, do_not_use_local: bool,
                      ignore_cache: bool):
    if ignore_cache:
        delete_easy_logs_cache()

    db = EasyLogsDB()

    if not do_not_use_cloud:
        logs_cloud = dtu.get_cached(EasyLogsConstants.CACHE_CLOUD,
                                    get_logs_cloud,
                                    just_delete=False)
        assert isinstance(logs_cloud, dict)
        db.update_logs(logs_cloud)

    if not do_not_use_local:
        logs_local = dtu.get_cached(EasyLogsConstants.CACHE_LOCAL,
                                    get_logs_local,
                                    just_delete=False)
        db.update_logs(logs_local)

    return db
예제 #6
0
def get_config_db() -> ConfigDB:
    if ConfigDB._singleton is None:
        ConfigDB._singleton = dtu.get_cached("ConfigDB", ConfigDB)
    return ConfigDB._singleton
예제 #7
0
def invalidate_log_cache_because_downloaded():
    dtu.get_cached(EasyLogsConstants.CACHE_LOCAL,
                   lambda: None,
                   just_delete=True)