def connect(self, name, cert_check=True):
        profile = self.get_profile(name)
        if profile is None:
            raise click.UsageError('The profile "%s" does not exist.' % name)

        kwargs = {}
        stdin = None
        password = self.get_keychain_password(name)
        rsa_token = self.get_rsa_token(name)

        args = ['sudo', 'openconnect']
        if not cert_check:
            args.append('--no-cert-check')

        user = profile.get('user')
        if user is not None:
            args.append('--user=%s' % user)
        group = profile.get('group')
        if group is not None:
            args.append('--authgroup=%s' % group)

        if password is not None:
            args.append('--passwd-on-stdin')
            stdin = password
            kwargs['stdin'] = PIPE
        elif rsa_token is not None:
            args.append('--token-mode=rsa')
            args.append('--token-secret=%s' % rsa_token)

        fingerprint = profile.get('fingerprint')
        if fingerprint is not None:
            args.append('--servercert=%s' % fingerprint)
        args.append(profile['url'])

        c = Popen(args, **kwargs)
        try:
            if stdin is not None:
                c.stdin.write(stdin)
                c.stdin.flush()
                c.stdin.close()
            c.wait()
        except __HOLE__:
            try:
                c.terminate()
            except Exception:
                pass
dataset/ETHPy150Open mitsuhiko/osx-openconnect-helper/openconnect_helper.py/ProfileManager.connect