

def create_user_interactive(email=None, password='', is_public=False, is_active=True, is_admin=True):
    '\n    This function will interactively prompt for the required information. In\n    case of error, instead of throwing exceptions will print human readable\n    messages to stderr and exit with code 1.\n    '
    if (not email):
        email = raw_input('E-mail: ').strip()
        if (not email):
            log.error('Error: E-mail cannot be empty.')
            sys.exit(1)
    if (get_user(email) is not None):
        log.error('Error: User exists.')
        sys.exit(1)
    if (not password):
        password = getpass.getpass()
        if (not password):
            is_active = False
        pw_again = getpass.getpass('Again: ')
        if (password != pw_again):
            log.error('Error: Password do not match.')
            sys.exit(1)
    if (password == ''):
        is_active = False
        log.info('Password is empty. User will not be active until a password is set.')
    else:
        is_active = confirm('Is active?')
    is_public = confirm('Is public?')
    if (is_admin is None):
        is_admin = confirm('Is admin?')
    preview = {
        'email': email,
        'password': ('(Empty)' if (password == '') else '(Not shown)'),
        'active': ('Yes' if is_active else 'No'),
        'public': ('Yes' if is_public else 'No'),
        'admin': ('Yes' if is_admin else 'No'),
    }
    log.info(('\nE-mail: %(email)s\nPassword: %(password)s\nActive: %(active)s\nPublic: %(public)s\nAdmin: %(admin)s\n' % preview))
    if (not confirm('Are values correct?')):
        log.error('Aborting.')
        sys.exit(1)
    user = mk_user(email, password, is_public, is_active, is_admin)
    log.info(("User '%s' created successfuly." % user.pk))
    return user

dataset/ETHPy150Open tooxie/shiva-server/shiva/admin.py create_user_interactive/original