This commit is contained in:
Edwin Eefting
2021-02-06 12:44:03 +01:00
parent 427f74d2f0
commit 35584149ff

View File

@ -33,7 +33,8 @@ class Log:
self.show_debug = show_debug self.show_debug = show_debug
self.show_verbose = show_verbose self.show_verbose = show_verbose
def error(self, txt): @staticmethod
def error(txt):
if colorama: if colorama:
print(colorama.Fore.RED + colorama.Style.BRIGHT + "! " + txt + colorama.Style.RESET_ALL, file=sys.stderr) print(colorama.Fore.RED + colorama.Style.BRIGHT + "! " + txt + colorama.Style.RESET_ALL, file=sys.stderr)
else: else:
@ -227,7 +228,6 @@ class CachedProperty(object):
self.__doc__ = getattr(func, '__doc__') self.__doc__ = getattr(func, '__doc__')
self.func = func self.func = func
def __get__(self, obj, cls): def __get__(self, obj, cls):
if obj is None: if obj is None:
return self return self
@ -245,6 +245,7 @@ class CachedProperty(object):
def invalidate_cache(obj): def invalidate_cache(obj):
if hasattr(obj, '_cached_properties'):
obj._cached_properties = {} obj._cached_properties = {}
@ -540,7 +541,6 @@ class ZfsDataset:
self.name = name # full name self.name = name # full name
self.force_exists = force_exists self.force_exists = force_exists
def __repr__(self): def __repr__(self):
return "{}: {}".format(self.zfs_node, self.name) return "{}: {}".format(self.zfs_node, self.name)
@ -564,7 +564,6 @@ class ZfsDataset:
def invalidate(self): def invalidate(self):
"""clear cache""" """clear cache"""
# TODO: nicer?
invalidate_cache(self) invalidate_cache(self)
self.force_exists = None self.force_exists = None
@ -777,7 +776,6 @@ class ZfsDataset:
"""add to self.snapshots as soon as it is created""" """add to self.snapshots as soon as it is created"""
pass pass
@CachedProperty @CachedProperty
def snapshots(self): def snapshots(self):
"""get all snapshots of this dataset""" """get all snapshots of this dataset"""
@ -1649,7 +1647,7 @@ class ZfsAutobackup:
if args.resume: if args.resume:
self.verbose("NOTE: The --resume option isn't needed anymore (its autodetected now)") self.verbose("NOTE: The --resume option isn't needed anymore (its autodetected now)")
if args.target_path!=None and args.target_path[0] == "/": if args.target_path is not None and args.target_path[0] == "/":
self.log.error("Target should not start with a /") self.log.error("Target should not start with a /")
sys.exit(255) sys.exit(255)