Clean the disk before flushing the new image.

        See: https://bugs.launchpad.net/ironic-lib/+bug/1550604
320540
def patch_ironic_ramdisk(self):
        
        tmpdir = self.run('mktemp -d')[0].rstrip('\n')
        self.run('cd {tmpdir}; zcat /home/stack/ironic-python-agent.initramfs| cpio -id'.format(tmpdir=tmpdir))
        self.send_file(pkg_data_filename('static', 'ironic-wipefs.patch'), '/tmp/ironic-wipefs.patch')
        self.run('cd {tmpdir}; patch -p0 < /tmp/ironic-wipefs.patch'.format(tmpdir=tmpdir))
        self.run('cd {tmpdir}; find . | cpio --create --format=newc > /home/stack/ironic-python-agent.initramfs'.format(tmpdir=tmpdir))
682023
def flush(self, save_index=False, save_model=False, clear_buffer=False):
        """"""
        if save_index:
            if self.fresh_index is not None:
                self.fresh_index.save(self.location('index_fresh'))
            if self.opt_index is not None:
                self.opt_index.save(self.location('index_opt'))
        if save_model:
            if self.model is not None:
                self.model.save(self.location('model'))
        self.payload.commit()
        if clear_buffer:
            if hasattr(self, 'fresh_docs'):
                try:
                    self.fresh_docs.terminate() # erase all buffered documents + file on disk
                except:
                    pass
            self.fresh_docs = SqliteDict(journal_mode=JOURNAL_MODE) # buffer defaults to a random location in temp
        self.fresh_docs.sync()
65610
def cleanup(self):
        
        if self.sock is not None:
            self.sock.close()
        if self.outfile is not None:
            self.outfile.close()
        if self.bar is not None:
            self.update_progress(complete=True)
309025
def cleanup_images(self, remove_old=False, keep_tags=None, **kwargs):
        
        self.push_log("Checking images for dependent images and containers.")
        set_raise_on_error(kwargs, False)
        return super(DockerFabricClient, self).cleanup_images(remove_old=remove_old, keep_tags=keep_tags, **kwargs)
179029
def _cleanup():
    '''
    
    '''
    for inst in _ACTIVE[:]:
        res = inst.isalive()
        if res is not True:
            try:
                _ACTIVE.remove(inst)
            except ValueError:
                # This can happen if two threads create a new Terminal instance
                # It's harmless that it was already removed, so ignore.
                pass
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])
92831
def _flush(self):
        
        t1, t2 = str(time.time()).split(".")
        state_path = os.path.join(self.ep_directory, "state_{}_{}.npz".format(t1, t2))
        if hasattr(self.env, "unwrapped"):
            env_name = self.env.unwrapped.__class__.__name__
        else:
            env_name = self.env.__class__.__name__
        np.savez(
            state_path,
            states=np.array(self.states),
            action_infos=self.action_infos,
            env=env_name,
        )
        self.states = []
        self.action_infos = []
609297
def clean(self):
        
        if not util.is_blank(self.catalog.catname) and os.path.exists(self.catalog.catname):
            os.remove(self.catalog.catname)
1090803
def cleanup(self):
        """"""
        shutil.rmtree(self.name, onerror=lambda *a: os.chmod(a[1], __import__('stat').S_IWRITE) or os.unlink(a[1]))
        if os.path.exists(self.name):
            raise IOError(17, "File exists: '{}'".format(self.name))
1287636
def flush(self, key=None):
        

        if not key is None:
            if key in self.data:
                del self.data[key]
        else:
            self.data = {}
            self.next_cleaning = time.time() + self.cleaning_interval
1236743
def _cleanup(self):
        """"""
        for filename in os.listdir(self._storage_dir):
            file_path = path.join(self._storage_dir, filename)
            file_stat = os.stat(file_path)
            evaluate = max(file_stat.st_ctime, file_stat.st_mtime)
            if evaluate + self._duration < time.time():
                LOGGER.debug('Removing stale file: %s', file_path)
                os.unlink(file_path)
294980
function clean() {
    swig.log.info('', 'Cleaning the /public directory...');

    let paths = [
      './public/**/{target}/**/*',
      '!./public/**/{target}/**/config',
      '!./public/**/{target}/**/config/**/*',
      '!./public/**/{target}/**/src',
      '!./public/**/{target}/**/src/**/*',
      '!./public/css/{target}/main.less',
      '!./public/spec/{target}/**/*'
    ];

    paths = _.map(paths, p => p.replace('{target}', swig.pkg.name));
    const files = glob.sync(paths);

    swig.log.verbose(`[clean] ${files.length} files found at: `);
    swig.log.verbose(paths);

    _.each(files, (file) => {
      swig.log.verbose(`[clean] removing: ${file}`);
      rimraf.sync(path.normalize(file));
    });
  }
843968
def clean(verbose=False):
    
    def rm(name):
        if os.path.isfile(name):
            os.remove(name)
            if verbose:
                printer.info('Removed file:', name)
        else:
            if verbose:
                printer.info('File not present:', name)

    def rmdir(name):
        if os.path.isdir(name):
            shutil.rmtree(name)
            if verbose:
                printer.info('Removed directory:', name)
        else:
            if verbose:
                printer.info('Directory not present:', name)

    root = os.getcwd()

    rmdir('build')
    rmdir('dist')

    for path, dirs, files in os.walk(root):
        rel_path = os.path.relpath(path, root)

        if rel_path == '.':
            rel_path = ''

        if rel_path.startswith('.'):
            continue

        for d in dirs:
            if d == '__pycache__':
                rmdir(os.path.join(rel_path, d))

        for f in files:
            if f.endswith('.pyc') or f.endswith('.pyo'):
                rm(os.path.join(rel_path, f))
474252
def _replace_old_image(self):
        ''' 
        '''
        try:
            old_obj = self.__class__.objects.get(pk=self.pk)
            if old_obj.image.path != self.image.path:
                path = old_obj.image.path
                default_storage.delete(path)
        except self.__class__.DoesNotExist:
            pass
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)
936617
def flush(self):
        

        self.clear()
        self.delete(self.session_key)
        self.create()
218883
def clean(self, config=True, catalog=False, check=False):
        

        try:
            if (config):
                os.unlink(self.config['FILTER_NAME'])
                os.unlink(self.config['PARAMETERS_NAME'])
                os.unlink(self.config['STARNNW_NAME'])
                os.unlink(self.config['CONFIG_FILE'])
            if (catalog):
                os.unlink(self.config['CATALOG_NAME'])
            if (check):
                os.unlink(self.config['CHECKIMAGE_NAME'])

        except OSError:
            pass