chiark / gitweb /
Submit slice information. Slightly update the packaging script to automate the engine...
authordaid <daid303@gmail.com>
Wed, 12 Jun 2013 08:39:03 +0000 (10:39 +0200)
committerdaid <daid303@gmail.com>
Wed, 12 Jun 2013 08:39:03 +0000 (10:39 +0200)
Cura/gui/sceneView.py
Cura/util/sliceEngine.py
Cura/util/version.py
build_app.py [moved from setup.py with 100% similarity]
package.sh

index 151ee77caa8bd5b05ca123c7dd11727f1f7d14e0..edd5805f91724c061d207e814aa994536aefdc30 100644 (file)
@@ -165,6 +165,8 @@ class SceneView(openglGui.glGuiPanel):
                if button == 1:
                        if machineCom.machineIsConnected():
                                printWindow.printFile(self._gcodeFilename)
+                               if self._gcodeFilename == self._slicer.getGCodeFilename():
+                                       self._slicer.submitSliceInfoOnline()
                        elif len(removableStorage.getPossibleSDcardDrives()) > 0:
                                drives = removableStorage.getPossibleSDcardDrives()
                                if len(drives) > 1:
@@ -224,7 +226,8 @@ class SceneView(openglGui.glGuiPanel):
                        else:
                                self.notification.message("Saved as %s" % (fileB))
                self.printButton.setProgressBar(None)
-
+               if fileA == self._slicer.getGCodeFilename():
+                       self._slicer.submitSliceInfoOnline()
 
        def _showSliceLog(self):
                dlg = wx.TextEntryDialog(self, "The slicing engine reported the following", "Engine log...", '\n'.join(self._slicer.getSliceLog()), wx.TE_MULTILINE | wx.OK | wx.CENTRE)
index 56698d784db3b9e30b0626f3b022c518bd88663a..1c816279ebc13925384a643b445432b241638762 100644 (file)
@@ -9,8 +9,12 @@ import threading
 import traceback
 import platform
 import sys
+import urllib
+import urllib2
+import hashlib
 
 from Cura.util import profile
+from Cura.util import version
 
 def getEngineFilename():
        if platform.system() == 'Windows':
@@ -39,6 +43,7 @@ class Slicer(object):
                self._sliceLog = []
                self._printTimeSeconds = None
                self._filamentMM = None
+               self._modelHash = None
 
        def cleanup(self):
                self.abortSlicer()
@@ -112,6 +117,7 @@ class Slicer(object):
                commandList += ['-b', self._binaryStorageFilename]
                self._objCount = 0
                with open(self._binaryStorageFilename, "wb") as f:
+                       hash = hashlib.sha512()
                        order = scene.printOrder()
                        if order is None:
                                pos = numpy.array(profile.getMachineCenterCoords()) * 1000
@@ -131,6 +137,7 @@ class Slicer(object):
                                                        vertexes -= obj._drawOffset
                                                        vertexes += numpy.array([obj.getPosition()[0], obj.getPosition()[1], 0.0])
                                                        f.write(vertexes.tostring())
+                                                       hash.update(mesh.vertexes.tostring())
 
                                commandList += ['#']
                                self._objCount = 1
@@ -139,13 +146,16 @@ class Slicer(object):
                                        obj = scene.objects()[n]
                                        for mesh in obj._meshList:
                                                f.write(numpy.array([mesh.vertexCount], numpy.int32).tostring())
-                                               f.write(mesh.vertexes.tostring())
+                                               s = mesh.vertexes.tostring()
+                                               f.write(s)
+                                               hash.update(s)
                                        pos = obj.getPosition() * 1000
                                        pos += numpy.array(profile.getMachineCenterCoords()) * 1000
                                        commandList += ['-m', ','.join(map(str, obj._matrix.getA().flatten()))]
                                        commandList += ['-s', 'posx=%d' % int(pos[0]), '-s', 'posy=%d' % int(pos[1])]
                                        commandList += ['#' * len(obj._meshList)]
                                        self._objCount += 1
