示例#1
0
def main_trap(argv=sys.argv[1:]):

    auth = pycb.config.auth

    (opts, args) = setup_options(argv)
    if len(args) != 2:
        raise cbToolsException('CMDLINE', ("You must provide a display name and a quota.  See --help"))

    display_name = args[0]
    qstr = args[1]

    if qstr == "UNLIMITED":
        q = User.UNLIMITED
    else:
        try:
            q = pretty_parse(qstr)
        except:
            traceback.print_exc(file=sys.stdout)
            raise cbToolsException('CMDLINE', ("The quota must be an integer > 0 or the string UNLIMITED"))

        if q < 1:
            raise cbToolsException('CMDLINE', ("The quota must be an integer > 0 or the string UNLIMITED"))

    try:
        user_id = auth.get_user_id_by_display(display_name)
        u = auth.get_user(user_id)
    except Exception, ex:
        raise cbToolsException('UNKNOWN_USER', (display_name), ex)
示例#2
0
def main_trap(argv=sys.argv[1:]):

    auth = pycb.config.auth

    (opts, args) = setup_options(argv)
    if len(args) != 2:
        raise cbToolsException(
            'CMDLINE',
            ("You must provide a display name and a quota.  See --help"))

    display_name = args[0]
    qstr = args[1]

    if qstr == "UNLIMITED":
        q = User.UNLIMITED
    else:
        try:
            q = pretty_parse(qstr)
        except:
            traceback.print_exc(file=sys.stdout)
            raise cbToolsException(
                'CMDLINE',
                ("The quota must be an integer > 0 or the string UNLIMITED"))

        if q < 1:
            raise cbToolsException(
                'CMDLINE',
                ("The quota must be an integer > 0 or the string UNLIMITED"))

    try:
        user_id = auth.get_user_id_by_display(display_name)
        u = auth.get_user(user_id)
    except Exception, ex:
        raise cbToolsException('UNKNOWN_USER', (display_name), ex)
示例#3
0
def main_trap(argv=sys.argv[1:]):

    auth = pycb.config.auth

    (opts, args) = setup_options(argv)
    if len(args) == 0:
        raise cbToolsException('CMDLINE', ("You must provide a display name"))

    display_name = args[0]

    try:
        user_id = auth.get_user_id_by_display(display_name)
        u = auth.get_user(user_id)
    except Exception, ex:
        raise cbToolsException('UNKNOWN_USER', (display_name), ex)
示例#4
0
def main_trap(argv=sys.argv[1:]):

    auth = pycb.config.auth

    (opts, args) = setup_options(argv)
    if len(args) == 0:
        raise cbToolsException('CMDLINE', ("You must provide a display name"))

    display_name = args[0]

    try:
        user_id = auth.get_user_id_by_display(display_name)
        u = auth.get_user(user_id)
    except Exception, ex:
        raise cbToolsException('UNKNOWN_USER', (display_name), ex)
示例#5
0
def main_trap(argv=sys.argv[1:]):

    auth = pycb.config.auth

    (opts, args) = setup_options(argv)
    if len(args) == 0:
        raise cbToolsException('CMDLINE', ("You must provide a display name"))

    display_name = args[0]

    if opts.password == None:
        opts.password = add_user_generate_pw(42)
    if not opts.exist:
        # make new user
        if opts.canonical_id == None:
            opts.canonical_id = add_user_generate_pw(21)

        try:
            auth.create_user(display_name, opts.canonical_id, opts.password, opts)
        except Exception, ex:
            raise cbToolsException('USEREXISTS', (display_name), ex)
示例#6
0
def main_trap(argv=sys.argv[1:]):

    auth = pycb.config.auth

    (opts, args) = setup_options(argv)
    if len(args) == 0:
        raise cbToolsException('CMDLINE', ("You must provide a display name"))

    search_name = args[0].replace("*", "%%")

    all_matches = auth.find_user_id_by_display(search_name)

    for id in all_matches:
        u = auth.get_user(id)
        p = printer_obj()
        p.ID = id
        p.canonical_id = u.get_canonical_id()
        p.quota = u.get_quota()
        p.password = u.get_password()
        p.friendly = u.get_display_name()

        pycb.tools.print_report(p, opts.report, opts)

    return 0
示例#7
0
def main_trap(argv=sys.argv[1:]):

    auth = pycb.config.auth

    (opts, args) = setup_options(argv)
    if len(args) == 0:
        raise cbToolsException('CMDLINE', ("You must provide a display name"))

    search_name = args[0].replace("*", "%%")

    all_matches = auth.find_user_id_by_display(search_name)

    for id in all_matches:
        u = auth.get_user(id)
        p = printer_obj() 
        p.ID = id
        p.canonical_id = u.get_canonical_id()
        p.quota = u.get_quota()
        p.password = u.get_password()
        p.friendly = u.get_display_name()

        pycb.tools.print_report(p, opts.report, opts)

    return 0
示例#8
0
                'CMDLINE',
                ("The quota must be an integer > 0 or the string UNLIMITED"))

        if q < 1:
            raise cbToolsException(
                'CMDLINE',
                ("The quota must be an integer > 0 or the string UNLIMITED"))

    try:
        user_id = auth.get_user_id_by_display(display_name)
        u = auth.get_user(user_id)
    except Exception, ex:
        raise cbToolsException('UNKNOWN_USER', (display_name), ex)

    if u == None:
        raise cbToolsException('UNKNOWN_USER', (display_name))

    u.set_quota(q)

    return 0


def main(argv=sys.argv[1:]):
    try:
        rc = main_trap(argv)
    except cbToolsException, tex:
        print tex
        rc = tex.get_rc()
    except SystemExit:
        rc = 0
    except:
示例#9
0
            q = pretty_parse(qstr)
        except:
            traceback.print_exc(file=sys.stdout)
            raise cbToolsException('CMDLINE', ("The quota must be an integer > 0 or the string UNLIMITED"))

        if q < 1:
            raise cbToolsException('CMDLINE', ("The quota must be an integer > 0 or the string UNLIMITED"))

    try:
        user_id = auth.get_user_id_by_display(display_name)
        u = auth.get_user(user_id)
    except Exception, ex:
        raise cbToolsException('UNKNOWN_USER', (display_name), ex)

    if u == None:
        raise cbToolsException('UNKNOWN_USER', (display_name))

    u.set_quota(q)

    return 0

def main(argv=sys.argv[1:]):
    try:
        rc = main_trap(argv)
    except cbToolsException, tex:
        print tex
        rc = tex.get_rc()
    except SystemExit:
        rc = 0
    except:
        traceback.print_exc(file=sys.stdout)
示例#10
0
    if opts.password == None:
        opts.password = add_user_generate_pw(42)
    if not opts.exist:
        # make new user
        if opts.canonical_id == None:
            opts.canonical_id = add_user_generate_pw(21)

        try:
            auth.create_user(display_name, opts.canonical_id, opts.password, opts)
        except Exception, ex:
            raise cbToolsException('USEREXISTS', (display_name), ex)

    try:
        user_id = auth.get_user_id_by_display(display_name)
    except Exception, ex:
        raise cbToolsException('UNKNOWN_USER', (display_name), ex)

    try:
        u = auth.get_user(user_id)
    except:
        raise cbToolsException('UNKNOWN_USER', (user_id), ex)

    opts.ID = user_id
    opts.canonical_id = u.get_canonical_id()
    opts.quota = u.get_quota()
    opts.id = u.set_user_pw(opts.password)

    pycb.tools.print_report(opts, opts.report, opts)

    return 0