This repository was archived by the owner on Oct 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77class BlahConfigParser (RawConfigParser , object ):
88
9- def __init__ (self , path = '/etc/blah.config' ):
9+ def __init__ (self , path = '/etc/blah.config' , defaults = None ):
1010 # RawConfigParser requires ini-style [section headers] but since
1111 # blah.config is also used as a shell script we need to fake one
1212 self .header = 'blahp'
1313 with open (path ) as f :
1414 config = f .read ()
1515 vfile = StringIO (u'[%s]\n %s' % (self .header , config ))
1616
17- super (BlahConfigParser , self ).__init__ ()
17+ super (BlahConfigParser , self ).__init__ (defaults = defaults )
1818 # TODO: readfp() is replaced by read_file() in Python 3.2+
1919 self .readfp (vfile )
2020
Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ def qstat(jobid=""):
233233 starttime = time .time ()
234234 log ("Starting qstat." )
235235 command = (qstat_bin , '-f' )
236- if config .has_option ( 'pbs_pro' ) and config . get ('pbs_pro' ).lower () != 'yes' :
236+ if config .get ('pbs_pro' ).lower () != 'yes' :
237237 command += ('-1' ,) # -1 conflicts with -f in PBS Pro
238238 if jobid :
239239 command += (jobid ,)
@@ -358,8 +358,6 @@ def get_qstat_location():
358358 if _qstat_location_cache != None :
359359 return _qstat_location_cache
360360
361- if not (config .has_option ('pbs_binpath' ) and config .get ('pbs_binpath' )):
362- config .set ('pbs_binpath' , '/usr/bin' )
363361 cmd = 'echo "%s/%s"' % (config .get ('pbs_binpath' ), 'qstat' )
364362
365363 child_stdout = os .popen (cmd )
@@ -528,7 +526,8 @@ def main():
528526 jobid = jobid_arg .split ("/" )[- 1 ].split ("." )[0 ]
529527
530528 global config
531- config = blah .BlahConfigParser ()
529+ config = blah .BlahConfigParser (defaults = {'pbs_pro' : 'no' ,
530+ 'pbs_binpath' : '/usr/bin' })
532531
533532 log ("Checking cache for jobid %s" % jobid )
534533 cache_contents = None
Original file line number Diff line number Diff line change @@ -344,8 +344,6 @@ def get_slurm_location(program):
344344 if _slurm_location_cache != None :
345345 return os .path .join (_slurm_location_cache , program )
346346
347- if not (config .has_option ('slurm_binpath' ) and config .get ('slurm_binpath' )):
348- config .set ('slurm_binpath' , '/usr/bin' )
349347 cmd = 'echo "%s/%s"' % (config .get ('slurm_binpath' ), 'scontrol' )
350348
351349 child_stdout = os .popen (cmd )
@@ -499,7 +497,7 @@ def main():
499497 jobid = jobid_arg .split ("/" )[- 1 ].split ("." )[0 ]
500498
501499 global config
502- config = blah .BlahConfigParser ()
500+ config = blah .BlahConfigParser (defaults = { 'slurm_binpath' : '/usr/bin' } )
503501
504502 log ("Checking cache for jobid %s" % jobid )
505503 cache_contents = None
You can’t perform that action at this time.
0 commit comments