Repository: common-workflow-language/cwltool

Issue:
Searching for node/nodejs in sandboxjs.py broken
## Expected Behavior
Checking for the existence of nodejs or node should not throw an exception.

## Actual Behavior
The code that checks for the presence of node/nodejs does not catch the correct exception when a given binary is not present. It should just gracefully catch the exception an move on with its life.

## Proposed fix
Change line 81 of sandboxjs.py from:
```python
        except OSError as e:
            if e.errno == errno.ENOENT:
                pass
            else:
                raise
```
to:
```python
        except OSError as e:
            if e.errno == errno.ENOENT or e.errno == errno.EACCES:                                                                                                                                                          
                pass
            else:
                raise
```

## Workflow Code
Running part 13 of the tutorial on CentOS 7, with nodejs-6.11.1-1.el7.x86_64 installed is sufficient  (i.e. node, not nodejs is the name of the binary).

## Full Traceback
```pytb
(cwl) [gpdock02]~/cloud/test/cwl_experiments$ cwltool --debug expression.cwl empty.yml 
/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/bin/cwltool 1.0.20180508202931
Resolved 'expression.cwl' to 'file:///panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/test/cwl_experiments/expression.cwl'
I'm sorry, I couldn't load this CWL file.  The error was:
Traceback (most recent call last):
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/main.py", line 502, in main
    makeTool, make_tool_kwds)
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/load_tool.py", line 341, in make_tool
    tool = makeTool(processobj, **kwargs)
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/workflow.py", line 40, in defaultMakeTool
    return command_line_tool.CommandLineTool(toolpath_object, **kwargs)
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/command_line_tool.py", line 200, in __init__
    super(CommandLineTool, self).__init__(toolpath_object, **kwargs)
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/process.py", line 527, in __init__
    validate_js_expressions(cast(CommentedMap, toolpath_object), self.doc_schema.names[toolpath_object["class"]], validate_js_options)
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/validate_js.py", line 187, in validate_js_expressions
    expression_errors, _ = jshint_js(code_fragment_js, js_globals, jshint_options)
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/validate_js.py", line 113, in jshint_js
    context=jshint_functions_text
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/sandboxjs.py", line 162, in exec_js_process
    new_proc = new_js_proc(js_engine_code, force_docker_pull=force_docker_pull)
  File "/panfs/pan1.be-md.ncbi.nlm.nih.gov/gpipe/home/slottad/cloud/virtenvs/cwl/lib/python3.6/site-packages/cwltool/sandboxjs.py", line 68, in new_js_proc
    if subprocess.check_output([n, "--eval", "process.stdout.write('t')"]).decode('utf-8') != "t":
  File "/opt/python-3.6/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/opt/python-3.6/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/opt/python-3.6/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/opt/python-3.6/lib/python3.6/subprocess.py", line 1333, in _execute_child
    raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied
```

## Your Environment
* cwltool version: 1.0.20180508202931



Discussion:
I'm a little surprised by the error, I think that might happen if you tried to run a binary for which the current user lacked the read or execute bit.  (Unfortunately "node" is a very common term and so it is really easy to conflict with other things).  However it should probably treat any OSError as "didn't work, so get on with it".  PR welcome.
I'm a little befuddled too, since it does this for `nodejs`, which does not exist at all. This is for two different versions of python (3.5.7 and 3.6.2, custom builds) on our systems. I agree that it shouldn't care about the specific OSError type. 

Resolving patch:
diff --git a/cwltool/sandboxjs.py b/cwltool/sandboxjs.py
--- a/cwltool/sandboxjs.py
+++ b/cwltool/sandboxjs.py
@@ -71,13 +71,8 @@ def new_js_proc(js_text, force_docker_pull=False):
 
                 required_node_version = check_js_threshold_version(n)
                 break
-        except subprocess.CalledProcessError:
+        except (subprocess.CalledProcessError, OSError):
             pass
-        except OSError as e:
-            if e.errno == errno.ENOENT:
-                pass
-            else:
-                raise
 
     if nodejs is None or nodejs is not None and required_node_version is False:
         try:


Test patch: