from __future__ import absolute_import
-import wx, os, platform, types, webbrowser, math, subprocess, multiprocessing, threading, time, re, shutil
+import wx, os, multiprocessing, threading, time, shutil
from Cura.util import profile
from Cura.util import sliceRun
from Cura.util import machineCom
from Cura.util import profile
+from Cura.util import resources
def getDefaultFirmware():
if profile.getPreference('machine_type') == 'ultimaker':
if sys.platform.startswith('linux'):
- return os.path.join(os.path.dirname(os.path.abspath(__file__)), "../firmware/ultimaker_115200.hex")
+ return resources.getPathForFirmware("ultimaker_115200.hex")
else:
- return os.path.join(os.path.dirname(os.path.abspath(__file__)), "../firmware/ultimaker_250000.hex")
+ return resources.getPathForFirmware("ultimaker_250000.hex")
return None
class InstallFirmware(wx.Dialog):
if sys.platform.startswith('darwin'):
if hasattr(sys, 'frozen'):
from Foundation import *
- imagesPath = os.path.join(NSBundle.mainBundle().resourcePath(), 'images')
- meshesPath = os.path.join(NSBundle.mainBundle().resourcePath(), 'images')
+ resourceBasePath = NSBundle.mainBundle().resourcePath()
else:
- imagesPath = os.path.join(os.path.dirname(__file__), "../images")
- meshesPath = os.path.join(os.path.dirname(__file__), "../images")
+ resourceBasePath = os.path.join(os.path.dirname(__file__), "../resources")
else:
if hasattr(sys, 'frozen'):
- imagesPath = os.path.join(os.path.dirname(__file__), "../../images")
- meshesPath = os.path.join(os.path.dirname(__file__), "../../images")
+ resourceBasePath = os.path.join(os.path.dirname(__file__), "../../resources")
else:
- imagesPath = os.path.join(os.path.dirname(__file__), "../images")
- meshesPath = os.path.join(os.path.dirname(__file__), "../images")
+ resourceBasePath = os.path.join(os.path.dirname(__file__), "../resources")
-
-def getPathForResource(dir, resource_name):
+def getPathForResource(dir, subdir, resource_name):
assert os.path.isdir(dir), "{p} is not a directory".format(p=dir)
- path = os.path.normpath(os.path.join(dir, resource_name))
+ path = os.path.normpath(os.path.join(dir, subdir, resource_name))
assert os.path.isfile(path), "{p} is not a file.".format(p=path)
return path
def getPathForImage(name):
- return getPathForResource(imagesPath, name)
+ return getPathForResource(resourceBasePath, 'images', name)
def getPathForMesh(name):
- return getPathForResource(meshesPath, name)
+ return getPathForResource(resourceBasePath, 'meshes', name)
+
+def getPathForFirmware(name):
+ return getPathForResource(resourceBasePath, 'firmware', name)