def recursive_clean(self, directory, age, recurse):
        """recusively clean a directory

           @param directory: (string)
           @param age: (float)
           @param recurse: (bool)

           return bool
        """
        try: data = map(lambda n: os.path.join(directory,n), os.listdir(directory))
        except:
            log('could not find directory %s' % directory)
            return

        for node in data:
            if os.path.isdir(node) and recurse:
                #blocking method in a thread
                empty = self.recursive_clean(node,age,recurse)
                if empty:
                    try: os.rmdir(node)
                    except: log('could not remove directory: %s' % node)
                continue
            if os.path.isdir(node): continue #in case recurse is False
            if (time.time() - os.stat(node).st_mtime) > age:             
                try: os.remove(node)
                except: log('could not remove file: %s' % node)
        return bool(os.listdir(directory))
dataset/ETHPy150Open OrbitzWorldwide/droned/droned/services/janitizer.py/Janitizer.recursive_clean/original