def unmount_usb(request, device): """Removes /var/www/ddr/media symlink, unmounts requested device, gives feedback. @param request: Django request object; used to access session. @param device: dict containing device info. See DDR.storage.devices. """ logger.debug('unmount(%s, %s)' % (device['devicefile'], device['label'])) unmounted = ddrstorage.umount(device['devicefile']) logger.debug('unmounted: %s' % unmounted) ddrstorage.unlink() _unmount_common(request) if unmounted: msg = STORAGE_MESSAGES['UNMOUNT_SUCCESS'].format(device['label']) messages.success(request, msg) elif unmounted == False: msg = STORAGE_MESSAGES['UNMOUNT_FAIL_1'].format( device['devicefile'], device['label'], stat, mounted) messages.warning(request, msg) else: msg = STORAGE_MESSAGES['UNMOUNT_FAIL'].format( devicefile, label, stat, mounted) messages.error(request, msg) return unmounted
def umount( device_file ): """Command-line function for UNmounting specified device on local system. """ return 0,storage.umount(device_file)