[Tools] Fix static analyis issues

This commit addresses issues identified by LGTM for the various
independent (and mostly-independent) files in the Tools subdirectory.
The vast majority of the issues are trivial, and are things like unused
imports or catching BaseException. There was one true bug identified, a
global variable being changed in a function where it was not marked
global, but it only affected output quantity (the variable is named
"VERBOSE"). A couple of other issues identified variables that appear to
represent no-longer-existing options in the code. The options were left,
but a deprecation printout replaces the variable in the event the option
is provided.
This commit is contained in:
Chris Hennes
2021-02-25 22:48:01 -06:00
committed by wwmayer
parent bcb070def1
commit e2bb84fd2f
22 changed files with 144 additions and 183 deletions

View File

@@ -40,20 +40,20 @@ def cpall(dirFrom, dirTo):
pathTo = os.path.join(dirTo, file) # extend both paths
if not os.path.isdir(pathFrom): # copy simple files
try:
if verbose > 1: print('copying', pathFrom, 'to', pathTo)
if verbose > 1: print('copying ', pathFrom, ' to ', pathTo)
cpfile(pathFrom, pathTo)
fcount = fcount+1
except:
print('Error copying', pathFrom, 'to', pathTo, '--skipped')
except Exception:
print('Error copying ', pathFrom, ' to ', pathTo, ' -- skipped')
print(sys.exc_info()[0], sys.exc_info()[1])
else:
if verbose: print('copying dir', pathFrom, 'to', pathTo)
if verbose: print('copying dir ', pathFrom, ' to ', pathTo)
try:
os.mkdir(pathTo) # make new subdir
cpall(pathFrom, pathTo) # recur into subdirs
dcount = dcount+1
except:
print('Error creating', pathTo, '--skipped')
except Exception:
print('Error creating ', pathTo, ' -- skipped')
print(sys.exc_info()[0], sys.exc_info()[1])
def SetUpFilter(MatchList):
@@ -79,20 +79,20 @@ def cpallWithFilter(dirFrom, dirTo,MatchList):
pathTo = os.path.join(dirTo, file) # extend both paths
if not os.path.isdir(pathFrom): # copy simple files
try:
if verbose > 1: print('copying', pathFrom, 'to', pathTo)
if verbose > 1: print('copying ', pathFrom, ' to ', pathTo)
cpfile(pathFrom, pathTo)
fcount = fcount+1
except:
print('Error copying', pathFrom, 'to', pathTo, '--skipped')
except Exception:
print('Error copying ', pathFrom, ' to ', pathTo, ' -- skipped')
print(sys.exc_info()[0], sys.exc_info()[1])
else:
if verbose: print('copying dir', pathFrom, 'to', pathTo)
if verbose: print('copying dir ', pathFrom, ' to ', pathTo)
try:
os.mkdir(pathTo) # make new subdir
cpallWithFilter(pathFrom, pathTo,MatchList) # recur into subdirs
dcount = dcount+1
except:
print('Error creating', pathTo, '--skipped')
except Exception:
print('Error creating ', pathTo, ' -- skipped')
print(sys.exc_info()[0], sys.exc_info()[1])
################################################################