From: daid303 Date: Wed, 1 May 2013 11:32:47 +0000 (+0200) Subject: Add utility function to eject drives. X-Git-Tag: 13.05~40 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ee86565e9c805442b35b91050c73bc05bb2cc513;p=cura.git Add utility function to eject drives. --- diff --git a/Cura/gui/util/opengl.py b/Cura/gui/util/opengl.py index 87845124..e5a4a435 100644 --- a/Cura/gui/util/opengl.py +++ b/Cura/gui/util/opengl.py @@ -116,6 +116,9 @@ class GLVBO(GLReferenceCounter): def release(self): if self._buffer is not None: + glBindBuffer(GL_ARRAY_BUFFER, self._buffer) + glBufferData(GL_ARRAY_BUFFER, None, GL_STATIC_DRAW) + glBindBuffer(GL_ARRAY_BUFFER, 0) glDeleteBuffers(1, [self._buffer]) self._buffer = None diff --git a/Cura/util/removableStorage.py b/Cura/util/removableStorage.py index 27d5c705..5039503b 100644 --- a/Cura/util/removableStorage.py +++ b/Cura/util/removableStorage.py @@ -95,5 +95,17 @@ def getPossibleSDcardDrives(): _removeableCacheTime = time.time() return drives +def ejectDrive(driveName): + if platform.system() == "Windows": + cmd = '"%s" %s>NUL' % (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) + else: + cmd = "umount '%s' > /dev/null 2>&1" % (driveName) + if os.system(cmd): + return False + else: + return True + if __name__ == '__main__': print getPossibleSDcardDrives()