コード例 #1
0
ファイル: __main__.py プロジェクト: tilmanpotthof/upmctl
def run(args):
    client = Client(base_url=args.base_url,
                    base_auth=args.base_authentication)
    pp = pprint.PrettyPrinter()

    if hasattr(args, 'list'):
        if args.user:
            plugins = list_plugins(client, key='userInstalled',
                                   value='boolean', pattern='true')
        elif args.system:
            plugins = list_plugins(client, key='userINstalled',
                                   value='boolean', pattern='false')
        elif args.key:
            plugins = list_plugins(client, key='key', value='regex',
                                   pattern=args.key)
        elif args.key_configuration_file:
            config = read_config(args.key_configuration_file)
            key = get_key_config(config)
            plugins = list_plugins(client, key='key', value='regex',
                                   pattern=key)
        else:
            plugins = list_plugins(client)
        pp.pprint(plugins)
    elif hasattr(args, 'show'):
        plugin = show_plugin(client, args.key)
        pp.pprint(plugin)
コード例 #2
0
ファイル: __main__.py プロジェクト: tschaefer/upmctl
def run(args):
    client = Client(base_url=args.base_url,
                    base_auth=args.base_authentication)

    try:

        if hasattr(args, 'list'):
            if args.user:
                plugins = list_plugins(client, key='userInstalled',
                                       value='boolean', pattern='true')
            elif args.system:
                plugins = list_plugins(client, key='userInstalled',
                                       value='boolean', pattern='false')
            elif args.key:
                plugins = list_plugins(client, key='key', value='regex',
                                       pattern=args.key)
            elif args.key_configuration_file:
                config = read_config(args.key_configuration_file)
                key = get_key_config(config)
                plugins = list_plugins(client, key='key', value='regex',
                                       pattern=key)
            else:
                plugins = list_plugins(client)
            if plugins is not None:
                print plugins
        elif hasattr(args, 'show'):
            plugin = show_plugin(client, args.key)
            print plugin
        elif hasattr(args, 'install'):
            token = get_upm_token(client)
            client.request.url = args.base_url
            install_plugin(client, token, args.plugin)
        elif hasattr(args, 'delete'):
            delete_plugin(client, args.key)
        elif hasattr(args, 'activate'):
            activate_plugin(client, args.key)
        elif hasattr(args, 'deactivate'):
            deactivate_plugin(client, args.key)

    except ClientError as e:
        print >> sys.stderr, "%s: %s" % ('upmctl', e)
        sys.exit(1)

    sys.exit(0)