This commit is contained in:
Edwin Eefting 2019-10-22 21:59:01 +02:00
parent 34d0c5d67b
commit 052890a7e0

View File

@ -200,49 +200,49 @@ class Thinner:
######### Thinner testing code # ######### Thinner testing code
now=int(time.time()) # now=int(time.time())
#
t=Thinner("1d1w,1w1m,1m6m,1y2y", always_keep=1) # t=Thinner("1d1w,1w1m,1m6m,1y2y", always_keep=1)
#
import random # import random
#
class Thing: # class Thing:
def __init__(self, timestamp): # def __init__(self, timestamp):
self.timestamp=timestamp # self.timestamp=timestamp
#
def __str__(self): # def __str__(self):
age=now-self.timestamp # age=now-self.timestamp
struct=time.localtime(self.timestamp) # struct=time.localtime(self.timestamp)
return("{} ({} days old)".format(time.strftime("%Y-%m-%d %H:%M:%S",struct),int(age/(3600*24)))) # return("{} ({} days old)".format(time.strftime("%Y-%m-%d %H:%M:%S",struct),int(age/(3600*24))))
#
def test(): # def test():
global now # global now
things=[] # things=[]
#
while True: # while True:
print("#################### {}".format(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(now)))) # print("#################### {}".format(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(now))))
#
(keeps, removes)=t.run(things, now) # (keeps, removes)=t.run(things, now)
#
print ("### KEEP ") # print ("### KEEP ")
for thing in keeps: # for thing in keeps:
print(thing) # print(thing)
#
print ("### REMOVE ") # print ("### REMOVE ")
for thing in removes: # for thing in removes:
print(thing) # print(thing)
#
things=keeps # things=keeps
#
#increase random amount of time and maybe add a thing # #increase random amount of time and maybe add a thing
now=now+random.randint(0,160000) # now=now+random.randint(0,160000)
if random.random()>=0: # if random.random()>=0:
things.append(Thing(now)) # things.append(Thing(now))
#
sys.stdin.readline() # sys.stdin.readline()
#
test() # test()
@ -1004,28 +1004,5 @@ class ZfsAutobackup:
raise raise
#times=[] zfs_autobackup=ZfsAutobackup()
zfs_autobackup.run()
#
# test()
#
#
#
#
#
#
#
#
# now=time.time()
# time_str=re.findall("^.*-([0-9]*)$", snapshot)[0]
# if len(time_str)==14:
# #new format:
# time_secs=time.mktime(time.strptime(time_str,"%Y%m%d%H%M%S"))
#
#
# zfs_autobackup=ZfsAutobackup()
# zfs_autobackup.run()