|
|
@ -129,10 +129,12 @@ class Apps(Actor) :
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
class Mailer (Actor):
|
|
|
|
class Mailer (Actor):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
Actor.__init__(self)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
conf = {uid:<account>,host:<host>,port:<port>,password:<password>}
|
|
|
|
conf = {uid:<account>,host:<host>,port:<port>,password:<password>}
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
def __init__(self,conf) :
|
|
|
|
def init(self,conf) :
|
|
|
|
self.uid = conf['uid']
|
|
|
|
self.uid = conf['uid']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -170,12 +172,14 @@ class Folders(Actor):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This is designed to handle folders i.e cleaning/archiving the folders
|
|
|
|
This is designed to handle folders i.e cleaning/archiving the folders
|
|
|
|
if the user does NOT have any keys to cloud-view than she will not be able to archive
|
|
|
|
if the user does NOT have any keys to cloud-view than she will not be able to archive
|
|
|
|
|
|
|
|
{threshold:value}
|
|
|
|
|
|
|
|
@params threshold in terms of size, or age. It will be applied to all folders
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def init(self,**args):
|
|
|
|
def init(self,**args):
|
|
|
|
Actor.init(self,config,item)
|
|
|
|
Actor.init(self,config,item)
|
|
|
|
self.lfolders = args['folders'] #config['folders']
|
|
|
|
#self.lfolders = args['folders'] #config['folders']
|
|
|
|
self.action = args['action'] #{clear,archive} config['actions']['folders']
|
|
|
|
#self.action = args['action'] #{clear,archive} config['actions']['folders']
|
|
|
|
self.threshold = self.get_size( args['threshold']) #self.config['threshold'])
|
|
|
|
self.threshold = self.get_size( args['threshold']) #self.config['threshold'])
|
|
|
|
self.item = item
|
|
|
|
self.item = item
|
|
|
|
|
|
|
|
|
|
|
@ -191,7 +195,8 @@ class Folders(Actor):
|
|
|
|
self.clean(item)
|
|
|
|
self.clean(item)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# @TODO: The archive can be uploaded to the cloud or else where
|
|
|
|
# @TODO: The archive can be uploaded to the cloud or else where
|
|
|
|
# - This allows the submission of data to a processing engine if there ever were one
|
|
|
|
# @param id cloud service idenfier {dropbox,box,google-drive,one-drive}
|
|
|
|
|
|
|
|
# @param key authorization key for the given service
|
|
|
|
#
|
|
|
|
#
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
@ -211,6 +216,9 @@ class Folders(Actor):
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
def get_size(self,value):
|
|
|
|
def get_size(self,value):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
converts size values into MB and returns the value without units
|
|
|
|
|
|
|
|
"""
|
|
|
|
units = {'MB':1000,'GB':1000000,'TB':1000000000} # converting to kb
|
|
|
|
units = {'MB':1000,'GB':1000000,'TB':1000000000} # converting to kb
|
|
|
|
key = set(unites) & set(re.split('(\d+)',value.upper()))
|
|
|
|
key = set(unites) & set(re.split('(\d+)',value.upper()))
|
|
|
|
if len(key) == 0:
|
|
|
|
if len(key) == 0:
|
|
|
@ -218,7 +226,7 @@ class Folders(Actor):
|
|
|
|
key = key.pop()
|
|
|
|
key = key.pop()
|
|
|
|
return float(value.upper().replace('MB','').strip()) * units[key]
|
|
|
|
return float(value.upper().replace('MB','').strip()) * units[key]
|
|
|
|
|
|
|
|
|
|
|
|
def isvalid(self,item):
|
|
|
|
def can_clean(self,item):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This function returns whether the following :
|
|
|
|
This function returns whether the following :
|
|
|
|
p : folder exists
|
|
|
|
p : folder exists
|
|
|
@ -233,7 +241,7 @@ class Folders(Actor):
|
|
|
|
def analyze(self,logs):
|
|
|
|
def analyze(self,logs):
|
|
|
|
r = {'clean':self.clean,'archive':self.archive}
|
|
|
|
r = {'clean':self.clean,'archive':self.archive}
|
|
|
|
for item in logs :
|
|
|
|
for item in logs :
|
|
|
|
if self.isValid(item) :
|
|
|
|
if self.can_clean(item) :
|
|
|
|
|
|
|
|
|
|
|
|
id = self.config['action'].strip()
|
|
|
|
id = self.config['action'].strip()
|
|
|
|
pointer = r[id]
|
|
|
|
pointer = r[id]
|
|
|
|