From: daid303 Date: Tue, 28 May 2013 11:25:53 +0000 (+0200) Subject: Add option to disable SD auto detect. Log output if SD card remove fails. X-Git-Tag: 13.06.2~34 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=80092caab94d034b929d40af19137a4aa9115d47;p=cura.git Add option to disable SD auto detect. Log output if SD card remove fails. --- diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index 97ec3542..1acdfc86 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -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') diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index b2e31639..124053b7 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -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() diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 51ea91ee..3e238551 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -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') diff --git a/Cura/util/removableStorage.py b/Cura/util/removableStorage.py index e22cfc8d..f537cb43 100644 --- a/Cura/util/removableStorage.py +++ b/Cura/util/removableStorage.py @@ -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