From: daid Date: Wed, 12 Jun 2013 08:39:03 +0000 (+0200) Subject: Submit slice information. Slightly update the packaging script to automate the engine... X-Git-Tag: 13.06.2~16 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=36c425dcc958ebc5ad0cc8190fe1e0e38bd7e958;p=cura.git Submit slice information. Slightly update the packaging script to automate the engine building. --- diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index 151ee77c..edd5805f 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -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) diff --git a/Cura/util/sliceEngine.py b/Cura/util/sliceEngine.py index 56698d78..1c816279 100644 --- a/Cura/util/sliceEngine.py +++ b/Cura/util/sliceEngine.py @@ -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 diff --git a/Cura/util/version.py b/Cura/util/version.py index fe3a9cd5..2424aa81 100644 --- a/Cura/util/version.py +++ b/Cura/util/version.py @@ -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 diff --git a/setup.py b/build_app.py similarity index 100% rename from setup.py rename to build_app.py diff --git a/package.sh b/package.sh index 45ce6b96..ff42fa34 100755 --- a/package.sh +++ b/package.sh @@ -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