Skip to content

Commit c012a1d

Browse files
authored
Merge branch 'master' into dependency-resolver-patch-khillion
2 parents 499e481 + 03a0374 commit c012a1d

File tree

10 files changed

+375
-81
lines changed

10 files changed

+375
-81
lines changed

cwltool/docker.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@
44
import os
55
import re
66
import shutil
7-
import subprocess
87
import sys
98
import tempfile
109
from io import open
11-
1210
import datetime
11+
import threading
12+
1313
import requests
1414
from typing import (Dict, List, Text, Any, MutableMapping, Set)
15-
import threading
1615

1716
from .docker_id import docker_vm_id
1817
from .errors import WorkflowException
1918
from .job import ContainerCommandLineJob
2019
from .pathmapper import PathMapper, ensure_writable
2120
from .secrets import SecretStore
2221
from .utils import docker_windows_path_adjust, onWindows
22+
if os.name == 'posix' and sys.version_info[0] < 3:
23+
import subprocess32 as subprocess # type: ignore
24+
else:
25+
import subprocess # type: ignore
2326

2427
_logger = logging.getLogger("cwltool")
2528

cwltool/docker_id.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
from __future__ import print_function
22
from __future__ import absolute_import
3-
4-
import subprocess
3+
import os
4+
import sys
55
from typing import List, Text, Tuple
6+
if os.name == 'posix' and sys.version_info[0] < 3:
7+
import subprocess32 as subprocess # type: ignore
8+
else:
9+
import subprocess # type: ignore
610

711

812
def docker_vm_id(): # type: () -> Tuple[int, int]

cwltool/job.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import re
1010
import shutil
1111
import stat
12-
import subprocess
1312
import sys
1413
import tempfile
1514
from abc import ABCMeta, abstractmethod
@@ -28,6 +27,11 @@
2827
from .secrets import SecretStore
2928
from .utils import bytes2str_in_dicts
3029
from .utils import copytree_with_merge, onWindows
30+
if os.name == 'posix' and sys.version_info[0] < 3:
31+
import subprocess32 as subprocess # type: ignore
32+
else:
33+
import subprocess # type: ignore
34+
3135

3236
_logger = logging.getLogger("cwltool")
3337

cwltool/resolver.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
from __future__ import absolute_import
22
import logging
33
import os
4+
import sys
45

6+
if sys.version_info < (3, 4):
7+
from pathlib2 import Path
8+
else:
9+
from pathlib import Path
510
from six.moves import urllib
611

7-
from schema_salad.ref_resolver import file_uri
812

913
_logger = logging.getLogger("cwltool")
1014

1115

1216
def resolve_local(document_loader, uri):
13-
if uri.startswith("/"):
14-
return None
15-
shares = [os.environ.get("XDG_DATA_HOME", os.path.join(os.path.expanduser('~'), ".local", "share"))]
16-
shares.extend(os.environ.get("XDG_DATA_DIRS", "/usr/local/share/:/usr/share/").split(":"))
17-
shares = [os.path.join(s, "commonwl", uri) for s in shares]
18-
shares.insert(0, os.path.join(os.getcwd(), uri))
17+
if uri.startswith("/") and os.path.exists(uri):
18+
return Path(uri).as_uri()
19+
if os.path.exists(urllib.parse.urlparse(
20+
urllib.parse.urldefrag(
21+
"{}/{}".format(Path.cwd().as_uri(), uri))[0])[2]):
22+
return "{}/{}".format(Path.cwd().as_uri(), uri)
23+
sharepaths = [os.environ.get("XDG_DATA_HOME", os.path.join(
24+
os.path.expanduser('~'), ".local", "share"))]
25+
sharepaths.extend(os.environ.get(
26+
"XDG_DATA_DIRS", "/usr/local/share/:/usr/share/").split(":"))
27+
shares = [os.path.join(s, "commonwl", uri) for s in sharepaths]
1928

2029
_logger.debug("Search path is %s", shares)
2130

22-
for s in shares:
23-
if os.path.exists(s):
24-
return file_uri(s)
25-
if os.path.exists("%s.cwl" % s):
26-
return file_uri(s)
31+
for path in shares:
32+
if os.path.exists(path):
33+
return Path(uri).as_uri()
34+
if os.path.exists("{}.cwl".format(path)):
35+
return Path("{}.cwl".format(path)).as_uri()
2736
return None
2837

2938

@@ -32,7 +41,6 @@ def tool_resolver(document_loader, uri):
3241
ret = r(document_loader, uri)
3342
if ret is not None:
3443
return ret
35-
return file_uri(os.path.abspath(uri), split_frag=True)
3644

3745

3846
ga4gh_tool_registries = ["https://dockstore.org:8443"]

cwltool/sandboxjs.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@
55
import os
66
import re
77
import select
8-
import subprocess
98
import threading
109
import sys
1110
from io import BytesIO
1211
from typing import Any, Dict, List, Mapping, Text, Tuple, Union
13-
from .utils import onWindows
14-
from pkg_resources import resource_stream
15-
1612
import six
13+
from pkg_resources import resource_stream
14+
from .utils import onWindows
1715

1816
try:
1917
import queue # type: ignore
2018
except ImportError:
2119
import Queue as queue # type: ignore
20+
if os.name == 'posix' and sys.version_info[0] < 3:
21+
import subprocess32 as subprocess # type: ignore
22+
else:
23+
import subprocess # type: ignore
24+
2225

2326
class JavascriptException(Exception):
2427
pass
@@ -194,7 +197,7 @@ def terminate():
194197

195198
PROCESS_FINISHED_STR = "r1cepzbhUTxtykz5XTC4\n"
196199

197-
def process_finished(): # type: () -> bool
200+
def process_finished(): # type: () -> bool
198201
return stdout_buf.getvalue().decode('utf-8').endswith(PROCESS_FINISHED_STR) and \
199202
stderr_buf.getvalue().decode('utf-8').endswith(PROCESS_FINISHED_STR)
200203

@@ -363,4 +366,4 @@ def fn_linenum(): # type: () -> Text
363366
return json.loads(stdout)
364367
except ValueError as e:
365368
raise JavascriptException(u"%s\nscript was:\n%s\nstdout was: '%s'\nstderr was: '%s'\n" %
366-
(e, fn_linenum(), stdout, stderr))
369+
(e, fn_linenum(), stdout, stderr))

0 commit comments

Comments
 (0)