def _handle_error(error: McmdError, exit_on_error: bool, line_number: int):
    if exit_on_error:
        raise ScriptError.from_error(error, line_number)
    else:
        io.error(error.message)
        if error.info:
            io.info(error.info)
def _handle_error(error):
    io.error(error.message)
    if error.info:
        io.info(error.info)

    if isinstance(error, ScriptError):
        io.info('Script failed at line {}'.format(io.highlight(str(error.line))))

    exit(1)
def _handle_error(error: McmdError, line_number: int,
                  state: _ScriptExecutionState):
    if state.options.exit_on_error and not state.options.dry_run:
        raise ScriptError.from_error(error, line_number)
    else:
        sys.stderr.write('Error on line {}: '.format(str(line_number)))
        io.error(error.message)
        if error.info:
            io.info(error.info)
def _make_member_of_group_role(user: User, role: Role):
    group = role.group
    membership = _get_group_membership(user, group)
    if membership:
        if membership.role.name == role.name:
            io.info('User {} is already {} of group {}'.format(
                highlight(user.username), highlight(role.label),
                highlight(group.name)))
        else:
            update = ask.confirm(
                'User {} is {} of group {}. Do you want to update his/her role to {}?'
                .format(user.username, membership.role.label, group.name,
                        role.label))
            if update:
                _update_group_role_membership(user, group, role)
    else:
        _add_group_role_membership(user, group, role)
def _make_member_of_role(role, user):
    if _is_member(user, role):
        io.info('User {} is already a member of role {}'.format(
            highlight(user.username), highlight(role.name)))
    else:
        _add_role_membership(user, role)
def _show_update_message(current: Version, latest: Version):
    io.warn(
        'A new version of MOLGENIS Commander is available: {}! You are using {}.'
        .format(latest, current))
    io.info("To upgrade, run 'pip install --upgrade molgenis-commander'")