Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Fix bugs in constructing the path to pbs/slurm query commands
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhlin committed Jul 13, 2017
1 parent 87286a7 commit 273f7bc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/scripts/blah.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ def items(self):
return super(BlahConfigParser, self).items(self.header)

def get(self, option):
return super(BlahConfigParser, self).get(self.header, option)
# ConfigParser happily includes quotes in value strings, which we
# happily allow in /etc/blah.config. This causes failures when joining
# paths, for example.
return super(BlahConfigParser, self).get(self.header, option).strip('"\'')

14 changes: 8 additions & 6 deletions src/scripts/pbs_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,17 @@ def get_qstat_location():
global _qstat_location_cache
if _qstat_location_cache != None:
return _qstat_location_cache

try:
cmd = os.path.join(config.get('pbs_binpath'), 'qstat')
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)
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

Expand Down
13 changes: 7 additions & 6 deletions src/scripts/slurm_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,15 @@ def get_slurm_location(program):
if _slurm_location_cache != None:
return os.path.join(_slurm_location_cache, program)
try:
cmd = os.path.join(config.get('slurm_binpath'), program)
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)
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

Expand Down

0 comments on commit 273f7bc

Please sign in to comment.