Skip to content

Commit

Permalink
use open from io rather than open builtin for more consistent behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
manu-chroma committed Jul 13, 2017
1 parent c5ac2f7 commit 69d4178
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cwltool/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import sys
import tempfile
from io import open
from typing import Dict, List, Text

import requests
Expand Down Expand Up @@ -56,7 +57,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
found = True
elif "dockerFile" in dockerRequirement:
dockerfile_dir = str(tempfile.mkdtemp())
with open(os.path.join(dockerfile_dir, "Dockerfile"), str("w")) as df:
with open(os.path.join(dockerfile_dir, "Dockerfile"), "wb") as df:
df.write(dockerRequirement["dockerFile"].encode('utf-8'))
cmd = ["docker", "build", "--tag=%s" %
str(dockerRequirement["dockerImageId"]), dockerfile_dir]
Expand All @@ -70,7 +71,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
if not dry_run:
if os.path.exists(dockerRequirement["dockerLoad"]):
_logger.info(u"Loading docker image from %s", dockerRequirement["dockerLoad"])
with open(dockerRequirement["dockerLoad"], str("rb")) as f:
with open(dockerRequirement["dockerLoad"], "rb") as f:
loadproc = subprocess.Popen(cmd, stdin=f, stdout=sys.stderr)
else:
loadproc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=sys.stderr)
Expand Down
1 change: 1 addition & 0 deletions cwltool/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import subprocess
import sys
import tempfile
from io import open
from typing import (IO, Any, Callable, Dict, Iterable, List, MutableMapping, Text,
Tuple, Union, cast)

Expand Down
1 change: 1 addition & 0 deletions cwltool/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import tempfile
import uuid
from collections import Iterable
from io import open
from functools import cmp_to_key
from typing import (Any, Callable, Dict, Generator, List, Set, Text,
Tuple, Union, cast)
Expand Down

0 comments on commit 69d4178

Please sign in to comment.