mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-09 13:53:09 +00:00
extend errorlist script to warnings, update docs
This commit is contained in:
parent
2fda86ce61
commit
775b9f5560
3 changed files with 45 additions and 11 deletions
|
@ -689,9 +689,20 @@ Errors
|
||||||
Could not verify manifest: Unsupported suite {!r}; a newer version is needed.
|
Could not verify manifest: Unsupported suite {!r}; a newer version is needed.
|
||||||
|
|
||||||
Warnings
|
Warnings
|
||||||
|
BorgWarning rc: 1
|
||||||
|
Warning: {}
|
||||||
FileChangedWarning rc: 100
|
FileChangedWarning rc: 100
|
||||||
|
{}: file changed while we backed it up
|
||||||
IncludePatternNeverMatchedWarning rc: 101
|
IncludePatternNeverMatchedWarning rc: 101
|
||||||
BackupExcWarning rc: 102 (needs more work!)
|
Include pattern '{}' never matched.
|
||||||
|
BackupWarning rc: 102
|
||||||
|
{}: {}
|
||||||
|
BackupOSWarning rc: 104
|
||||||
|
{}: {}
|
||||||
|
PermissionWarning rc: 105
|
||||||
|
{}: {}
|
||||||
|
IOWarning rc: 106
|
||||||
|
{}: {}
|
||||||
|
|
||||||
Operations
|
Operations
|
||||||
- cache.begin_transaction
|
- cache.begin_transaction
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
from textwrap import indent
|
from textwrap import indent
|
||||||
|
|
||||||
import borg.archiver # noqa: F401 - need import to get Error subclasses.
|
import borg.archiver # noqa: F401 - need import to get Error subclasses.
|
||||||
from borg.helpers import Error
|
from borg.constants import * # NOQA
|
||||||
|
from borg.helpers import Error, BorgWarning
|
||||||
|
|
||||||
|
|
||||||
def subclasses(cls):
|
def subclasses(cls):
|
||||||
|
@ -17,26 +18,46 @@ def subclasses(cls):
|
||||||
# 3..99 are available for specific errors
|
# 3..99 are available for specific errors
|
||||||
# 100..127 are available for specific warnings
|
# 100..127 are available for specific warnings
|
||||||
# 128+ are reserved for signals
|
# 128+ are reserved for signals
|
||||||
free_rcs = set(range(3, 99+1)) # 3 .. 99 (we only deal with errors here)
|
free_error_rcs = set(range(EXIT_ERROR_BASE, EXIT_WARNING_BASE)) # 3 .. 99
|
||||||
|
free_warning_rcs = set(range(EXIT_WARNING_BASE, EXIT_SIGNAL_BASE)) # 100 .. 127
|
||||||
|
|
||||||
# these classes map to rc 2
|
# these classes map to rc 2
|
||||||
generic_rc_classes = set()
|
generic_error_rc_classes = set()
|
||||||
|
generic_warning_rc_classes = set()
|
||||||
|
|
||||||
classes = {Error}.union(subclasses(Error))
|
error_classes = {Error}.union(subclasses(Error))
|
||||||
|
|
||||||
for cls in sorted(classes, key=lambda cls: (cls.__module__, cls.__qualname__)):
|
for cls in sorted(error_classes, key=lambda cls: (cls.__module__, cls.__qualname__)):
|
||||||
traceback = "yes" if cls.traceback else "no"
|
traceback = "yes" if cls.traceback else "no"
|
||||||
rc = cls.exit_mcode
|
rc = cls.exit_mcode
|
||||||
print(' ', cls.__qualname__, 'rc:', rc, 'traceback:', traceback)
|
print(' ', cls.__qualname__, 'rc:', rc, 'traceback:', traceback)
|
||||||
print(indent(cls.__doc__, ' ' * 8))
|
print(indent(cls.__doc__, ' ' * 8))
|
||||||
if rc in free_rcs:
|
if rc in free_error_rcs:
|
||||||
free_rcs.remove(rc)
|
free_error_rcs.remove(rc)
|
||||||
elif rc == 2:
|
elif rc == 2:
|
||||||
generic_rc_classes.add(cls.__qualname__)
|
generic_error_rc_classes.add(cls.__qualname__)
|
||||||
else: # rc != 2
|
else: # rc != 2
|
||||||
# if we did not intentionally map this to the generic error rc, this might be an issue:
|
# if we did not intentionally map this to the generic error rc, this might be an issue:
|
||||||
print(f'ERROR: {rc} is not a free/available RC, but either duplicate or invalid')
|
print(f'ERROR: {rc} is not a free/available RC, but either duplicate or invalid')
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print('free RCs:', sorted(free_rcs))
|
print('free error RCs:', sorted(free_error_rcs))
|
||||||
print('generic errors:', sorted(generic_rc_classes))
|
print('generic errors:', sorted(generic_error_rc_classes))
|
||||||
|
|
||||||
|
warning_classes = {BorgWarning}.union(subclasses(BorgWarning))
|
||||||
|
|
||||||
|
for cls in sorted(warning_classes, key=lambda cls: (cls.__module__, cls.__qualname__)):
|
||||||
|
rc = cls.exit_mcode
|
||||||
|
print(' ', cls.__qualname__, 'rc:', rc)
|
||||||
|
print(indent(cls.__doc__, ' ' * 8))
|
||||||
|
if rc in free_warning_rcs:
|
||||||
|
free_warning_rcs.remove(rc)
|
||||||
|
elif rc == 1:
|
||||||
|
generic_warning_rc_classes.add(cls.__qualname__)
|
||||||
|
else: # rc != 1
|
||||||
|
# if we did not intentionally map this to the generic warning rc, this might be an issue:
|
||||||
|
print(f'ERROR: {rc} is not a free/available RC, but either duplicate or invalid')
|
||||||
|
|
||||||
|
print("\n")
|
||||||
|
print('free warning RCs:', sorted(free_warning_rcs))
|
||||||
|
print('generic warnings:', sorted(generic_warning_rc_classes))
|
||||||
|
|
|
@ -124,10 +124,12 @@ class BackupOSWarning(BorgWarning):
|
||||||
|
|
||||||
|
|
||||||
class PermissionWarning(BorgWarning):
|
class PermissionWarning(BorgWarning):
|
||||||
|
"""{}: {}"""
|
||||||
exit_mcode = 105
|
exit_mcode = 105
|
||||||
|
|
||||||
|
|
||||||
class IOWarning(BorgWarning):
|
class IOWarning(BorgWarning):
|
||||||
|
"""{}: {}"""
|
||||||
exit_mcode = 106
|
exit_mcode = 106
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue