1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 17:57:59 +00:00

blacken the code

This commit is contained in:
Thomas Waldmann 2024-08-27 02:46:13 +02:00
parent ec1d89f477
commit a40978ae1b
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
6 changed files with 26 additions and 23 deletions

View file

@ -582,14 +582,13 @@ def main(): # pragma: no cover
# Register fault handler for SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL. # Register fault handler for SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL.
faulthandler.enable() faulthandler.enable()
with signal_handler("SIGINT", raising_signal_handler(KeyboardInterrupt)), signal_handler( with (
"SIGHUP", raising_signal_handler(SigHup) signal_handler("SIGINT", raising_signal_handler(KeyboardInterrupt)),
), signal_handler("SIGTERM", raising_signal_handler(SigTerm)), signal_handler( signal_handler("SIGHUP", raising_signal_handler(SigHup)),
"SIGUSR1", sig_info_handler signal_handler("SIGTERM", raising_signal_handler(SigTerm)),
), signal_handler( signal_handler("SIGUSR1", sig_info_handler),
"SIGUSR2", sig_trace_handler signal_handler("SIGUSR2", sig_trace_handler),
), signal_handler( signal_handler("SIGINFO", sig_info_handler),
"SIGINFO", sig_info_handler
): ):
archiver = Archiver() archiver = Archiver()
msg = msgid = tb = None msg = msgid = tb = None

View file

@ -39,13 +39,9 @@ def garbage_collect(self):
logger.info("Getting object IDs present in the repository...") logger.info("Getting object IDs present in the repository...")
self.repository_chunks = self.get_repository_chunks() self.repository_chunks = self.get_repository_chunks()
logger.info("Computing object IDs used by archives...") logger.info("Computing object IDs used by archives...")
( (self.used_chunks, self.wanted_chunks, self.total_files, self.total_size, self.archives_count) = (
self.used_chunks, self.analyze_archives()
self.wanted_chunks, )
self.total_files,
self.total_size,
self.archives_count,
) = self.analyze_archives()
self.report_and_delete() self.report_and_delete()
logger.info("Finished compaction / garbage collection...") logger.info("Finished compaction / garbage collection...")
@ -134,7 +130,9 @@ def report_and_delete(self):
count = len(self.repository_chunks) count = len(self.repository_chunks)
logger.info(f"Overall statistics, considering all {self.archives_count} archives in this repository:") logger.info(f"Overall statistics, considering all {self.archives_count} archives in this repository:")
logger.info(f"Source data size was {format_file_size(self.total_size, precision=0)} in {self.total_files} files.") logger.info(
f"Source data size was {format_file_size(self.total_size, precision=0)} in {self.total_files} files."
)
dsize = sum(self.used_chunks[id] for id in self.repository_chunks) dsize = sum(self.used_chunks[id] for id in self.repository_chunks)
logger.info(f"Repository size is {format_file_size(self.repository_size, precision=0)} in {count} objects.") logger.info(f"Repository size is {format_file_size(self.repository_size, precision=0)} in {count} objects.")
if self.total_size != 0: if self.total_size != 0:

View file

@ -5,6 +5,7 @@
Code used to be in borg/helpers.py but was split into the modules in this Code used to be in borg/helpers.py but was split into the modules in this
package, which are imported into here for compatibility. package, which are imported into here for compatibility.
""" """
import os import os
from typing import List from typing import List
from collections import namedtuple from collections import namedtuple

View file

@ -82,9 +82,11 @@ def daemonizing(*, timeout=5):
logger.debug("Daemonizing: Foreground process (%s, %s, %s) is waiting for background process..." % old_id) logger.debug("Daemonizing: Foreground process (%s, %s, %s) is waiting for background process..." % old_id)
exit_code = EXIT_SUCCESS exit_code = EXIT_SUCCESS
# Indeed, SIGHUP and SIGTERM handlers should have been set on archiver.run(). Just in case... # Indeed, SIGHUP and SIGTERM handlers should have been set on archiver.run(). Just in case...
with signal_handler("SIGINT", raising_signal_handler(KeyboardInterrupt)), signal_handler( with (
"SIGHUP", raising_signal_handler(SigHup) signal_handler("SIGINT", raising_signal_handler(KeyboardInterrupt)),
), signal_handler("SIGTERM", raising_signal_handler(SigTerm)): signal_handler("SIGHUP", raising_signal_handler(SigHup)),
signal_handler("SIGTERM", raising_signal_handler(SigTerm)),
):
try: try:
if timeout > 0: if timeout > 0:
time.sleep(timeout) time.sleep(timeout)

View file

@ -14,6 +14,7 @@
if the directory does not exist, the test will be skipped. if the directory does not exist, the test will be skipped.
""" """
import errno import errno
import os import os
import random import random

View file

@ -32,16 +32,18 @@ def test_fuse_mount_hardlinks(archivers, request):
ignore_perms = ["-o", "ignore_permissions,defer_permissions"] ignore_perms = ["-o", "ignore_permissions,defer_permissions"]
else: else:
ignore_perms = ["-o", "ignore_permissions"] ignore_perms = ["-o", "ignore_permissions"]
with fuse_mount(archiver, mountpoint, "-a", "test", "--strip-components=2", *ignore_perms), changedir( with (
os.path.join(mountpoint, "test") fuse_mount(archiver, mountpoint, "-a", "test", "--strip-components=2", *ignore_perms),
changedir(os.path.join(mountpoint, "test")),
): ):
assert os.stat("hardlink").st_nlink == 2 assert os.stat("hardlink").st_nlink == 2
assert os.stat("subdir/hardlink").st_nlink == 2 assert os.stat("subdir/hardlink").st_nlink == 2
assert open("subdir/hardlink", "rb").read() == b"123456" assert open("subdir/hardlink", "rb").read() == b"123456"
assert os.stat("aaaa").st_nlink == 2 assert os.stat("aaaa").st_nlink == 2
assert os.stat("source2").st_nlink == 2 assert os.stat("source2").st_nlink == 2
with fuse_mount(archiver, mountpoint, "input/dir1", "-a", "test", *ignore_perms), changedir( with (
os.path.join(mountpoint, "test") fuse_mount(archiver, mountpoint, "input/dir1", "-a", "test", *ignore_perms),
changedir(os.path.join(mountpoint, "test")),
): ):
assert os.stat("input/dir1/hardlink").st_nlink == 2 assert os.stat("input/dir1/hardlink").st_nlink == 2
assert os.stat("input/dir1/subdir/hardlink").st_nlink == 2 assert os.stat("input/dir1/subdir/hardlink").st_nlink == 2