Cleans up old hunt data from aff4.
509784
def CleanAff4Hunts(self):
    """"""

    hunts_ttl = config.CONFIG["DataRetention.hunts_ttl"]
    if not hunts_ttl:
      self.Log("TTL not set - nothing to do...")
      return

    exception_label = config.CONFIG["DataRetention.hunts_ttl_exception_label"]

    hunts_root = aff4.FACTORY.Open("aff4:/hunts", token=self.token)
    hunts_urns = list(hunts_root.ListChildren())

    deadline = rdfvalue.RDFDatetime.Now() - hunts_ttl

    hunts_deleted = 0

    hunts = aff4.FACTORY.MultiOpen(
        hunts_urns, aff4_type=implementation.GRRHunt, token=self.token)
    for hunt in hunts:
      if exception_label in hunt.GetLabelsNames():
        continue

      runner = hunt.GetRunner()
      if runner.context.create_time + runner.context.duration < deadline:
        aff4.FACTORY.Delete(hunt.urn, token=self.token)
        hunts_deleted += 1
        self.HeartBeat()
    self.Log("Deleted %d hunts." % hunts_deleted)
1350362
def clean(self):
        """"""
        doc = self._resource
        result = {k: v for k, v in doc.iteritems() if k not in
                  self.internal_fields}

        if '_id' in doc and 'id' not in result:
            result['id'] = doc['_id']

        return result
122719
def cleanup(self):
        """"""
        for item in self.server_map:
            self.member_del(item, reconfig=False)
        self.server_map.clear()
51113
def purge_old(self):
        '''
        
        '''
        if self.keep_max is not None:
            keys = self.redis_conn.keys(self.get_key() + ':*')
            keys.sort(reverse=True)
            while len(keys) > self.keep_max:
                key = keys.pop()
                self.redis_conn.delete(key)
1034962
def clear_data(self):
        '''
         '''
        if self.forest.verbose > 1:
            print('clearing up stuff')
        self.S = None
        self.Uy = None
        self.U = None
60158
def clearData(self):
        """"""
        self._counts = np.zeros_like(self._bins)
        self.histo.setOpts(height=self._counts)
964553
def sweep(self):
        '''
        
        '''
        if self.max_age < time.time() - self.timestamp:
            self.clear()
            self.timestamp = time.time()
        else:
            paterns = list(self.cache.values())
            paterns.sort()
            for idx in range(self.clear_size):
                del self.cache[paterns[idx][2]]
276937
def maybe_clean(self):
        """"""

        now = time.time()
        if self.next_cleaning <= now:
            keys_to_delete = []
            for (k, v) in self.data.iteritems():
                if v.expiration <= now:
                    keys_to_delete.append(k)
            for k in keys_to_delete:
                del self.data[k]
            now = time.time()
            self.next_cleaning = now + self.cleaning_interval
378495
def wipe_results(self):
        
        # Clean results table
        self.db.purge_table('results')

        # Get rid of contents of data dir
        map(shutil.rmtree, glob.glob(os.path.join(self.get_data_dir(), '*.*')))
241058
private function CleanUp() {

		// remove possible empty keys
		$AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
		foreach ($AVpossibleEmptyKeys as $dummy => $key) {
			if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
				unset($this->info['audio'][$key]);
			}
			if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
				unset($this->info['video'][$key]);
			}
		}

		// remove empty root keys
		if (!empty($this->info)) {
			foreach ($this->info as $key => $value) {
				if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
					unset($this->info[$key]);
				}
			}
		}

		// remove meaningless entries from unknown-format files
		if (empty($this->info['fileformat'])) {
			if (isset($this->info['avdataoffset'])) {
				unset($this->info['avdataoffset']);
			}
			if (isset($this->info['avdataend'])) {
				unset($this->info['avdataend']);
			}
		}

		// remove possible duplicated identical entries
		if (!empty($this->info['error'])) {
			$this->info['error'] = array_values(array_unique($this->info['error']));
		}
		if (!empty($this->info['warning'])) {
			$this->info['warning'] = array_values(array_unique($this->info['warning']));
		}

		// remove "global variable" type keys
		unset($this->info['php_memory_limit']);

		return true;
	}
1219791
def cleanup(self):
        

        all([delete_file_or_tree(f) for f in self.to_delete])
        self.to_delete = []
638209
public void cleanup() {
		long currentTime = System.currentTimeMillis();

		// remove entries which have exceeded their time to live
		cachedExecutionGraphs.values().removeIf(
			(ExecutionGraphEntry entry) -> currentTime >= entry.getTTL());
	}
584724
private void cleanup() {

        m_folder1Exclusive = null;
        m_folder2Exclusive = null;
        m_foldersSibling = null;
        m_foldersEqualnames = null;
        m_foldersDifferenttypes = null;
    }
697109
def _cleanup(self):
        '''
        
        '''
        if (hasattr(self, 'config')
           and self.config.get('support_archive')
           and os.path.exists(self.config['support_archive'])):
            self.out.warning('Terminated earlier, cleaning up')
            try:
                os.unlink(self.config['support_archive'])
            except Exception as err:
                log.debug(err)
                self.out.error('{} while cleaning up.'.format(err))
1123763
def clean_old_jobs():
    '''
    
    '''
    for returner_ in __opts__[CONFIG_KEY]:
        fstr = '{0}.clean_old_jobs'.format(returner_)
        if fstr in _mminion().returners:
            _mminion().returners[fstr]()
1035756
def cleanup_log_files(outputfile):
    """"""
    d = os.path.dirname(os.path.abspath(outputfile))
    logfiles = [f for f in os.listdir(d) if f.endswith('ogg.log')]
    for f in logfiles:
        os.remove(f)
695610
def clean():
    ''''''

    basedir = dirname(__file__)

    print(cyan('delete temp files and dirs for packaging'))
    local(flo(
        'rm -rf  '
        '{basedir}/.eggs/  '
        '{basedir}/fabsetup.egg-info/  '
        '{basedir}/dist  '
        '{basedir}/README  '
        '{basedir}/build/  '
    ))

    print(cyan('\ndelete temp files and dirs for editing'))
    local(flo(
        'rm -rf  '
        '{basedir}/.cache  '
        '{basedir}/.ropeproject  '
    ))

    print(cyan('\ndelete bytecode compiled versions of the python src'))
    # cf. http://stackoverflow.com/a/30659970
    local(flo('find  {basedir}/fabsetup  '
              'fabfile*  ') +
          '\( -name \*pyc -o -name \*.pyo -o -name __pycache__ '
          '-o -name \*.so -o -name \*.o -o -name \*.c \) '
          '-prune '
          '-exec rm -rf {} + || true')