aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2021-12-30 23:34:51 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2021-12-30 23:34:51 -0500
commitc4514f27759e05bcbcd21cbd52859e421a3938f2 (patch)
tree640da6542ea2ef8c316b6742fae0f72d7ba9a272
parentc01d8dc26998d366b38c364a7e3c09888d2dce67 (diff)
downloadhtc_utils-c4514f27759e05bcbcd21cbd52859e421a3938f2.tar.gz
Fix HTCondor program detection logic
-rw-r--r--htc_utils/bindings/__init__.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/htc_utils/bindings/__init__.py b/htc_utils/bindings/__init__.py
index 7f403e1..9cfa584 100644
--- a/htc_utils/bindings/__init__.py
+++ b/htc_utils/bindings/__init__.py
@@ -6,23 +6,26 @@ from distutils.spawn import find_executable
__all__ = ['htcondor_path', 'recast', 'Job', 'Submit', 'Wait']
def htcondor_path(path=None):
- needles = ['condor_master', 'condor_submit', 'condor_wait']
+ programs = ['condor_master', 'condor_submit', 'condor_wait']
paths = []
+ if '/usr/sbin' not in os.environ['PATH']:
+ os.environ['PATH'] += ":/usr/sbin"
+
if path is not None:
os.environ['PATH'] = ':'.join([os.path.join(path, 'bin'), os.environ['PATH']])
os.environ['PATH'] = ':'.join([os.path.join(path, 'sbin'), os.environ['PATH']])
- for needle in needles:
- try:
- executable = find_executable(needle, os.environ['PATH'])
- path = os.path.dirname(executable)
- paths.append(path)
- except AttributeError:
- pass
+ for program in programs:
+ executable = find_executable(program, os.environ['PATH'])
+ if not executable:
+ continue
+ path = os.path.dirname(executable)
+ paths.append(path)
if not paths:
- raise OSError('Unable to find a valid HTCondor installation.')
+ raise OSError('HTCondor installation not found. '
+ 'Modify your PATH variable and try again.'.format(", ".join(programs)))
return ':'.join(paths)