Example #1
0
def test_find_executable_path():
    with tempdir() as d:
        f = d / "foo"
        with open(f, "wt") as out:
            out.write("foo")
        os.chmod(f, stat.S_IRUSR)
        assert find_executable_path("foo", [d]) is None
        make_executable(f)
        assert find_executable_path("foo", [d]) == f
Example #2
0
def test_find_executable_path_system():
    with tempdir() as d:
        f = d / "foo"
        with open(f, "wt") as out:
            out.write("foo")
        os.chmod(f, stat.S_IRUSR)
        with setenv({"PATH": str(d)}):
            assert find_executable_path("foo") is None
            make_executable(f)
            assert find_executable_path("foo") == f
Example #3
0
    def __init__(self,
                 project_root: Path,
                 import_dirs: Optional[List[Path]] = None,
                 java_bin: Optional[Union[str, Path]] = None,
                 java_args: Optional[str] = None,
                 cromwell_jar_file: Optional[Union[str, Path]] = None,
                 cromwell_config_file: Optional[Union[str, Path]] = None,
                 cromwell_args: Optional[str] = None):
        self.project_root = project_root
        self.import_dirs = import_dirs

        if not java_bin:
            java_home = os.environ.get(ENV_JAVA_HOME)
            if java_home:
                java_bin = Path(java_home) / "bin" / "java"
            else:
                java_bin = find_executable_path("java")

        if not java_bin:
            raise FileNotFoundError("Could not find java executable")

        self.java_bin = ensure_path(java_bin,
                                    exists=True,
                                    is_file=True,
                                    executable=True)

        if not cromwell_jar_file:
            cromwell_jar = os.environ.get(ENV_CROMWELL_JAR)
            if cromwell_jar:
                cromwell_jar_file = ensure_path(cromwell_jar)
            else:
                cromwell_jar_file = find_in_classpath("cromwell*.jar")

        if not cromwell_jar_file:
            raise FileNotFoundError("Could not find Cromwell JAR file")

        self.cromwell_jar_file = ensure_path(cromwell_jar_file,
                                             is_file=True,
                                             exists=True)

        if not cromwell_config_file:
            config_file = os.environ.get(ENV_CROMWELL_CONFIG)
            if config_file:
                cromwell_config_file = ensure_path(config_file)
        if cromwell_config_file:
            self.cromwell_config_file = ensure_path(cromwell_config_file,
                                                    is_file=True,
                                                    exists=True)
        else:
            self.cromwell_config_file = None

        if not java_args and self.cromwell_config_file:
            java_args = f"-Dconfig.file={self.cromwell_config_file}"
        self.java_args = java_args

        self.cromwell_args = cromwell_args or os.environ.get(ENV_CROMWELL_ARGS)
Example #4
0
    def __init__(self,
                 java_bin: Optional[Union[str, Path]] = None,
                 java_args: Optional[str] = None):
        if not java_bin:
            java_home = os.environ.get(ENV_JAVA_HOME)
            if java_home:
                java_bin = Path(java_home) / "bin" / "java"
            else:
                java_bin = find_executable_path("java")

        if not java_bin:
            raise FileNotFoundError("Could not find java executable")

        self.java_bin = ensure_path(java_bin,
                                    exists=True,
                                    is_file=True,
                                    executable=True)

        self.java_args = java_args or os.environ.get(ENV_JAVA_ARGS)