From 9e5fe599043a59c185ed95b51e00309a708baf5c Mon Sep 17 00:00:00 2001 From: daid303 Date: Tue, 6 Nov 2012 11:06:09 +0100 Subject: [PATCH] Add safely remove SD feature. --- Cura/gui/preview3d.py | 2 ++ Cura/gui/sliceProgessPanel.py | 11 +++++++++-- package.sh | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index 4882df71..6ebae45d 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -322,6 +322,8 @@ class previewPanel(wx.Panel): else: self.warningPopup.yesButton.Show(True) self.warningPopup.noButton.SetLabel('no') + self.warningPopup.Fit() + self.warningPopup.Layout() self.OnMove() self.warningPopup.Show(True) self.warningPopup.timer.Start(5000) diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py index 5b35fbfc..eaaed967 100644 --- a/Cura/gui/sliceProgessPanel.py +++ b/Cura/gui/sliceProgessPanel.py @@ -90,10 +90,17 @@ class sliceProgessPanel(wx.Panel): except: self.GetParent().preview3d.ShowWarningPopup("Failed to copy file to SD card.") return - self.GetParent().preview3d.ShowWarningPopup("Copy finished, safely remove SD card?", OnSafeRemove) + self.GetParent().preview3d.ShowWarningPopup("Copy finished, safely remove SD card?", self.OnSafeRemove) def OnSafeRemove(self): - print "Remove!" + if platform.system() == "Windows": + cmd = "%s %s>NUL" % (os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'EjectMedia.exe')), profile.getPreference('sdpath')) + else: + cmd = "umount %s > /dev/null 2>&1" % (profile.getPreference('sdpath')) + if os.system(cmd): + self.GetParent().preview3d.ShowWarningPopup("Safe remove failed.") + else: + self.GetParent().preview3d.ShowWarningPopup("You can now eject the card.") def OnSliceDone(self, result): self.progressGauge.Destroy() diff --git a/package.sh b/package.sh index 6a90ee5e..86dc04b8 100755 --- a/package.sh +++ b/package.sh @@ -97,6 +97,7 @@ if [ $BUILD_TARGET = "win32" ]; then downloadURL http://videocapture.sourceforge.net/VideoCapture-0.9-5.zip downloadURL http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20120927-git-13f0cd6-win32-static.7z downloadURL http://sourceforge.net/projects/comtypes/files/comtypes/0.6.2/comtypes-0.6.2.win32.exe + downloadURL http://www.uwe-sieber.de/files/ejectmedia.zip #Get pypy downloadURL https://bitbucket.org/pypy/pypy/downloads/pypy-${PYPY_VERSION}-win32.zip elif [ $BUILD_TARGET = "osx64" ]; then @@ -129,6 +130,7 @@ if [ $BUILD_TARGET = "win32" ]; then extract ffmpeg-20120927-git-13f0cd6-win32-static.7z ffmpeg-20120927-git-13f0cd6-win32-static/bin/ffmpeg.exe extract ffmpeg-20120927-git-13f0cd6-win32-static.7z ffmpeg-20120927-git-13f0cd6-win32-static/licenses extract comtypes-0.6.2.win32.exe + extract ejectmedia.zip Win32 mkdir -p ${TARGET_DIR}/python mkdir -p ${TARGET_DIR}/Cura/ @@ -141,6 +143,7 @@ if [ $BUILD_TARGET = "win32" ]; then mv VideoCapture-0.9-5/Python27/DLLs/vidcap.pyd ${TARGET_DIR}/python/DLLs mv ffmpeg-20120927-git-13f0cd6-win32-static/bin/ffmpeg.exe ${TARGET_DIR}/Cura/ mv ffmpeg-20120927-git-13f0cd6-win32-static/licenses ${TARGET_DIR}/Cura/ffmpeg-licenses/ + mv Win32/EjectMedia.exe ${TARGET_DIR}/Cura/ rm -rf \$_OUTDIR rm -rf PURELIB rm -rf PLATLIB -- 2.30.2