[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

@@ -165,7 +165,7 @@ def crawl(site=DEFAULTURL):
if PDFCONVERTOR == 'pisa':
try:
import ho.pisa as pisa
except: ("Error: Python-pisa not installed, exiting.")
except Exception: ("Error: Python-pisa not installed, exiting.")
return 1
else:
if os.system('htmldoc --version'):
@@ -173,7 +173,7 @@ def crawl(site=DEFAULTURL):
return 1
try:
from pyPdf import PdfFileReader,PdfFileWriter
except:
except Exception:
print ("Error: Python-pypdf not installed, exiting.")
# run ########################################################
@@ -273,7 +273,7 @@ def joinpdf(folder=TMPFOLDER,startpage=INDEX,outputname='freecad.pdf'):
if exists(p[:-5]):
if VERBOSE: print ('Appending',p)
try: inputfile = PdfFileReader(open(folder+os.sep+p[:-5]+'.pdf','rb'))
except: print ('Unable to append',p)
except Exception: print ('Unable to append',p)
else:
for i in range(inputfile.getNumPages()):
result.addPage(inputfile.getPage(i))
@@ -538,7 +538,7 @@ def fetchimage(imagelink):
file.close()
processed.append(filename)
return
except:
except Exception:
failcount += 1
print ('Error: unable to fetch file ' + filename)
@@ -574,7 +574,7 @@ def output(html,page):
file.close()
def main(arg):
global QHELPCOMPILER,QCOLLECTIOMGENERATOR,OUTPUTPATH,PDFOUTPUT,PDFCONVERTOR,TMPFOLDER
global QHELPCOMPILER,QCOLLECTIOMGENERATOR,OUTPUTPATH,PDFOUTPUT,PDFCONVERTOR,TMPFOLDER,VERBOSE
try:
opts, args = getopt.getopt(sys.argv[1:], "hp:t:c:g:o:", ["help", "pdf=", "noremove", "tempfolder=", "helpcompiler-exe=", "out-path=", "helpgenerator-exe="])
except getopt.GetoptError: