|
|
|
@ -192,13 +192,15 @@ class Folders(Actor):
|
|
|
|
|
This function will archive all files in a given folder
|
|
|
|
|
@pre : isValid
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
folder = item['label']
|
|
|
|
|
name = folder.split(os.sep)
|
|
|
|
|
name = name[len(name)-1]
|
|
|
|
|
signature='-'.join([name,str(item['date']),str(item['count']),'files'])
|
|
|
|
|
date = ''.join([str(i) for i in item['date'].values()])
|
|
|
|
|
signature='-'.join([name,date,str(item['stats']['file_count']),'files'])
|
|
|
|
|
tarball=os.sep.join([folder,'..',signature])
|
|
|
|
|
shutil.make_archive(tarball,'tar',folder)
|
|
|
|
|
self.clean(item)
|
|
|
|
|
#self.clean(item)
|
|
|
|
|
#
|
|
|
|
|
# @TODO: The archive can be uploaded to the cloud or else where
|
|
|
|
|
# @param id cloud service idenfier {dropbox,box,google-drive,one-drive}
|
|
|
|
@ -239,15 +241,19 @@ class Folders(Actor):
|
|
|
|
|
This function returns whether the following :
|
|
|
|
|
p : folder exists
|
|
|
|
|
q : has_reached threashold
|
|
|
|
|
|
|
|
|
|
@TODO: Add a user defined configuration element to make this happen
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
p = os.path.exists(item['label']) and item['label'] in self.lfolders
|
|
|
|
|
q = self.get_size(item['size']) >= self.threshold
|
|
|
|
|
q = item['stats']['size']['mean'] >= self.threshold and self.threshold > 0
|
|
|
|
|
return p and q
|
|
|
|
|
|
|
|
|
|
def analyze(self,logs):
|
|
|
|
|
r = {'clean':self.clean,'archive':self.archive}
|
|
|
|
|
self.lfolders = [ folder['label'] for folder in logs]
|
|
|
|
|
for item in logs :
|
|
|
|
|
|
|
|
|
|
if self.can_clean(item) :
|
|
|
|
|
self.archive(item)
|
|
|
|
|
#self.clean(item)
|
|
|
|
|