

@flow.StateHandler()
def Start(self):
    tmp_ttl = config_lib.CONFIG['DataRetention.tmp_ttl']
    if (not tmp_ttl):
        self.Log('TTL not set - nothing to do...')
        return
    exception_label = config_lib.CONFIG['DataRetention.tmp_ttl_exception_label']
    tmp_root = aff4.FACTORY.Open('aff4:/tmp', mode='r', token=self.token)
    tmp_urns = list(tmp_root.ListChildren())
    deadline = (rdfvalue.RDFDatetime().Now() - tmp_ttl)
    for tmp_group in utils.Grouper(tmp_urns, 10000):
        expired_tmp_urns = []
        for tmp_obj in aff4.FACTORY.MultiOpen(tmp_group, mode='r', token=self.token):
            if (exception_label in tmp_obj.GetLabelsNames()):
                continue
            if (tmp_obj.Get(tmp_obj.Schema.LAST) < deadline):
                expired_tmp_urns.append(tmp_obj.urn)
        aff4.FACTORY.MultiDelete(expired_tmp_urns, token=self.token)
        self.HeartBeat()

dataset/ETHPy150Open google/grr/grr/lib/flows/cron/data_retention.py CleanTemp.Start/original