コード例 #1
0
ファイル: __init__.py プロジェクト: trmznt/rhombus
def setup_settings( args ):

    configfile = args.config or os.environ.get(ENVIRON)

    if not configfile:
        cexit('need -c or --config option, or set %s environment' % ENVIRON)

    setup_logging( configfile )
    settings = get_appsettings( configfile )

    set_func_userid(userid_func)
    user = args.user or os.environ.get(USER) or None

    return settings
コード例 #2
0
ファイル: rbmgr.py プロジェクト: trmznt/rhombus
def do_addenumkey(args, dbh, settings):

    cerr('Add enumkey')

    key = args.addenumkey
    key = key.upper() if key.startswith('@') else key.lower()

    key_group = args.ekeygroup
    if key_group is None and not key.startswith('@'):
        cexit('ekey must under a group, or a group key which starts with @')

    ekey = dbh.add_ekey(key, key_group)
    cerr('I - enumkey: %s / %s has been added.' %
        (ekey.key, ekey.group.key if ekey.group else '*'))
コード例 #3
0
ファイル: __init__.py プロジェクト: trmznt/rhombus
def execute(command, run_args):

    print('paths:', PATHS)

    M = None
    for module_path in PATHS:
        try:
            print(module_path)
            M = importlib.import_module(module_path + command)
            break
        except ImportError as exc:
            pass
    if M is None:
        cexit('Cannot locate script name: %s' % command)

    print(M)

    if hasattr(M, 'init_argparser'):
        parser = M.init_argparser()
        assert parser, "FATAL ERROR - init_argparser() does not return an instance"
    else:
        print('Use default arg parser!')
        parser = arg_parser()

    args = parser.parse_args(run_args)

    #configfile = args.config or os.environ.get('RHOMBUS_CONFIG')
    #cinfo('Using config file: %s' % configfile)
    #if not configfile:
    #    print('need -c or --config option, or set RHOMBUS_CONFIG environment')
    #    sys.exit(1)

    #print('Connecting to database...')
    #setup_logging( configfile )
    #settings = get_appsettings( configfile )
    #init_db( settings )

    cerr('Running module: %s' % command)

    M.main( args )
コード例 #4
0
ファイル: rbmgr.py プロジェクト: trmznt/rhombus
def do_setcred(args, dbh, settings):

    if not args.userclass:
        cexit('ERR - please provide userclass')

    if not args.login:
        cexit('ERR - please provide login name')

    domain = dbh.get_userclass(args.userclass)
    user = domain.search_user(args.login)

    if not user:
        cexit('WARN - user does not exist')

    if args.credential:
        user.set_credential(args.credential)
        cerr('Credential for user %s has been modified sucessfully' % user.login)
コード例 #5
0
ファイル: rbmgr.py プロジェクト: trmznt/rhombus
def do_adduser(args, dbh, settings):

    print('do_adduser()')

    if not args.userclass:
        cexit('ERR - please provide userclass')
    domain = dbh.get_userclass( args.userclass )
    if not domain:
        cexit('ERR - userclass: %s does not exist!' % args.userclass)

    if not args.login:
        cexit('ERR - please provide login name')

    if not args.lastname:
        cexit('ERR - please provide last name')

    if not args.firstname:
        cexit('ERR - please provide firstname')

    if not args.email:
        cexit('ERR - please provide email address')

    if not args.primarygroup:
        cexit('ERR - please provide primarygroup')

    if args.groups:
        groups = args.groups.split(',')
    else:
        groups = []

    user = domain.add_user( login = args.login, email = args.email,
                            lastname = args.lastname, firstname = args.firstname,
                            primarygroup = args.primarygroup,
                            groups = groups, session = dbh.session() )

    cout('User %s added sucessfully.' % user.login)