cleanup
This commit is contained in:
@ -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,7 +245,8 @@ class CachedProperty(object):
|
|||||||
|
|
||||||
|
|
||||||
def invalidate_cache(obj):
|
def invalidate_cache(obj):
|
||||||
obj._cached_properties = {}
|
if hasattr(obj, '_cached_properties'):
|
||||||
|
obj._cached_properties = {}
|
||||||
|
|
||||||
|
|
||||||
class Logger:
|
class Logger:
|
||||||
@ -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"""
|
||||||
@ -931,7 +929,7 @@ class ZfsDataset:
|
|||||||
|
|
||||||
# incremental?
|
# incremental?
|
||||||
if prev_snapshot:
|
if prev_snapshot:
|
||||||
cmd.extend(["-i", "@"+prev_snapshot.snapshot_name])
|
cmd.extend(["-i", "@" + prev_snapshot.snapshot_name])
|
||||||
|
|
||||||
cmd.append(self.name)
|
cmd.append(self.name)
|
||||||
|
|
||||||
@ -1461,7 +1459,7 @@ class ZfsNode(ExecuteNode):
|
|||||||
dataset.verbose("No changes since {}".format(dataset.our_snapshots[-1].snapshot_name))
|
dataset.verbose("No changes since {}".format(dataset.our_snapshots[-1].snapshot_name))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#force_exist, since we're making it
|
# force_exist, since we're making it
|
||||||
snapshot = ZfsDataset(dataset.zfs_node, dataset.name + "@" + snapshot_name, force_exists=True)
|
snapshot = ZfsDataset(dataset.zfs_node, dataset.name + "@" + snapshot_name, force_exists=True)
|
||||||
|
|
||||||
pool = dataset.split_path()[0]
|
pool = dataset.split_path()[0]
|
||||||
@ -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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user