def temp_raw_device(driver, volume): driver._attach_file(volume) try: yield finally: driver._detach_file(volume)