Fixed the temp module bug that had popped up in the newest versions of FreeCAD and fixed the extra newlines in the output.
This commit is contained in:
parent
00f5bf8f66
commit
3f1bd3b70f
|
@ -163,7 +163,6 @@ class CadQueryExecuteScript:
|
||||||
tempFile = tempfile.NamedTemporaryFile(delete=False)
|
tempFile = tempfile.NamedTemporaryFile(delete=False)
|
||||||
tempFile.write(cqCodePane.toPlainText().encode('utf-8'))
|
tempFile.write(cqCodePane.toPlainText().encode('utf-8'))
|
||||||
tempFile.close()
|
tempFile.close()
|
||||||
FreeCAD.Console.PrintMessage("\r\n")
|
|
||||||
|
|
||||||
docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0]
|
docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0]
|
||||||
|
|
||||||
|
@ -173,16 +172,15 @@ class CadQueryExecuteScript:
|
||||||
except:
|
except:
|
||||||
FreeCAD.newDocument(docname)
|
FreeCAD.newDocument(docname)
|
||||||
|
|
||||||
|
|
||||||
#We import this way because using execfile() causes non-standard script execution in some situations
|
#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(
|
msg = QtGui.QApplication.translate(
|
||||||
"cqCodeWidget",
|
"cqCodeWidget",
|
||||||
"Executed ",
|
"Executed ",
|
||||||
None,
|
None,
|
||||||
QtGui.QApplication.UnicodeUTF8)
|
QtGui.QApplication.UnicodeUTF8)
|
||||||
FreeCAD.Console.PrintMessage("\r\n" + msg + cqCodePane.file.path)
|
FreeCAD.Console.PrintMessage(msg + cqCodePane.file.path + "\r\n")
|
||||||
|
|
||||||
|
|
||||||
class CadQueryNewScript:
|
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 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' \
|
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'):
|
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()
|
CadQuerySaveAsScript().Activated()
|
||||||
|
|
||||||
|
|
|
@ -28,4 +28,4 @@ def save(filename=None):
|
||||||
"Saved ",
|
"Saved ",
|
||||||
None,
|
None,
|
||||||
QtGui.QApplication.UnicodeUTF8)
|
QtGui.QApplication.UnicodeUTF8)
|
||||||
FreeCAD.Console.PrintMessage("\r\n" + msg + cqCodePane.file.path)
|
FreeCAD.Console.PrintMessage(msg + cqCodePane.file.path + "\r\n")
|
||||||
|
|
|
@ -27,6 +27,6 @@ def open(filename):
|
||||||
"Opened ",
|
"Opened ",
|
||||||
None,
|
None,
|
||||||
QtGui.QApplication.UnicodeUTF8)
|
QtGui.QApplication.UnicodeUTF8)
|
||||||
FreeCAD.Console.PrintMessage("\r\n" + msg + filename)
|
FreeCAD.Console.PrintMessage(msg + filename + "\r\n")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -95,7 +95,7 @@ class CadQueryWorkbench (Workbench):
|
||||||
"Please install Python 2.7",
|
"Please install Python 2.7",
|
||||||
None,
|
None,
|
||||||
QtGui.QApplication.UnicodeUTF8)
|
QtGui.QApplication.UnicodeUTF8)
|
||||||
FreeCAD.Console.PrintError("\r\n" + msg)
|
FreeCAD.Console.PrintError(msg + "\r\n")
|
||||||
|
|
||||||
#The extra version numbers won't work on Windows
|
#The extra version numbers won't work on Windows
|
||||||
if sys.platform.startswith('win'):
|
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
|
#Getting the main window will allow us to start setting things up the way we want
|
||||||
mw = FreeCADGui.getMainWindow()
|
mw = FreeCADGui.getMainWindow()
|
||||||
|
|
||||||
# TODO: Fix the extra newline foolishness with the output in the report view
|
|
||||||
|
|
||||||
dockWidgets = mw.findChildren(QtGui.QDockWidget)
|
dockWidgets = mw.findChildren(QtGui.QDockWidget)
|
||||||
|
|
||||||
for widget in dockWidgets:
|
for widget in dockWidgets:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user