Minor tweaks to Start recommended by LGTM

Using the results of the vulnerability scan at lgtm.com, some minor
changes were made. First, all Python exception handling now explicitly
catches Exception, rather than BaseException (which would include SystemExit
and KeyboardInterrupt). Second, unused imports were removed. Third, a
couple of unnecessary or unused assignments were addressed. Finally, the
JavaScript was modified to explicitly declare the local ddiv variable when
needed.
This commit is contained in:
Chris Hennes
2021-01-26 20:38:51 -06:00
parent 2f731b7da7
commit ba8e0aa863
4 changed files with 13 additions and 14 deletions

View File

@@ -20,6 +20,6 @@
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
import FreeCAD
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start")
rf.SetBool("AllowDownload",True)

View File

@@ -20,7 +20,7 @@
#* *
#***************************************************************************
import FreeCADGui,sys
import FreeCADGui
# MRU will be given before this script is run
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
FreeCADGui.loadFile(rf.GetString("MRU"+str(MRU)))

View File

@@ -31,7 +31,7 @@ function load() {
if (allowDownloads == 1) {
// load latest commits
ddiv = document.getElementById("commits");
var ddiv = document.getElementById("commits");
ddiv.innerHTML = "Connecting...";
var tobj=new JSONscriptRequest('https://api.github.com/repos/FreeCAD/FreeCAD/commits?callback=printCommits');
tobj.buildScriptTag(); // Build the script tag
@@ -61,7 +61,7 @@ function printCommits(data) {
// json callback for git commits
ddiv = document.getElementById('commits');
var ddiv = document.getElementById('commits');
ddiv.innerHTML = "Received";
var html = ['<ul>'];
for (var i = 0; i < 25; i++) {
@@ -76,7 +76,7 @@ function printAddons(data) {
// json callback for addons list
ddiv = document.getElementById('addons');
var ddiv = document.getElementById('addons');
ddiv.innerHTML = "Received";
var html = ['<ul class="addonslist">'];
var blacklist = ['addons_installer.FCMacro','FreeCAD-Addon-Details.md','README.md'];
@@ -98,7 +98,7 @@ function printForum(data) {
// json callback for forum posts
ddiv = document.getElementById('forum');
var ddiv = document.getElementById('forum');
ddiv.innerHTML = "Received";
var html = ['<ul>'];
for (var i = 0; i < 25; i++) {

View File

@@ -25,7 +25,7 @@
# the html code of the start page. It is built only once per FreeCAD session for now...
import six
import sys,os,FreeCAD,FreeCADGui,tempfile,time,zipfile,urllib,re
import sys,os,FreeCAD,FreeCADGui,tempfile,time,zipfile,re
from . import TranslationTexts
from PySide import QtCore,QtGui
@@ -107,7 +107,7 @@ def getInfo(filename):
try:
import gnome.ui
import gnomevfs
except:
except Exception:
# alternative method
import hashlib
fhash = hashlib.md5(("file://"+path).encode("utf8")).hexdigest()
@@ -140,7 +140,7 @@ def getInfo(filename):
if filename.lower().endswith(".fcstd"):
try:
zfile=zipfile.ZipFile(filename)
except:
except Exception:
print("Cannot read file: ",filename)
return None
files=zfile.namelist()
@@ -366,7 +366,6 @@ def handle():
# build SECTION_RECENTFILES
SECTION_RECENTFILES = encode("")
rf = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
rfcount = rf.GetInt("RecentFiles",0)
SECTION_RECENTFILES = encode("<h2>"+TranslationTexts.T_RECENTFILES+"</h2>")
@@ -493,7 +492,7 @@ def handle():
img = os.path.join(resources_dir,"images/freecad.png")
iconbank[wb] = img
UL_WORKBENCHES += '<li>'
UL_WORKBENCHES += '<img src="file:///'+iconbank[wb]+'">&nbsp;'
UL_WORKBENCHES += '<img src="file:///'+img+'">&nbsp;'
UL_WORKBENCHES += '<a href="https://www.freecadweb.org/wiki/'+wn+'_Workbench">'+wn.replace("ReverseEngineering","ReverseEng")+'</a>'
UL_WORKBENCHES += '</li>'
UL_WORKBENCHES += '</ul>'
@@ -503,19 +502,19 @@ def handle():
try:
import dxfLibrary
except:
except Exception:
pass
else:
wblist.append("dxf-library")
try:
import RebarTools
except:
except Exception:
pass
else:
wblist.append("reinforcement")
try:
import CADExchangerIO
except:
except Exception:
pass
else:
wblist.append("cadexchanger")