Skip to content

Commit

Permalink
Fix bug that broke shell parsing of *_binpath
Browse files Browse the repository at this point in the history
Because the blahp is insane and the defaults are shell commands
  • Loading branch information
brianhlin committed Jul 21, 2017
1 parent 1f3b79e commit 9bfeb4f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
5 changes: 5 additions & 0 deletions src/scripts/blah.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ def get(self, option):
# paths, for example.
return super(BlahConfigParser, self).get(self.header, option).strip('"\'')

def set(self, option, value):
return super(BlahConfigParser, self).set(self.header, option, value)

def has_option(self, option):
return super(BlahConfigParser, self).has_option(self.header, option)
24 changes: 11 additions & 13 deletions src/scripts/pbs_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,17 @@ def get_qstat_location():
if _qstat_location_cache != None:
return _qstat_location_cache

try:
location = os.path.join(config.get('pbs_binpath'), 'qstat')
except KeyError:
cmd = 'which qstat'
child_stdout = os.popen(cmd)
output = child_stdout.read()
location = output.split("\n")[0].strip()
if child_stdout.close():
raise Exception("Unable to determine qstat location: %s" % output)

_qstat_location_cache = location
return location
if not (config.has_option('pbs_binpath') and config.get('pbs_binpath')):
config.set('pbs_binpath', '/usr/bin')
cmd = 'echo "%s/%s"' % (config.get('pbs_binpath'), 'qstat')

child_stdout = os.popen(cmd)
output = child_stdout.read().split("\n")[0].strip()
if child_stdout.close():
raise Exception("Unable to determine qstat location: %s" % output)

_qstat_location_cache = output
return output

job_id_re = re.compile("\s*Job Id:\s([0-9]+)([\w\-\/.]*)")
exec_host_re = re.compile("\s*exec_host = ([\w\-\/.]+)")
Expand Down Expand Up @@ -528,7 +527,6 @@ def main():
return 1
jobid = jobid_arg.split("/")[-1].split(".")[0]

config_dir = os.path.dirname(os.path.abspath(__file__))
global config
config = blah.BlahConfigParser()

Expand Down
28 changes: 14 additions & 14 deletions src/scripts/slurm_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,18 @@ def get_slurm_location(program):
global _slurm_location_cache
if _slurm_location_cache != None:
return os.path.join(_slurm_location_cache, program)
try:
location = os.path.join(config.get('slurm_binpath'), program)
except KeyError:
cmd = 'which %s' % program
child_stdout = os.popen(cmd)
output = child_stdout.read()
location = output.split("\n")[0].strip()
if child_stdout.close():
raise Exception("Unable to determine scontrol location: %s" % output)

_slurm_location_cache = os.path.dirname(location)
return location

if not (config.has_option('slurm_binpath') and config.get('slurm_binpath')):
config.set('slurm_binpath', '/usr/bin')
cmd = 'echo "%s/%s"' % (config.get('slurm_binpath'), 'scontrol')

child_stdout = os.popen(cmd)
output = child_stdout.read().split("\n")[0].strip()
if child_stdout.close():
raise Exception("Unable to determine scontrol location: %s" % output)

_slurm_location_cache = os.path.dirname(output)
return output

job_id_re = re.compile("JobId=([0-9]+) .*")
exec_host_re = re.compile("\s*BatchHost=([\w\-.]+)")
Expand Down Expand Up @@ -490,8 +490,8 @@ def main():
return 1
jobid = jobid_arg.split("/")[-1].split(".")[0]

config_dir = os.path.dirname(os.path.abspath(__file__))
blah.load_env(config_dir)
global config
config = blah.BlahConfigParser()

log("Checking cache for jobid %s" % jobid)
cache_contents = None
Expand Down

0 comments on commit 9bfeb4f

Please sign in to comment.