diff --git a/nipype/utils/filemanip.py b/nipype/utils/filemanip.py index 8bf4c456d2..bf73335d8f 100644 --- a/nipype/utils/filemanip.py +++ b/nipype/utils/filemanip.py @@ -880,24 +880,29 @@ def get_dependencies(name, environ): Uses otool on darwin, ldd on linux. Currently doesn't support windows. """ + command = None if sys.platform == 'darwin': - proc = sp.Popen( - 'otool -L `which %s`' % name, - stdout=sp.PIPE, - stderr=sp.PIPE, - shell=True, - env=environ) + command = 'otool -L `which %s`' % name elif 'linux' in sys.platform: + command = 'ldd `which %s`' % name + else: + return 'Platform %s not supported' % sys.platform + + deps = None + try: proc = sp.Popen( - 'ldd `which %s`' % name, + command, stdout=sp.PIPE, stderr=sp.PIPE, shell=True, env=environ) - else: - return 'Platform %s not supported' % sys.platform - o, e = proc.communicate() - return o.rstrip() + o, e = proc.communicate() + deps = o.rstrip() + except Exception as ex: + deps = '"%s" failed' % command + fmlogger.warning('Could not get dependencies of %s. Error:\n%s', + name, ex.message) + return deps def canonicalize_env(env):