Draft: Disabled automatic DXF library download - fixes #1785
Note for existing users: Can be reenabled in menu Edit > Preferences > Import-Export > DXF > Automatic update
This commit is contained in:
parent
dd392efeb1
commit
bd1bbff874
File diff suppressed because one or more lines are too long
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<height>528</height>
|
||||
<width>505</width>
|
||||
<height>543</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -20,6 +20,35 @@
|
|||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Automatic update</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="checkBox_3">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>By checking this, you will allow FreeCAD to download and update the</p><p>components needed for DXF import and export. You can also do that</p><p>manually, by visiting https://github.com/yorikvanhavre/Draft-dxf-importer</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow FreeCAD to automatically download and update the DXF libraries</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>dxfAllowDownload</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Draft</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="GroupBox12">
|
||||
<property name="title">
|
||||
|
|
|
@ -69,27 +69,39 @@ else:
|
|||
FreeCAD.Console.PrintWarning("DXF libraries need to be updated. Downloading...\n")
|
||||
libsok = False
|
||||
if not libsok:
|
||||
files = ['dxfColorMap.py','dxfImportObjects.py','dxfLibrary.py','dxfReader.py']
|
||||
baseurl = 'https://raw.githubusercontent.com/yorikvanhavre/Draft-dxf-importer/'+str(CURRENTDXFLIB)+"/"
|
||||
import ArchCommands
|
||||
from FreeCAD import Base
|
||||
progressbar = Base.ProgressIndicator()
|
||||
progressbar.start("Downloading files...",4)
|
||||
for f in files:
|
||||
progressbar.next()
|
||||
p = None
|
||||
p = ArchCommands.download(baseurl+f,force=True)
|
||||
if not p:
|
||||
FreeCAD.Console.PrintWarning("Download of dxf libraries failed. Please download them manually from\nhttps://github.com/yorikvanhavre/Draft-dxf-importer\nand place them in your macros folder\n")
|
||||
break
|
||||
progressbar.stop()
|
||||
|
||||
sys.path.append(FreeCAD.ConfigGet("UserAppData"))
|
||||
try:
|
||||
import dxfColorMap, dxfLibrary, dxfReader
|
||||
except ImportError:
|
||||
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
|
||||
dxfAllowDownload = p.GetBool("dxfAllowDownload",False)
|
||||
if dxfAllowDownload:
|
||||
files = ['dxfColorMap.py','dxfImportObjects.py','dxfLibrary.py','dxfReader.py']
|
||||
baseurl = 'https://raw.githubusercontent.com/yorikvanhavre/Draft-dxf-importer/'+str(CURRENTDXFLIB)+"/"
|
||||
import ArchCommands
|
||||
from FreeCAD import Base
|
||||
progressbar = Base.ProgressIndicator()
|
||||
progressbar.start("Downloading files...",4)
|
||||
for f in files:
|
||||
progressbar.next()
|
||||
p = None
|
||||
p = ArchCommands.download(baseurl+f,force=True)
|
||||
if not p:
|
||||
FreeCAD.Console.PrintWarning("Download of dxf libraries failed. Please download them manually from\nhttps://github.com/yorikvanhavre/Draft-dxf-importer\nand place them in your macros folder\n")
|
||||
break
|
||||
progressbar.stop()
|
||||
|
||||
sys.path.append(FreeCAD.ConfigGet("UserAppData"))
|
||||
try:
|
||||
import dxfColorMap, dxfLibrary, dxfReader
|
||||
except ImportError:
|
||||
dxfReader = None
|
||||
dxfLibrary = None
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning("The DXF import/export libraries needed by FreeCAD to handle the DXF format\n")
|
||||
FreeCAD.Console.PrintWarning("were not found on this system. Please either enable FreeCAD to download these\n")
|
||||
FreeCAD.Console.PrintWarning("libraries (menu Edit > Preferences > Import-Export > DXF > Enable downloads) or download\n")
|
||||
FreeCAD.Console.PrintWarning("these libraries manually, as explained on\n")
|
||||
FreeCAD.Console.PrintWarning("https://github.com/yorikvanhavre/Draft-dxf-importer\n")
|
||||
dxfReader = None
|
||||
dxfLibrary = None
|
||||
|
||||
|
||||
if open.__module__ == '__builtin__':
|
||||
pythonopen = open # to distinguish python built-in open function from the one declared here
|
||||
|
|
Loading…
Reference in New Issue
Block a user