How to use the pykern.pkio.unchecked_remove function in pykern

To help you get started, we’ve selected a few pykern examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github radiasoft / sirepo / sirepo / template / flash.py View on Github external
def remove_last_frame(run_dir):
    files = _h5_file_list(run_dir)
    if len(files) > 0:
        pkio.unchecked_remove(files[-1])
github radiasoft / sirepo / sirepo / template / warppba.py View on Github external
def remove_last_frame(run_dir):
    files = _h5_file_list(run_dir)
    if len(files) > 0:
        pkio.unchecked_remove(files[-1])
github radiasoft / sirepo / sirepo / job_driver_backends / docker_process.py View on Github external
async def start_report_job(run_dir, cmd):
    run_log_path = run_dir.join(template_common.RUN_LOG)
    quoted_cmd = ' '.join(shlex.quote(c) for c in cmd)
    quoted_outpath = shlex.quote(str(run_log_path))
    quoted_bash_cmd = f'{quoted_cmd} >{quoted_outpath} 2>&1'

    # Use a separate working dir, to make sure that the server isn't accessing
    # the working dir manually
    working_dir = run_dir + '-working-dir'
    pkio.unchecked_remove(working_dir)
    assert not working_dir.exists()
    shutil.copytree(str(run_dir), str(working_dir))

    container = await _make_container(run_dir, working_dir, quoted_bash_cmd, 'report')

    return _DockerReportJob(container, {'working_dir': str(working_dir)})
github radiasoft / sirepo / sirepo / pkcli / job_agent.py View on Github external
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.run_dir = pkio.py_path(self.msg.runDir)
        self._is_compute = self.msg.jobCmd == 'compute'
        if self._is_compute:
            pkio.unchecked_remove(self.run_dir)
            pkio.mkdir_parent(self.run_dir)
        self._in_file = self._create_in_file()
        self._process = _Process(self)
        self._terminating = False
        self._start_time = int(time.time())
        self.jid = self.msg.computeJid
github radiasoft / sirepo / sirepo / pkcli / synergia.py View on Github external
if run_with_mpi:
                mpi.run_script(pkio.read_text(template_common.PARAMETERS_PYTHON_FILE))
            else:
                #TODO(pjm): MPI doesn't work with rsbeams distributions yet
                exec(pkio.read_text(template_common.PARAMETERS_PYTHON_FILE), locals(), locals())
    except Exception as e:
        res = {
            'error': str(e),
        }
    if run_with_mpi and 'error' in res:
        text = pkio.read_text('mpi_run.out')
        m = re.search(r'^Traceback .*?^\w*Error: (.*?)\n\n', text, re.MULTILINE|re.DOTALL)
        if m:
            res['error'] = m.group(1)
            # remove output file - write_result() will not overwrite an existing error output
            pkio.unchecked_remove(simulation_db.json_filename(template_common.OUTPUT_BASE_NAME))
    simulation_db.write_result(res)
github radiasoft / sirepo / sirepo / job_supervisor.py View on Github external
def destroy(self):
        if 'timer' in self:
            tornado.ioloop.IOLoop.current().remove_timeout(self.timer)
        if '_lib_dir_symlink' in self:
            pykern.pkio.unchecked_remove(self._lib_dir_symlink)
        self.driver.destroy_op(self)
github radiasoft / sirepo / sirepo / simulation_db.py View on Github external
Args:
        req_or_data (dict): may be simulation data or a request
        remove_dir (bool): remove the directory [False]

    Returns:
        py.path: directory to run
    """
    import sirepo.sim_data
    t = req_or_data.simulationType
    s = sirepo.sim_data.get_class(t)
    d = simulation_dir(
        t,
        s.parse_sid(req_or_data),
    ).join(s.compute_model(req_or_data))
    if remove_dir:
        pkio.unchecked_remove(d)
    return d
github radiasoft / sirepo / sirepo / template / rs4pi.py View on Github external
def _move_import_file(data):
    sim = data['models']['simulation']
    path = sim[_TMP_INPUT_FILE_FIELD]
    del sim[_TMP_INPUT_FILE_FIELD]
    if os.path.exists(path):
        zip_path = _sim_file(sim['simulationId'], _ZIP_FILE_NAME)
        os.rename(path, zip_path)
        tmp_dir = _sim_file(sim['simulationId'], _TMP_ZIP_DIR)
        zipfile.ZipFile(zip_path).extractall(tmp_dir)
        _summarize_dicom_files(data, tmp_dir)
        pkio.unchecked_remove(tmp_dir)
        simulation_db.save_simulation_json(data)