Skip to content

Commit

Permalink
more changes to remove SonarQube complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemccabe committed May 10, 2023
1 parent 3f61ea8 commit 4df71a6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
27 changes: 14 additions & 13 deletions produtil/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,22 @@ def production(self):
file, so the runtime is likely several milliseconds when the
cache times out."""
now=int(time.time())
if self._production is None or \
now-self._lastprod>self._prod_cache_time:
prod=False
if os.path.exists('/etc/prod'):
with open('/etc/prod','rt') as f:
for line in f:
if re.match('[a-z]+',line):
prod = line.strip()==self.name
break
self._production=prod
self._lastprod=int(time.time())
return prod
else:
if (self._production is not None and
now-self._lastprod<=self._prod_cache_time):
return self._production

prod=False
if os.path.exists('/etc/prod'):
with open('/etc/prod','rt') as f:
for line in f:
if re.match('[a-z]+',line):
prod = line.strip()==self.name
break
self._production=prod
self._lastprod=int(time.time())
return prod


class WCOSSCray(NOAAWCOSS):
"""!This subclass of NOAAWCOSS handles the new Cray portions of
WCOSS: Luna and Surge."""
Expand Down
1 change: 0 additions & 1 deletion produtil/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,6 @@ def products(self,*args,**kwargs):
class. The default implementation returns immediately without
doing anything.
@param args,kwargs Implementation-defined, used by subclasses."""
return
for x in []: yield x # ensures this is an iterator
def log(self):
"""!Returns the logger object for this task."""
Expand Down
2 changes: 1 addition & 1 deletion produtil/fileop.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ def checkfiles(self,maxwait=1800,sleeptime=20,logger=None,
flogger=logger
else:
flogger=None
while None is None:
while True:
if len(self._fset)<=0:
if logger is not None:
logger.info('No files to check.')
Expand Down
1 change: 0 additions & 1 deletion produtil/mpi_impl/mpi_impl_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def __init__(self,logger=None):
def synonyms():
"""!Iterates over alternative names for this MPI implementation, such
as the names of other MPI implementations this class can handle."""
return
yield 'xyz' # trick to ensure this is an iterator

def getmpiserial_path(self):
Expand Down
6 changes: 3 additions & 3 deletions produtil/mpi_impl/srun.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def _get_available_nodes(self):
status=p.poll()
for line in nodelist.splitlines():
node=line.strip()
if not node: next
if node in nodeset: next
if not node: continue
if node in nodeset: continue
nodeset.add(node)
available_nodes.append(node)
return available_nodes
Expand Down Expand Up @@ -169,7 +169,7 @@ def mpirunner_impl(self,arg,allranks=False,rewrite_nodefile=True,**kwargs):
remaining_nodes=list(available_nodes)

for rank,count in arg.expand_iter(expand=False):
if count<1: next
if count<1: continue
cmdfile.append('%d-%d %s'%(irank,irank+count-1,rank.to_shell()))
irank+=count
if rewrite_nodefile:
Expand Down
4 changes: 2 additions & 2 deletions produtil/prog.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ def __init__(self,args,**kwargs):
if 'env' in kwargs: self._env=dict(kwargs['env'])

# Initialize input/output/error if requested:
if 'in' in kwargs: self<kwargs['in']
#if 'in' in kwargs: self<kwargs['in']
if 'instr' in kwargs: self<<str(kwargs['instr'])
if 'out' in kwargs: self>kwargs['out']
#if 'out' in kwargs: self>kwargs['out']
if 'outa' in kwargs: self>>kwargs['outa']
if 'err2out' in kwargs: self.err2out()
if 'err' in kwargs: self.err(kwargs['err'],append=False)
Expand Down

0 comments on commit 4df71a6

Please sign in to comment.