Move the os.remove() call to the finally block and detect failures via a status boolean. This way, warnings won't be raised as exceptions.