py3: App: FreeCADInit.py

This commit is contained in:
looooo
2017-03-09 12:18:04 +01:00
committed by wmayer
parent e392642e69
commit 5558d84a64

View File

@@ -36,7 +36,7 @@ import FreeCAD
def InitApplications():
try:
import sys,os,traceback,cStringIO
import sys,os,traceback,io
except ImportError:
FreeCAD.Console.PrintError("\n\nSeems the python standard libs are not installed, bailing out!\n\n")
raise
@@ -88,7 +88,7 @@ def InitApplications():
PathExtension = BinDir + os.pathsep
# prepend all module paths to Python search path
Log('Init: Searching for modules...\n')
FreeCAD.__path__ = ModDict.values()
FreeCAD.__path__ = list(ModDict.values())
for Dir in ModDict.values():
if ((Dir != '') & (Dir != 'CVS') & (Dir != '__init__.py')):
sys.path.insert(0,Dir)
@@ -96,16 +96,15 @@ def InitApplications():
InstallFile = os.path.join(Dir,"Init.py")
if (os.path.exists(InstallFile)):
try:
#execfile(InstallFile)
exec open(InstallFile).read()
except Exception, inst:
# XXX: This looks scary securitywise...
with open(InstallFile) as f:
exec(f.read())
except Exception as inst:
Log('Init: Initializing ' + Dir + '... failed\n')
Log('-'*100+'\n')
output=cStringIO.StringIO()
traceback.print_exc(file=output)
Log(output.getvalue())
Log(traceback.format_exc())
Log('-'*100+'\n')
Err('During initialization the error ' + str(inst).decode('ascii','replace') + ' occurred in ' + InstallFile + '\n')
Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n')
else:
Log('Init: Initializing ' + Dir + '... done\n')
else: