Remove stale refs so that they are no longer seen as fileserver envs
162788
def clean_stale_refs(self):
        '''
        
        '''
        cleaned = []
        cmd_str = 'git remote prune origin'

        # Attempt to force all output to plain ascii english, which is what some parsing code
        # may expect.
        # According to stackoverflow (http://goo.gl/l74GC8), we are setting LANGUAGE as well
        # just to be sure.
        env = os.environ.copy()
        env[b"LANGUAGE"] = b"C"
        env[b"LC_ALL"] = b"C"

        cmd = subprocess.Popen(
            shlex.split(cmd_str),
            close_fds=not salt.utils.platform.is_windows(),
            cwd=os.path.dirname(self.gitdir),
            env=env,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT)
        output = cmd.communicate()[0]
        if six.PY3:
            output = output.decode(__salt_system_encoding__)
        if cmd.returncode != 0:
            log.warning(
                'Failed to prune stale branches for %s remote \'%s\'. '
                'Output from \'%s\' follows:\n%s',
                self.role, self.id, cmd_str, output
            )
        else:
            marker = ' * [pruned] '
            for line in salt.utils.itertools.split(output, '\n'):
                if line.startswith(marker):
                    cleaned.append(line[len(marker):].strip())
            if cleaned:
                log.debug(
                    '%s pruned the following stale refs: %s',
                    self.role, ', '.join(cleaned)
                )
        return cleaned
350338
def __remove_obsolete_metadata(self):
        
        clean = {}
        for key, _ in self._source_file_names.items():
            if key in self._pystratum_metadata:
                clean[key] = self._pystratum_metadata[key]

        self._pystratum_metadata = clean
896980
public void cleanReferenceCache() {
        final long now = currentDateSupplier.get().getTime();
        final Iterator<HardReference> it = hardReferences.iterator();
        while (it.hasNext()) {
            if (it.next().keeptSince.getTime() + REFERENCE_KEEPING_TIME <= now) {
                it.remove();
            }
        }
    }
803153
def delete(self, refobj):
        
        refobjinter = self.get_refobjinter()
        reference = refobjinter.get_reference(refobj)
        if reference:
            fullns = cmds.referenceQuery(reference, namespace=True)
            cmds.file(removeReference=True, referenceNode=reference)
        else:
            parentns = common.get_namespace(refobj)
            ns = cmds.getAttr("%s.namespace" % refobj)
            fullns = ":".join((parentns.rstrip(":"), ns.lstrip(":")))
        cmds.namespace(removeNamespace=fullns, deleteNamespaceContent=True)
991592
def cleanup(output_root):
    """"""
    if os.path.exists(output_root):
        if os.path.isdir(output_root):
            rmtree(output_root)
        else:
            os.remove(output_root)
1269129
def cleanup_files_on_ev3():
    """"""

    list = get_base_ev3dev_cmd() + ['cleanup']

    env = os.environ.copy()
    env["PYTHONUSERBASE"] = THONNY_USER_BASE
    proc = subprocess.Popen(list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                            universal_newlines=True, env=env)
    dlg = MySubprocessDialog(get_workbench(), proc, "Delete files in homedir on EV3", autoclose=False)
    dlg.wait_window()
1083626
def remove_stale_symlinks(path)
      Dir.glob("#{path}/*").each { |f| File.unlink(f) if not File.exist?(f) }
    end
157005
private void clean(ArtifactoryCollector collector, List<ArtifactoryRepo> existingRepos) {
        // find the server url's to collect from
        Set<String> serversToBeCollected = new HashSet<>();
        serversToBeCollected.addAll(collector.getArtifactoryServers());

        // find the repos to collect from each server url above
        List<Set<String>> repoNamesToBeCollected = new ArrayList<Set<String>>();
        List<String[]> allRepos = new ArrayList<>();
        artifactorySettings.getServers().forEach(serverSetting -> {
            allRepos.add((String[]) getRepoAndPatternsForServ(serverSetting.getRepoAndPatterns()).keySet().toArray());
        });
        for (int i = 0; i < allRepos.size(); i++) {
            Set<String> reposSet = new HashSet<>();
            if (allRepos.get(i) != null) {
                reposSet.addAll(Arrays.asList(allRepos.get(i)));
            }
            repoNamesToBeCollected.add(reposSet);
        }

        assert (serversToBeCollected.size() == repoNamesToBeCollected.size());

        List<ArtifactoryRepo> stateChangeRepoList = new ArrayList<>();
        for (ArtifactoryRepo repo : existingRepos) {
            if (isRepoEnabledAndNotCollected(collector, serversToBeCollected, repoNamesToBeCollected, repo) ||  // if it was enabled but not to be collected
                    isRepoDisabledAndToBeCollected(collector, serversToBeCollected, repoNamesToBeCollected, repo)) { // OR it was disabled and now is to be collected
                repo.setEnabled(isRepoCollected(collector, serversToBeCollected, repoNamesToBeCollected, repo));
                stateChangeRepoList.add(repo);
            }
        }
        if (!CollectionUtils.isEmpty(stateChangeRepoList)) {
            artifactoryRepoRepository.save(stateChangeRepoList);
        }
    }
