コード例 #1
0
ファイル: zgoubi.py プロジェクト: mkeilman/sirepo
def _parse_zgoubi_log(run_dir):
    path = run_dir.join(_ZGOUBI_LOG_FILE)
    if not path.exists():
        return ''
    res = ''
    element_by_num = PKDict()
    text = pkio.read_text(str(path))

    for line in text.split("\n"):
        match = re.search(r'^ (\'\w+\'.*?)\s+(\d+)$', line)
        if match:
            element_by_num[match.group(2)] = match.group(1)
            continue
        if re.search('all particles lost', line):
            res += '{}\n'.format(line)
            continue
        if re.search('charge found null', line):
            res += '{}\n'.format(line)
        match = re.search(r'Enjob occured at element # (\d+)', line)
        if match:
            res += '{}\n'.format(line)
            num = match.group(1)
            if num in element_by_num:
                res += '  element # {}: {}\n'.format(num, element_by_num[num])
    path = run_dir.join(template_common.RUN_LOG)
    if res == '' and path.exists():
        text = pkio.read_text(str(path))
        for line in text.split("\n"):
            match = re.search(r'Fortran runtime error: (.*)', line)
            if match:
                res += '{}\n'.format(match.group(1))
    return res
コード例 #2
0
ファイル: plugin.py プロジェクト: tox-dev/tox-conda
def tox_get_python_executable(envconfig):
    if tox.INFO.IS_WIN:
        path = envconfig.envdir.join("python.exe")
    else:
        path = envconfig.envdir.join("bin", "python")
    if path.exists():
        return path
コード例 #3
0
def test_compressed_images(dials_regression, compression, extension,
                           image_to_test, tmp_path):
    path = Path(dials_regression) / "image_examples" / image_to_test
    if not path.exists():
        pytest.skip(str(path) + " not present in dials_regression")

    # Compress this file and write to disk
    test_image_for_reading = str(tmp_path / (path.name + "." + extension))
    with path.open("rb") as f_in:
        with compression(test_image_for_reading, "wb") as f_out:
            shutil.copyfileobj(f_in, f_out)

    # Find and instantiate the format class
    format_class = dxtbx.format.Registry.get_format_class_for_file(
        test_image_for_reading)
    assert format_class is not None, "no matching format class found"
    instance = format_class(test_image_for_reading)

    # Test metadata reading
    assert instance.get_goniometer()
    assert instance.get_beam()
    assert instance.get_scan()
    assert instance.get_detector()
    # Test data reading
    assert instance.get_raw_data()
コード例 #4
0
ファイル: template_common.py プロジェクト: pir8aye/sirepo
def copy_lib_files(data, source, target):
    """Copy auxiliary files to target

    Args:
        data (dict): simulation db
        target (py.path): destination directory
    """
    for f in lib_files(data, source):
        path = target.join(f.basename)
        pkio.mkdir_parent_only(path)
        if not path.exists():
            if not f.exists():
                sim_resource = resource_dir(data.simulationType)
                r = sim_resource.join(f.basename)
                # the file doesn't exist in the simulation lib, check the resource lib
                if r.exists():
                    pkio.mkdir_parent_only(f)
                    r.copy(f)
                else:
                    pkdlog('No file in lib or resource: {}', f)
                    continue
            if source:
                # copy files from another session
                f.copy(path)
            else:
                # symlink into the run directory
                path.mksymlinkto(f, absolute=False)
コード例 #5
0
ファイル: server.py プロジェクト: mrakitin/sirepo
def _mtime_or_now(path):
    """mtime for path if exists else time.time()

    Args:
        path (py.path):

    Returns:
        int: modification time
    """
    return int(path.mtime() if path.exists() else time.time())
コード例 #6
0
ファイル: server.py プロジェクト: roussel-ryan/sirepo
def _mtime_or_now(path):
    """mtime for path if exists else time.time()

    Args:
        path (py.path):

    Returns:
        int: modification time
    """
    return int(path.mtime() if path.exists() else time.time())
コード例 #7
0
    def __call__(self):
        if self._fixture:
            return self._fixture

        self.ensure(self.directory, bool(self.lineage))
        path = self.path(self.directory)
        if not path.exists():
            self.create()
            self.install(self.directory)
        module = self.load(self.root, path, self.lineage)

        if self.module_name is None:
            module_name = self.lineage[-1]
        else:
            module_name = self.module_name

        self._fixture = ModuleFixture(module_name, module, path)
        return self._fixture
コード例 #8
0
ファイル: zgoubi.py プロジェクト: Landau1908/sirepo
def _parse_zgoubi_log(run_dir):
    path = run_dir.join(_ZGOUBI_LOG_FILE)
    if not path.exists():
        return ''
    res = ''
    element_by_num = {}
    text = pkio.read_text(str(path))

    for line in text.split("\n"):
        match = re.search(r'^ (\'\w+\'.*?)\s+(\d+)$', line)
        if match:
            element_by_num[match.group(2)] = match.group(1)
            continue
        if re.search('all particles lost', line):
            res += '{}\n'.format(line)
            continue
        match = re.search(r'Enjob occured at element # (\d+)', line)
        if match:
            res += '{}\n'.format(line)
            num = match.group(1)
            if num in element_by_num:
                res += '  element # {}: {}\n'.format(num, element_by_num[num])
    return res
コード例 #9
0
ファイル: zgoubi.py プロジェクト: e-carlin/sirepo
def _parse_zgoubi_log(run_dir):
    path = run_dir.join(_ZGOUBI_LOG_FILE)
    if not path.exists():
        return ''
    res = ''
    element_by_num = {}
    text = pkio.read_text(str(path))

    for line in text.split("\n"):
        match = re.search(r'^ (\'\w+\'.*?)\s+(\d+)$', line)
        if match:
            element_by_num[match.group(2)] = match.group(1)
            continue
        if re.search('all particles lost', line):
            res += '{}\n'.format(line)
            continue
        match = re.search(r'Enjob occured at element # (\d+)', line)
        if match:
            res += '{}\n'.format(line)
            num = match.group(1)
            if num in element_by_num:
                res += '  element # {}: {}\n'.format(num, element_by_num[num])
    return res
コード例 #10
0
 def path(self, directory):
     path = super(SetsUpPyWithOutOfDatePyc, self).path(directory)
     pyc = self.directory.join(self.PYC_FN)
     if path.exists() and path.mtime() < pyc.mtime():
         path.remove()
     return path