[IMP]Odoo backups plan : usage of env OBPLAN
This commit is contained in:
parent
c3962fc74a
commit
1ed86ce696
@ -12,9 +12,12 @@ Keep :
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from os import unlink
|
||||
from os import unlink, environ
|
||||
from glob import glob
|
||||
|
||||
OBPLAN = environ.get('OBPLAN', u'365,31,7')
|
||||
OBPLAN = map(int, OBPLAN.split(u','))
|
||||
|
||||
DT = datetime.now()
|
||||
|
||||
def notkeep(fname):
|
||||
@ -26,12 +29,12 @@ def notkeep(fname):
|
||||
save_date = fname[0]
|
||||
save_date = datetime.strptime(save_date, '%Y-%m-%d')
|
||||
delta = DT - save_date
|
||||
if delta.days > 365:
|
||||
if delta.days > OBPLAN[0]:
|
||||
return True
|
||||
elif delta.days > 31:
|
||||
elif delta.days > OBPLAN[1]:
|
||||
if save_date.day != 1:
|
||||
return True
|
||||
elif delta.days > 7:
|
||||
elif delta.days > OBPLAN[2]:
|
||||
if (save_date.weekday() != 0) and (save_date.day != 1):
|
||||
return True
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user