diff --git a/swh/fuse/cache.py b/swh/fuse/cache.py --- a/swh/fuse/cache.py +++ b/swh/fuse/cache.py @@ -209,7 +209,7 @@ try: history.append(parse_swhid(parent)) except ValidationError: - logging.warning(f"Cannot parse object from history cache: {parent}") + logging.warning("Cannot parse object from history cache: %s", parent) return history async def set(self, history: str) -> None: @@ -265,7 +265,7 @@ def __init__(self, conf: Dict[str, Any]): m = re.match(r"(\d+)\s*(.+)\s*", conf["maxram"]) if not m: - logging.error(f"Cannot parse direntry maxram config: {conf['maxram']}") + logging.error("Cannot parse direntry maxram config: %s", conf["maxram"]) sys.exit(1) num = float(m.group(1)) diff --git a/swh/fuse/cli.py b/swh/fuse/cli.py --- a/swh/fuse/cli.py +++ b/swh/fuse/cli.py @@ -62,7 +62,7 @@ config_file = DEFAULT_CONFIG_PATH try: - logging.info(f"Loading configuration from: {config_file}") + logging.info("Loading configuration from: %s", config_file) conf = config.read_raw_config(config.config_basepath(config_file)) if not conf: raise ValueError(f"Cannot parse configuration file: {config_file}") @@ -76,10 +76,10 @@ # recursive merge not done by config.read conf = config.merge_configs(DEFAULT_CONFIG, conf) except Exception as err: - logging.warning(f"Using default configuration (cannot load custom one: {err})") + logging.warning("Using default configuration (cannot load custom one: %s)", err) conf = DEFAULT_CONFIG - logging.info(f"Read configuration: \n{pprint.pformat(conf)}") + logging.info("Read configuration: \n%s", pprint.pformat(conf)) ctx.ensure_object(dict) ctx.obj["config"] = conf @@ -177,8 +177,9 @@ subprocess.run(["fusermount", "-u", path], check=True) except subprocess.CalledProcessError as err: logging.error( - f"cannot unmount virtual file system: " - f"\"{' '.join(err.cmd)}\" returned exit status {err.returncode}" + "cannot unmount virtual file system: '%s' returned exit status %d", + " ".join(err.cmd), + err.returncode, ) ctx.exit(1) diff --git a/swh/fuse/fuse.py b/swh/fuse/fuse.py --- a/swh/fuse/fuse.py +++ b/swh/fuse/fuse.py @@ -85,7 +85,7 @@ # Retrieve it from cache so it is correctly typed return await self.cache.metadata.get(swhid) except requests.HTTPError as err: - logging.error(f"Cannot fetch metadata for object {swhid}: {err}") + logging.error("Cannot fetch metadata for object %s: %s", swhid, err) raise async def get_blob(self, swhid: SWHID) -> bytes: @@ -109,7 +109,7 @@ await self.cache.blob.set(swhid, blob) return blob except requests.HTTPError as err: - logging.error(f"Cannot fetch blob for object {swhid}: {err}") + logging.error("Cannot fetch blob for object %s: %s", swhid, err) raise async def get_history(self, swhid: SWHID) -> List[SWHID]: @@ -129,7 +129,7 @@ # Retrieve it from cache so it is correctly typed return await self.cache.history.get(swhid) except requests.HTTPError as err: - logging.error(f"Cannot fetch history for object {swhid}: {err}") + logging.error("Cannot fetch history for object %s: %s", swhid, err) # Ignore exception since swh-graph does not necessarily contain the # most recent artifacts from the archive. Computing the full history # from the Web API is too computationally intensive so simply return @@ -184,7 +184,7 @@ next_id += 1 self._inode2entry[attrs.st_ino] = entry except Exception as err: - logging.exception(f"Cannot readdir: {err}") + logging.exception("Cannot readdir: %s", err) raise pyfuse3.FUSEError(errno.ENOENT) async def open( @@ -207,7 +207,7 @@ data = await entry.get_content() return data[offset : offset + length] except Exception as err: - logging.exception(f"Cannot read: {err}") + logging.exception("Cannot read: %s", err) raise pyfuse3.FUSEError(errno.ENOENT) async def lookup( @@ -225,7 +225,7 @@ else: raise ValueError(f"unknown name: {name}") except Exception as err: - logging.exception(f"Cannot lookup: {err}") + logging.exception("Cannot lookup: %s", err) raise pyfuse3.FUSEError(errno.ENOENT) async def readlink(self, inode: int, _ctx: pyfuse3.RequestContext) -> bytes: @@ -248,7 +248,7 @@ try: await fs.get_metadata(swhid) except Exception as err: - logging.exception(f"Cannot prefetch object {swhid}: {err}") + logging.exception("Cannot prefetch object %s: %s", swhid, err) fuse_options = set(pyfuse3.default_options) fuse_options.add("fsname=swhfs") @@ -259,7 +259,7 @@ pyfuse3.init(fs, root_path, fuse_options) await pyfuse3.main() except Exception as err: - logging.error(f"Error running FUSE: {err}") + logging.error("Error running FUSE: %s", err) finally: fs.shutdown() pyfuse3.close(unmount=True)