示例#1
0
def add_member():
    """Handle 'mrlist add'."""

    mlist = List(client, args.list)
    member = resolve_member(args.member, True)
    mlist.addMember(member)
    print "Added %s to list %s" % (common.emph_text( str(member) ), common.emph_text( mlist.name ))
示例#2
0
def remove_member():
    """Handle 'mrlist remove'."""

    mlist = List(client, args.list)
    member = resolve_member(args.member, True)
    mlist.removeMember(member)
    print "Removed %s from list %s" % (common.emph_text( str(member) ), common.emph_text( mlist.name ))

    if args.reason:
        date = datetime.datetime.now().strftime("%d %b %Y")
        comment_params = (member.name.replace("@", " at "), args.reason, date, common.user_name())
        comment = "<devnull> %s removed due to %s %s (%s)" % comment_params
        commentholder = ListMember(client, ListMember.String, comment)
        mlist.addMember(commentholder)
        print "Added commment entry %s" % common.emph_text(comment)
示例#3
0
文件: mruser.py 项目: vasilvv/mrtools
def show_info():
    """Handle 'mruser info'."""

    user = User(client, args.user)
    user.loadInfo()

    if user.middle_name:
        realname = "%s %s %s" % (user.first_name, user.middle_name, user.last_name)
    else:
        realname = "%s %s" % (user.first_name, user.last_name)

    common.section_header( "Information about user %s" % common.emph_text(user.name) )
    common.show_fields(
        ('Login name', user.name),
        ('Real name', realname),
        ('Status', format_user_status(user)),
        ('User ID', user.uid),
        ('MIT ID', user.mit_id),
        ('Class', user.user_class),
        ('Shell (Unix)', user.shell),
        ('Shell (Windows)', user.windows_shell),
        ('Comments', user.comments) if user.comments else None,
        ('Sponsor', str(user.sponsor) if user.sponsor else 'None'),
        ('Expires', user.expiration) if user.expiration else None,
        ('Alternate email', user.alternate_email) if user.alternate_email else None,
        ('Alternate phone', user.alternate_phone) if user.alternate_phone else None,
        ('Created', "%s by %s" % (common.last_modified_date(user.created_date), user.created_by)),
        ('Last modified', "%s by %s using %s" % (common.last_modified_date(user.lastmod_datetime), user.lastmod_by, user.lastmod_with)),
    )
示例#4
0
文件: mruser.py 项目: vasilvv/mrtools
def format_user_status(user):
    statuses = {
        0  : ('Registerable',                 'blue',    False),
        1  : ('Active',                       'green',   False),
        2  : ('Half-registered',              'blue',    True ),
        3  : ('Deleted',                      'red',     False),
        4  : ('Non-registerable',              None,     False),
        5  : ('Enrolled -- Registerable',     'cyan',    False),
        6  : ('Enrolled -- Unregisterable',    None,     False),
        7  : ('Half-enrolled',                 None,     False),
        8  : ('Registered -- Kerberos-only',  'yellow',  False),
        9  : ('Active -- Kerberos-only',      'yellow',  False),
        10 : ('Supsended',                    'red',     True ),
        11 : ('Expired',                      'red',     True ),
        12 : ('Expired -- Kerberos-only',     'red',     True ),
    }

    if user.status not in statuses:
        return "Unknown status code (%i)" % user.status

    text, color, bold = statuses[user.status]
    if color: text = common.color_text(text, color)
    if bold : text = common.emph_text(text)

    if user.status in {User.Registerable, User.HalfRegistered}:
        if user.secure:
            text += " (needs secure Account Coupun)"
        else:
            text += " (no Account Coupon needed)"

    return text
示例#5
0
def set_owner():
    """Handles 'mrlist setowner'."""

    mlist = List(client, args.list)
    new_owner = resolve_member(args.owner, False)
    if not new_owner:
        raise UserError('Unable to determine owner type')

    mlist.setOwner(new_owner)
    print "Successfully changed owner of list %s to %s" % (common.emph_text(args.list), common.emph_text(str(new_owner)))
示例#6
0
def show_inverse():
    """Handle 'mrlist inverse'."""

    member = resolve_member(args.member, False)
    if not member:
        print "Impossible to determine the type of a member. Please specify it explicitly by prefixing the member with type, seperated by colon, like this: string:[email protected]"
        return

    memberships = list( member.getMemberships(recursive = args.recursive) )
    memberships.sort()
    common.section_header( "Memberships of %s" % common.emph_text( str(member) ) )
    for mlist in memberships:
        print "* %s" % mlist.name
示例#7
0
def set_memacl():
    """Handles 'mrlist setmemacl'."""

    mlist = List(client, args.list)
    if args.memacl.lower() == 'none':
        new_memacl = None
    else:
        new_memacl = resolve_member(args.memacl, False)
        if not new_memacl:
            print 'Unable to determine memacl type'
            return

    mlist.setMembershipACL(new_memacl)
    print "Successfully changed membership ACL of list %s to %s" % (common.emph_text(args.list), common.emph_text(str(new_memacl)))
示例#8
0
def show_info():
    """Handle 'mrlist info'."""

    mlist = List(common.client, args.list)
    mlist.loadInfo()

    common.section_header("Information about list %s" % common.emph_text(mlist.name) )
    common.show_fields(
        ('Description', mlist.description),
        ('Active', mlist.active),
        ('Public', mlist.public),
        ('Visible', not mlist.hidden),
        ('Mailing list', mlist.is_mailing),
        ('AFS group', "GID #%s" % mlist.gid if mlist.is_afsgroup else mlist.is_afsgroup),
        ('Unix group', mlist.is_nfsgroup) if mlist.is_afsgroup else None,
        ('Mailman list', "On server %s" % mlist.mailman_server if mlist.is_mailman_list else mlist.is_mailman_list),
        ('Owner', str(mlist.owner) ),
        ('Membership ACL', str(mlist.memacl) if mlist.memacl else 'None' ),
        ('Last modified', "%s ago by %s using %s" % (common.last_modified_date(mlist.lastmod_datetime), mlist.lastmod_by, mlist.lastmod_with)),
    )