Skip to content

Commit 4401c62

Browse files
committed
Utility functions for better getting condor_config_val
- get_condor_config_val now takes a "subsystem" argument and can look for condor_config_val in CONDOR_LOCATION instead of defaulting to looking through PATH. - get_condor_ce_config_val is a wrapper around get_condor_config_val that uses condor_ce_config_val.
1 parent e948d4b commit 4401c62

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

osg_configure/modules/utilities.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def get_condor_config(default_config='/etc/condor/condor_config'):
296296
return os.path.join(get_condor_location(), 'etc/condor_config')
297297

298298

299-
def get_condor_config_val(variable, executable='condor_config_val', quiet_undefined=False):
299+
def get_condor_config_val(variable, executable=None, quiet_undefined=False, subsystem=None):
300300
"""
301301
Use condor_config_val to return the expanded value of a variable.
302302
@@ -306,12 +306,24 @@ def get_condor_config_val(variable, executable='condor_config_val', quiet_undefi
306306
poll condor_ce_config_val or condor_cron_config_val)
307307
quiet_undefined - set to True if messages from condor_config_val
308308
claiming the variable is undefined should be silenced
309+
subsystem - if passed, query a specific subsystem (SCHEDD, COLLECTOR, etc.)
309310
Returns:
310311
The stripped output of condor_config_val, or None if
311312
condor_config_val reports an error.
312313
"""
314+
if not executable:
315+
condor_location = get_condor_location()
316+
if condor_location:
317+
executable = os.path.join(condor_location, "bin/condor_config_val")
318+
else:
319+
executable = "condor_config_val"
320+
313321
try:
314-
process = subprocess.Popen([executable, variable],
322+
cmd = [executable]
323+
if subsystem:
324+
cmd.extend(["-subsystem", subsystem])
325+
cmd.append(variable)
326+
process = subprocess.Popen(cmd,
315327
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
316328
encoding="latin-1")
317329
output, error = process.communicate()
@@ -324,6 +336,11 @@ def get_condor_config_val(variable, executable='condor_config_val', quiet_undefi
324336
return None
325337

326338

339+
def get_condor_ce_config_val(variable, *args, **kwargs):
340+
kwargs["executable"] = "/usr/bin/condor_ce_config_val"
341+
return get_condor_config_val(variable, *args, **kwargs)
342+
343+
327344
def read_file(filename, default=None):
328345
"""
329346
Read the contents of a file, returning default if the file cannot be read.

0 commit comments

Comments
 (0)