+                       self._modelHash = hash.hexdigest()
                if self._objCount > 0:
                        try:
                                self._process = self._runSliceProcess(commandList)
@@ -282,3 +292,24 @@ class Slicer(object):
                        kwargs['startupinfo'] = su
                        kwargs['creationflags'] = 0x00004000 #BELOW_NORMAL_PRIORITY_CLASS
                return subprocess.Popen(cmdList, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
+
+       def submitSliceInfoOnline(self):
+               if profile.getPreference('submit_slice_information') != 'True':
+                       return
+               if version.isDevVersion():
+                       return
+               data = {
+                       'processor': platform.processor(),
+                       'machine': platform.machine(),
+                       'platform': platform.platform(),
+                       'profile': profile.getGlobalProfileString(),
+                       'preferences': profile.getGlobalPreferencesString(),
+                       'modelhash': self._modelHash,
+                       'version': version.getVersion(),
+               }
+               try:
+                       f = urllib2.urlopen("http://www.youmagine.com/curastats/", data = urllib.urlencode(data), timeout = 1)
+                       f.read()
+                       f.close()
+               except:
+                       pass
index fe3a9cd5d2f3c493c8cf0a33458e3f5e26f372da..2424aa814eded10c43484da95ced998b363000b4 100644 (file)
@@ -62,7 +62,7 @@ def checkForNewerVersion():
                                if version > localVersion:
                                        return "%s/current/%s" % (updateBaseURL, filename)
        except:
-               print sys.exc_info()
+               #print sys.exc_info()
                return None
        return None
 
similarity index 100%
rename from setup.py
rename to build_app.py
index 45ce6b967d5d7572f93e300d942ac094b0b62636..ff42fa3476187e9830e4385df996a295673fbbcd 100755 (executable)
@@ -76,6 +76,7 @@ checkTool curl "curl: http://curl.haxx.se/"
 if [ $BUILD_TARGET = "win32" ]; then
        #Check if we have 7zip, needed to extract and packup a bunch of packages for windows.
        checkTool 7z "7zip: http://www.7-zip.org/"
+       checkTool mingw32-make "mingw: http://www.mingw.org/"
 fi
 #For building under MacOS we need gnutar instead of tar
 if [ -z `which gnutar` ]; then
@@ -95,7 +96,7 @@ if [ "$BUILD_TARGET" = "darwin" ]; then
        rm -rf scripts/darwin/build
        rm -rf scripts/darwin/dist
 
-       python setup.py py2app
+       python build_app.py py2app
        rc=$?
        if [[ $rc != 0 ]]; then
                echo "Cannot build app."
@@ -170,6 +171,8 @@ if [ $BUILD_TARGET = "win32" ]; then
        #Get the power module for python
        rm -rf Power
        git clone https://github.com/GreatFruitOmsk/Power
+       rm -rf CuraEngine
+       git clone https://github.com/Ultimaker/CuraEngine
 fi
 
 #############################
@@ -226,6 +229,9 @@ if [ $BUILD_TARGET = "win32" ]; then
        rm -rf ${TARGET_DIR}/python/Lib/site-packages/wx-2.8-msw-unicode/wx/locale
        #Remove the gle files because they require MSVCR71.dll, which is not included. We also don't need gle, so it's safe to remove it.
        rm -rf ${TARGET_DIR}/python/Lib/OpenGL/DLLS/gle*
+
+    #Build the C++ engine
+       mingw32-make -C CuraEngine
 fi
 
 #add Cura
@@ -237,7 +243,7 @@ echo $BUILD_NAME > ${TARGET_DIR}/Cura/version
 #add script files
 if [ $BUILD_TARGET = "win32" ]; then
     cp -a scripts/${BUILD_TARGET}/*.bat $TARGET_DIR/
-    cp CuraEngine.exe $TARGET_DIR
+    cp CuraEngine/CuraEngine.exe $TARGET_DIR
 else
     cp -a scripts/${BUILD_TARGET}/*.sh $TARGET_DIR/
 fi