'Ensure iDevice metadata is writable. DC mode only'

def _wait_for_writable_metadata(self, db_added, delay=2.0):

    if self.verbose:
        logger().info(('    %s._wait_for_writable_metadata()' % self.__class__.__name__))
    if (not db_added):
        if self.verbose:
            logger().info(('called    from    %s()    with    null    db_added' % sys._getframe(1).f_code.co_name))
        return
    attempts = 9
    while attempts:
        try:
            if isosx:
                db_added.bpm.set(0)
            elif iswindows:
                db_added.BPM = 0
            break
        except:
            attempts -= 1
            time.sleep(delay)
            if self.verbose:
                logger().info(('        waiting    %.1f    seconds    for    iDevice    metadata    to    become    writable    (attempt    #%d)' % (delay, (10 - attempts))))
    else:
        if self.verbose:
            logger().info('    ERROR:    failed    to    write    device    metadata')
