diff --git a/cwltool/docker.py b/cwltool/docker.py index b1c1b7bbf..ee3472340 100644 --- a/cwltool/docker.py +++ b/cwltool/docker.py @@ -156,8 +156,8 @@ def get_image( found = True elif "dockerFile" in docker_requirement: dockerfile_dir = create_tmp_dir(tmp_outdir_prefix) - with open(os.path.join(dockerfile_dir, "Dockerfile"), "wb") as dfile: - dfile.write(docker_requirement["dockerFile"].encode("utf-8")) + with open(os.path.join(dockerfile_dir, "Dockerfile"), "w") as dfile: + dfile.write(docker_requirement["dockerFile"]) cmd = [ "docker", "build", diff --git a/cwltool/job.py b/cwltool/job.py index 72488df7c..1502574a9 100644 --- a/cwltool/job.py +++ b/cwltool/job.py @@ -685,8 +685,8 @@ def create_file_and_add_volume( dirname = os.path.dirname(host_outdir_tgt or new_file) if not os.path.exists(dirname): os.makedirs(dirname) - with open(host_outdir_tgt or new_file, "wb") as file_literal: - file_literal.write(contents.encode("utf-8")) + with open(host_outdir_tgt or new_file, "w") as file_literal: + file_literal.write(contents) if not host_outdir_tgt: self.append_volume(runtime, new_file, volume.target, writable=writable) if writable: @@ -1031,8 +1031,8 @@ def terminate(): # type: () -> None ) as job_file: json_dump(job_description, job_file, ensure_ascii=False) job_script = os.path.join(job_dir, "run_job.bash") - with open(job_script, "wb") as _: - _.write(job_script_contents.encode("utf-8")) + with open(job_script, "w") as _: + _.write(job_script_contents) job_run = os.path.join(job_dir, "run_job.py") shutil.copyfile(run_job.__file__, job_run) @@ -1041,7 +1041,7 @@ def terminate(): # type: () -> None shutil.copyfile(env_to_stdout.__file__, env_getter) sproc = subprocess.Popen( # nosec - ["bash", job_script.encode("utf-8")], + ["bash", job_script], shell=False, # nosec cwd=job_dir, # The nested script will output the paths to the correct files if they need diff --git a/cwltool/process.py b/cwltool/process.py index f33ff0739..fa2338d3a 100644 --- a/cwltool/process.py +++ b/cwltool/process.py @@ -312,13 +312,11 @@ def stage_files( shutil.copytree(entry.resolved, entry.target) ensure_writable(entry.target, include_root=True) elif entry.type == "CreateFile" or entry.type == "CreateWritableFile": - with open(entry.target, "wb") as new: + with open(entry.target, "w") as new: if secret_store is not None: - new.write( - cast(str, secret_store.retrieve(entry.resolved)).encode("utf-8") - ) + new.write(cast(str, secret_store.retrieve(entry.resolved))) else: - new.write(entry.resolved.encode("utf-8")) + new.write(entry.resolved) if entry.type == "CreateFile": os.chmod(entry.target, stat.S_IRUSR) # Read only else: # it is a "CreateWritableFile"