804961
def clean!
      files_to_keep = cache.keys.concat(cache.values)

      if (sprockets_manifest = Dir.entries("#{base_dir}").detect { |entry| entry =~ SPROCKETS_MANIFEST_REGEX })
        files_to_keep.concat(JSON.parse(File.read("#{base_dir}/#{sprockets_manifest}")).fetch("files", {}).keys)
      end

      Dir["#{base_dir}/**/*"].each do |path|
        next if File.directory?(path) || files_to_keep.include?(Pathname(path).relative_path_from(base_dir).to_s)

        FileUtils.rm(path)
      end
    end
1133508
function cleanupUpdates() {
        Object.keys(_idsToUpdate).forEach(function (id) {
            var installResult = _idsToUpdate[id],
                keepFile = installResult.keepFile,
                filename = installResult.localPath;

            if (filename && !keepFile) {
                FileSystem.getFileForPath(filename).unlink();
            }
        });
        _idsToUpdate = {};
    }
169642
def cleanup(bucket, prefix, versions)
      objects = @con.get_bucket(bucket, :prefix => prefix).body['Contents']

      return if objects.size <= versions

      objects[0...(objects.size - versions)].each do |o|
       Mongolicious.logger.info("Removing outdated version #{o['Key']}")
       @con.delete_object(bucket, o['Key'])
      end
    end
148498
void cleanUpStaleEntries() {
        for (KeyedRef<K, V> ref = q.poll(); ref != null; ref = q.poll()) {
            map.remove(ref.getKey(), ref); // CONCURRENT remove() operation
        }
    }
314068
def clean_old_jobs():
    '''
    
    '''
    if __opts__.get('keep_jobs', False) and int(__opts__.get('keep_jobs', 0)) > 0:
        try:
            with _get_serv() as cur:
                sql = 'select date_sub(now(), interval {0} hour) as stamp;'.format(__opts__['keep_jobs'])
                cur.execute(sql)
                rows = cur.fetchall()
                stamp = rows[0][0]

            if __opts__.get('archive_jobs', False):
                _archive_jobs(stamp)
            else:
                _purge_jobs(stamp)
        except MySQLdb.Error as e:
            log.error('Mysql returner was unable to get timestamp for purge/archive of jobs')
            log.error(six.text_type(e))
            raise salt.exceptions.SaltRunnerError(six.text_type(e))
1227059
def cleanup():
    
    script_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(os.readlink(__file__))
    script_dir = os.path.realpath(os.path.join(script_dir, ".."))
    shutil.rmtree(os.path.join(script_dir, "dist"), ignore_errors=True)
    shutil.rmtree(os.path.join(script_dir, "tmp"), ignore_errors=True)
    shutil.rmtree(os.path.join(script_dir, "urh.egg-info"), ignore_errors=True)
    shutil.rmtree(os.path.join(script_dir, "src", "urh.egg-info"), ignore_errors=True)
    shutil.rmtree(os.path.join(script_dir, "src", "urh", "tmp"), ignore_errors=True)
273402
def cleanup_temporary_directories(self):
        """"""
        while self.build_directories:
            shutil.rmtree(self.build_directories.pop())
        for requirement in self.reported_requirements:
            requirement.remove_temporary_source()
        while self.eggs_links:
            symbolic_link = self.eggs_links.pop()
            if os.path.islink(symbolic_link):
                os.unlink(symbolic_link)
753526
def cleanup(self):
        '''
        
        '''
        log.debug('ConCache cleaning up')
        if os.path.exists(self.cache_sock):
            os.remove(self.cache_sock)
        if os.path.exists(self.update_sock):
            os.remove(self.update_sock)
        if os.path.exists(self.upd_t_sock):
            os.remove(self.upd_t_sock)
1698
def cleanup(self):
        

        while self.inactive_timeout > 0:
            self.time = time.time()

            keys = []

            for key, client in self.clients.items.items():
                t = getattr(client, "active_at", 0)
                if t > 0 and self.time - t > self.inactive_timeout:
                    client.kwargs["link"].disconnect()
                    keys.append(key)

            for key in keys:
                self.log_debug("Removing client (inactive): %s" % key)
                del self.clients[key]

            time.sleep(1)