chiark / gitweb /
Add option to disable SD auto detect. Log output if SD card remove fails.
authordaid303 <daid303@gmail.com>
Tue, 28 May 2013 11:25:53 +0000 (13:25 +0200)
committerdaid303 <daid303@gmail.com>
Tue, 28 May 2013 11:25:53 +0000 (13:25 +0200)
Cura/gui/preferencesDialog.py
Cura/gui/sceneView.py
Cura/util/profile.py
Cura/util/removableStorage.py

index 97ec354246a069a500305d1b8a7adea83f41012f..1acdfc86c0ed8d9a51482e7809a5940b33cbc211 100644 (file)
@@ -58,9 +58,9 @@ class preferencesDialog(wx.Dialog):
                #configBase.SettingRow(right, 'save_profile')
 
                #configBase.TitleRow(right, 'SD Card settings')
-               #configBase.SettingRow(right, 'sdpath', removableStorage.getPossibleSDcardDrives())
 
                configBase.TitleRow(right, 'Cura settings')
+               configBase.SettingRow(right, 'auto_detect_sd')
                configBase.SettingRow(right, 'check_for_updates')
                configBase.SettingRow(right, 'submit_slice_information')
 
index b2e316395bbcb8ee1eb1c30c397ad91e97d37f86..124053b74945865fdb708acc249ffa8d284b744c 100644 (file)
@@ -395,7 +395,7 @@ class SceneView(openglGui.glGuiPanel):
                self.sceneUpdated()
 
        def sceneUpdated(self):
-               self._sceneUpdateTimer.Start(1, True)
+               self._sceneUpdateTimer.Start(500, True)
                self._slicer.abortSlicer()
                self._scene.setSizeOffsets(numpy.array(profile.calculateObjectSizeOffsets(), numpy.float32))
                self.QueueRefresh()
index 51ea91ee42dbaa1ea4485563275795eef52dd393..3e238551c000567ce71ee64b8d8e571e7d40ab74 100644 (file)
@@ -268,7 +268,7 @@ setting('serial_baud_auto', '', int, 'preference', 'hidden')
 setting('save_profile', 'False', bool, 'preference', 'hidden').setLabel('Save profile on slice', 'When slicing save the profile as [stl_file]_profile.ini next to the model.')
 setting('filament_cost_kg', '0', float, 'preference', 'hidden').setLabel('Cost (price/kg)', 'Cost of your filament per kg, to estimate the cost of the final print.')
 setting('filament_cost_meter', '0', float, 'preference', 'hidden').setLabel('Cost (price/m)', 'Cost of your filament per meter, to estimate the cost of the final print.')
-setting('sdpath', '', str, 'preference', 'hidden').setLabel('SD card drive', 'Location of your SD card, when using the copy to SD feature.')
+setting('auto_detect_sd', 'True', bool, 'preference', 'hidden').setLabel('Auto detect SD card drive', 'Auto detect the SD card. You can disable this because on some systems external hard-drives or USB sticks are detected as SD card.')
 setting('check_for_updates', 'True', bool, 'preference', 'hidden').setLabel('Check for updates', 'Check for newer versions of Cura on startup')
 setting('submit_slice_information', 'False', bool, 'preference', 'hidden').setLabel('Send usage statistics', 'Submit anonymous usage information to improve next versions of Cura')
 
index e22cfc8d4c31388c114f1782c1f57da901f96869..f537cb436dc2b76106776a2b8b9c11b8116bc6a4 100644 (file)
@@ -11,6 +11,8 @@ try:
 except:
        from xml.etree import ElementTree
 
+from Cura.util import profile
+
 _removeableCache = None
 _removeableCacheTime = None
 
@@ -55,6 +57,9 @@ def getPossibleSDcardDrives():
        if _removeableCache is not None and time.time() - _removeableCacheTime < 5.0:
                return _removeableCache
 
+       if profile.getPreference('auto_detect_sd') == 'False':
+               return []
+
        drives = []
        if platform.system() == "Windows":
                from ctypes import windll
@@ -113,12 +118,24 @@ def getPossibleSDcardDrives():
 
 def ejectDrive(driveName):
        if platform.system() == "Windows":
-               cmd = '"%s" %s>NUL' % (os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'EjectMedia.exe')), driveName)
+               cmd = [os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'EjectMedia.exe')), driveName]
        elif platform.system() == "Darwin":
-               cmd = "diskutil eject '%s' > /dev/null 2>&1" % (driveName)
+               cmd = ["diskutil", "eject", driveName]
        else:
-               cmd = "umount '%s' > /dev/null 2>&1" % (driveName)
-       if os.system(cmd):
+               cmd = ["umount", driveName]
+
+       kwargs = {}
+       if subprocess.mswindows:
+               su = subprocess.STARTUPINFO()
+               su.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+               su.wShowWindow = subprocess.SW_HIDE
+               kwargs['startupinfo'] = su
+       p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
+       output = p.communicate()
+
+       if p.wait():
+               print output[0]
+               print output[1]
                return False
        else:
                return True