This decorator removes the temp file from disk. This is the case where
    you want to analyze from a payload.
977314
def clean(func):
    
    def wrapper(*args, **kwargs):
        # tuple: output command, path given from command line,
        # path of templ file when you give the payload
        out, given_path, path = func(*args, **kwargs)

        try:
            if not given_path:
                os.remove(path)
        except OSError:
            pass

        return out

    return wrapper
394104
def cleanup(self):
        """"""
        t = time.time()
        for noncefile in glob(self.path + '/*.nonce'):
            if os.path.getmtime(noncefile) + self.expiration > t:
                os.unlink(noncefile)
35534
def _delete_temp_logs(self, family_name: str):
        """"""
        for temp_log in self.store.analyses(family=family_name, temp=True):
            log.debug(f"delete temporary log: {temp_log.id} - {temp_log.status}")
            temp_log.delete()
718458
def clean(self):
        
        clean_files = ['blotImage','crmaskImage','finalMask',
                        'staticMask','singleDrizMask','outSky',
                        'outSContext','outSWeight','outSingle',
                        'outMedian','dqmask','tmpmask',
                        'skyMatchMask']

        log.info('Removing intermediate files for %s' % self._filename)
        # We need to remove the combined products first; namely, median image
        util.removeFileSafely(self.outputNames['outMedian'])
        # Now remove chip-specific intermediate files, if any were created.
        for chip in self.returnAllChips(extname='SCI'):
            for fname in clean_files:
                if fname in chip.outputNames:
                    util.removeFileSafely(chip.outputNames[fname])
1036227
def __deserialize_file(self, response):
        
        fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
        os.close(fd)
        os.remove(path)

        content_disposition = response.getheader("Content-Disposition")
        if content_disposition:
            filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?',
                                 content_disposition).group(1)
            path = os.path.join(os.path.dirname(path), filename)

        with open(path, "wb") as f:
            f.write(response.data)

        return path
275182
def copy_to_temp(object):
    
    temp_file = NamedTemporaryFile(delete=False)
    _copy_and_close(object, temp_file)
    return temp_file.name
243669
def clean(deltox=False):
    '''
    '''

    basedir = dirname(__file__)

    print(cyan('delete temp files and dirs for packaging'))
    local(flo(
        'rm -rf  '
        '{basedir}/.eggs/  '
        '{basedir}/utlz.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}/utlz  {basedir}/tests  ') +
          '\( -name \*pyc -o -name \*.pyo -o -name __pycache__ '
          '-o -name \*.so -o -name \*.o -o -name \*.c \) '
          '-prune '
          '-exec rm -rf {} +')

    if deltox:
        print(cyan('\ndelete tox virual environments'))
        local(flo('cd {basedir}  &&  rm -rf .tox/'))
897301
def untar(fname, verbose=True):
    
    if fname.lower().endswith(".tar.gz"):
        dirpath = os.path.join(BIGDATA_PATH, os.path.basename(fname)[:-7])
        if os.path.isdir(dirpath):
            return dirpath
        with tarfile.open(fname) as tf:
            members = tf.getmembers()
            for member in tqdm(members, total=len(members)):
                tf.extract(member, path=BIGDATA_PATH)
        dirpath = os.path.join(BIGDATA_PATH, members[0].name)
        if os.path.isdir(dirpath):
            return dirpath
    else:
        logger.warning("Not a tar.gz file: {}".format(fname))
880307
def close(self):
        
        if self.file:
            self.file.close()
            self.file = None

        # If temp_file is a folder, we do not remove it because we may
        # still need it after the unpickler is disposed
        if self.tmp_file and _os.path.isfile(self.tmp_file):
            _os.remove(self.tmp_file)
            self.tmp_file = None
1301004
def delete_image_tar(file_obj, tar):
    ''''''
    try:
        file_obj.close()
    except:
        tar.close()
    if os.path.exists(file_obj):
        os.remove(file_obj)
        deleted = True
        bot.debug('Deleted temporary tar.')   
    return deleted
688692
def tempfile(self):
        ""
        tf = tempfile.NamedTemporaryFile()
        tfn = tf.name
        tf.close()
        os.remove(tf.name)
        shutil.copy(self.fn, tfn)
        return tfn
104573
def CleanUp(self, path):
    """"""
    try:
      if os.path.exists(path):
        os.remove(path)
    except (OSError, IOError) as e:
      logging.info("Failed to remove temporary file %s. Err: %s", path, e)
1237819
def _cleanup_tempdir(tempdir):
    """"""
    try:
        shutil.rmtree(tempdir)
    except OSError as err:
        if err.errno != errno.ENOENT:
            raise
850031
def destroyTempFile(self, tempFile):
        
        #Do basic assertions for goodness of the function
        assert os.path.isfile(tempFile)
        assert os.path.commonprefix((self.rootDir, tempFile)) == self.rootDir #Checks file is part of tree
        #Update stats.
        self.tempFilesDestroyed += 1
        #Do the actual removal
        os.remove(tempFile)
        self.__destroyFile(tempFile)
1321492
def temp_file(self):
        
        with tempfile.NamedTemporaryFile(suffix='.bat', delete=False) as fp:
            try:
                logger.debug("Saving code to %r", fp.name)
                fp.write(self.code.encode('utf-8'))
                fp.close()
                yield fp.name
            finally:
                os.remove(fp.name)
529924
def tmpfile(*args, **kwargs):
    
    (fd, fname) = tempfile.mkstemp(*args, **kwargs)
    try:
        yield fname
    finally:
        os.close(fd)
        if os.path.exists(fname):
            os.remove(fname)
695236
def clear_break(
            self, filename, lineno=None, temporary=False, cond=None,
            funcname=None
    ):
        """"""
        log.info(
            'Removing break fn:%s lno:%s tmp:%s cond:%s fun:%s' %
            (filename, lineno, temporary, cond, funcname)
        )

        breakpoint = self.get_break(
            filename, lineno, temporary or False, cond, funcname
        )
        if temporary is None and breakpoint not in self.breakpoints:
            breakpoint = self.get_break(filename, lineno, True, cond, funcname)

        try:
            self.breakpoints.remove(breakpoint)
            log.info('Breakpoint %r removed' % breakpoint)
        except Exception:
            log.info('Breakpoint %r not removed: not found' % breakpoint)