#Only import the _core to save import time
import wx._core
-from Cura.util import profile
-from Cura.util import resources
-
class CuraApp(wx.App):
def __init__(self):
if platform.system() == "Windows" and not 'PYCHARM_HOSTED' in os.environ:
def afterSplashCallback(self):
#These imports take most of the time and thus should be done after showing the splashscreen
+ import webbrowser
from Cura.gui import mainWindow
from Cura.gui import configWizard
+ from Cura.util import profile
+ from Cura.util import resources
+ from Cura.util import version
#If we haven't run it before, run the configuration wizard.
if profile.getPreference('machine_type') == 'unknown':
#Hide the splashscreen before showing the main window.
if self.splash is not None:
self.splash.Show(False)
+ if profile.getPreference('check_for_updates') == 'True':
+ newVersion = version.checkForNewerVersion()
+ if newVersion is not None:
+ if wx.MessageBox('A new version of Cura is available, would you like to download?', 'New version available', wx.YES_NO | wx.ICON_INFORMATION) == wx.YES:
+ webbrowser.open(newVersion)
+ return
self.mainWindow = mainWindow.mainWindow()
setFullScreenCapable(self.mainWindow)
c = configBase.SettingRow(right, 'SD card path', 'sdpath', '', 'Location of your SD card, when using the copy to SD feature.', type = 'preference')
c = configBase.SettingRow(right, 'Copy to SD with 8.3 names', 'sdshortnames', False, 'Save the gcode files in short filenames, so they are properly shown on the UltiController', type = 'preference')
+ configBase.TitleRow(right, 'Cura settings')
+ c = configBase.SettingRow(right, 'Check for updates', 'check_for_updates', True, 'Check for newer versions of Cura on startup', type = 'preference')
+
self.okButton = wx.Button(right, -1, 'Ok')
right.GetSizer().Add(self.okButton, (right.GetSizer().GetRows(), 0), flag=wx.BOTTOM, border=5)
self.okButton.Bind(wx.EVT_BUTTON, self.OnClose)
'filament_cost_kg': '0',
'filament_cost_meter': '0',
'sdpath': '',
- 'sdshortnames': 'True',
+ 'sdshortnames': 'False',
+ 'check_for_updates': 'True',
'planner_always_autoplace': 'True',
'extruder_head_size_min_x': '75.0',
--- /dev/null
+
+class setting(object):
+ def __init__(self, key, name, description):
+ self._key = key
+ self._name = name
+ self._description = description
import os
import sys
+import urllib2
+import platform
+from xml.etree import ElementTree
+
from Cura.util import resources
def getVersion(getGitVersion = True):
gitPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../../.git"))
return os.path.exists(gitPath)
+def checkForNewerVersion():
+ if isDevVersion():
+ return None
+ try:
+ updateBaseURL = 'http://software.ultimaker.com'
+ localVersion = map(int, getVersion(False).split('.'))
+ while len(localVersion) < 3:
+ localVersion += [1]
+ latestFile = urllib2.urlopen("%s/latest.xml" % (updateBaseURL))
+ latestXml = latestFile.read()
+ latestFile.close()
+ xmlTree = ElementTree.fromstring(latestXml)
+ for release in xmlTree.iter('release'):
+ os = str(release.attrib['os'])
+ version = [int(release.attrib['major']), int(release.attrib['minor']), int(release.attrib['revision'])]
+ filename = release.find("filename").text
+ if platform.system() == os:
+ if version > localVersion:
+ return "%s/current/%s" % (updateBaseURL, filename)
+ except:
+ print sys.exc_info()
+ return None
+ return None
+
if __name__ == '__main__':
print(getVersion())
-