Use % formatting in log messages over f-strings

This commit is contained in:
Eric Torres 2019-05-01 12:01:52 -07:00
parent f33cf3c8a9
commit 6c87f3dac1
4 changed files with 8 additions and 8 deletions

View File

@ -34,7 +34,7 @@ def rsync(*args):
""" """
cmd = [_RSYNC_BIN, *args] cmd = [_RSYNC_BIN, *args]
syslog.debug(f"rsync command: {cmd}") syslog.debug("rsync command: %s", cmd)
syslog.info("Beginning rsync process") syslog.info("Beginning rsync process")
process = subprocess.run(cmd, capture_output=True, check=True, text=True) process = subprocess.run(cmd, capture_output=True, check=True, text=True)

View File

@ -75,6 +75,6 @@ def do_backup(repository, parsed_config, args, extra_rsync_opts=None):
exit(E_INVALID_SNAPSHOT_NAME) exit(E_INVALID_SNAPSHOT_NAME)
except CalledProcessError as e: except CalledProcessError as e:
syslog.critical("Backup process failed") syslog.critical("Backup process failed")
syslog.critical(f"Failing command: {e.cmd}") syslog.critical("Failing command: %s", e.cmd)
syslog.critical(e.stderr) syslog.critical(e.stderr)
exit(e.returncode) exit(e.returncode)

View File

@ -101,7 +101,7 @@ class Hierarchy(os.PathLike):
def cleanup(self, **kwargs): def cleanup(self, **kwargs):
"""Clean up this Hierarchy's data from the filesystem.""" """Clean up this Hierarchy's data from the filesystem."""
syslog.info(f"Performing cleanup on {self._path}") syslog.info("Performing cleanup on %s", self._path)
# We don't want to risk symlink attacks # We don't want to risk symlink attacks
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
@ -119,7 +119,7 @@ class Hierarchy(os.PathLike):
:rtype: type that the data is serialized as :rtype: type that the data is serialized as
""" """
syslog.debug(f"Reading metadata from {self.metadata_path}") syslog.debug("Reading metadata from %s", self.metadata_path)
with self.metadata_path.open(mode=METADATA_READ) as mfile: with self.metadata_path.open(mode=METADATA_READ) as mfile:
return json.load(mfile) return json.load(mfile)
@ -131,7 +131,7 @@ class Hierarchy(os.PathLike):
:param attr: class data to write to file :param attr: class data to write to file
:type attr: any type :type attr: any type
""" """
syslog.debug(f"Writing metadata to {self.metadata_path}") syslog.debug("Writing metadata to %s", self.metadata_path)
tmpfile = self.metadata_path.with_suffix(".tmp") tmpfile = self.metadata_path.with_suffix(".tmp")

View File

@ -232,7 +232,7 @@ class Repository(Hierarchy):
self.metadata_path.unlink() self.metadata_path.unlink()
self.snapshot_symlink.unlink() self.snapshot_symlink.unlink()
syslog.info("Removing repository metadata") syslog.info("Removing repository metadata")
syslog.debug(f"Repository metadata removed: {self.metadata_path}") syslog.debug("Repository metadata removed: %s", self.metadata_path)
if remove_snapshots: if remove_snapshots:
try: try:
@ -248,7 +248,7 @@ class Repository(Hierarchy):
except PermissionError as e: except PermissionError as e:
syslog.error(e) syslog.error(e)
else: else:
syslog.info(f"Removed repository directory: {self.path}") syslog.info("Removed repository directory: %s", self.path)
def create_snapshot(self, name=None): def create_snapshot(self, name=None):
"""Create a new snapshot in this repository. """Create a new snapshot in this repository.
@ -295,7 +295,7 @@ class Repository(Hierarchy):
self.write_metadata(self._snapshot_metadata) self.write_metadata(self._snapshot_metadata)
syslog.debug("Snapshot created") syslog.debug("Snapshot created")
syslog.debug(f"Snapshot name: {new_snapshot.name}") syslog.debug("Snapshot name: %s", new_snapshot.name)
self.symlink_snapshot(new_snapshot) self.symlink_snapshot(new_snapshot)
return new_snapshot return new_snapshot