From 3f1bd3b70f1e8b7145e060f2be5233fe9cb4deb7 Mon Sep 17 00:00:00 2001 From: Jeremy Mack Wright Date: Wed, 28 Oct 2015 00:09:29 -0400 Subject: [PATCH] Fixed the temp module bug that had popped up in the newest versions of FreeCAD and fixed the extra newlines in the output. --- CadQuery/Gui/Command.py | 8 +++----- CadQuery/Gui/ExportCQ.py | 2 +- CadQuery/Gui/ImportCQ.py | 2 +- CadQuery/InitGui.py | 4 +--- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/CadQuery/Gui/Command.py b/CadQuery/Gui/Command.py index 7a9f1fc..3a15105 100644 --- a/CadQuery/Gui/Command.py +++ b/CadQuery/Gui/Command.py @@ -163,7 +163,6 @@ class CadQueryExecuteScript: tempFile = tempfile.NamedTemporaryFile(delete=False) tempFile.write(cqCodePane.toPlainText().encode('utf-8')) tempFile.close() - FreeCAD.Console.PrintMessage("\r\n") docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0] @@ -173,16 +172,15 @@ class CadQueryExecuteScript: except: FreeCAD.newDocument(docname) - #We import this way because using execfile() causes non-standard script execution in some situations - imp.load_source('temp.module', tempFile.name) + imp.load_source('temp_module', tempFile.name) msg = QtGui.QApplication.translate( "cqCodeWidget", "Executed ", None, QtGui.QApplication.UnicodeUTF8) - FreeCAD.Console.PrintMessage("\r\n" + msg + cqCodePane.file.path) + FreeCAD.Console.PrintMessage(msg + cqCodePane.file.path + "\r\n") class CadQueryNewScript: @@ -279,7 +277,7 @@ class CadQuerySaveScript: #If the code pane doesn't have a filename, we need to present the save as dialog if len(cqCodePane.file.path) == 0 or os.path.basename(cqCodePane.file.path) == 'script_template.py' \ or os.path.split(cqCodePane.file.path)[-2].endswith('Examples'): - FreeCAD.Console.PrintError("\r\nYou cannot save over a blank file, example file or template file.") + FreeCAD.Console.PrintError("You cannot save over a blank file, example file or template file.\r\n") CadQuerySaveAsScript().Activated() diff --git a/CadQuery/Gui/ExportCQ.py b/CadQuery/Gui/ExportCQ.py index dbcbaf1..f69e80e 100644 --- a/CadQuery/Gui/ExportCQ.py +++ b/CadQuery/Gui/ExportCQ.py @@ -28,4 +28,4 @@ def save(filename=None): "Saved ", None, QtGui.QApplication.UnicodeUTF8) - FreeCAD.Console.PrintMessage("\r\n" + msg + cqCodePane.file.path) + FreeCAD.Console.PrintMessage(msg + cqCodePane.file.path + "\r\n") diff --git a/CadQuery/Gui/ImportCQ.py b/CadQuery/Gui/ImportCQ.py index a3cd04b..a16778d 100644 --- a/CadQuery/Gui/ImportCQ.py +++ b/CadQuery/Gui/ImportCQ.py @@ -27,6 +27,6 @@ def open(filename): "Opened ", None, QtGui.QApplication.UnicodeUTF8) - FreeCAD.Console.PrintMessage("\r\n" + msg + filename) + FreeCAD.Console.PrintMessage(msg + filename + "\r\n") return diff --git a/CadQuery/InitGui.py b/CadQuery/InitGui.py index 78e9dcf..6f9c147 100644 --- a/CadQuery/InitGui.py +++ b/CadQuery/InitGui.py @@ -95,7 +95,7 @@ class CadQueryWorkbench (Workbench): "Please install Python 2.7", None, QtGui.QApplication.UnicodeUTF8) - FreeCAD.Console.PrintError("\r\n" + msg) + FreeCAD.Console.PrintError(msg + "\r\n") #The extra version numbers won't work on Windows if sys.platform.startswith('win'): @@ -104,8 +104,6 @@ class CadQueryWorkbench (Workbench): #Getting the main window will allow us to start setting things up the way we want mw = FreeCADGui.getMainWindow() - # TODO: Fix the extra newline foolishness with the output in the report view - dockWidgets = mw.findChildren(QtGui.QDockWidget) for widget in dockWidgets: