Skip to content

'User' object has no attribute 'populate_groups' #808

Closed

Description

@pablo-vivanco

I got the error in the subject line when using the tableauserverclient module.

The documentation says to call populate_users() to see the user membership to groups.
reference https://tableau.github.io/server-client-python/docs/api-ref#users

what method should I call to see the user membership to groups?

Thanks,

Pablo

Activity

  1. bcantoni commented on Feb 24, 2021

    @bcantoni
    Contributor

    @pablo-vivanco could you include a code snippet showing what you are trying?

    From the description you mentioned user, but the populate groups method only works on users object (plural), so maybe that's the issue.

    The example shown here could be helpful:
    https://tableau.github.io/server-client-python/docs/api-ref#userspopulate_groups

  2. pablo-vivanco commented on Feb 28, 2021

    @pablo-vivanco
    Author

    Hi bcantoni.

    Yes, I'll be glad to. FYI, I used pip on a windows pc to install TSC, which is version 0.14.1

    here is the snippet

    with server.auth.sign_in(src_tbl_auth):
        do_run = input('\nList Projects?: ') or 'no'
        if do_run[0] == 'y': 
            projects = list(TSC.Pager(server.projects, request_options))
            print(f'\n\nProjects:\n---------\n{"name":30s}\t{"description":60s}\t{"id":40s}\t{"parent_id":40s}\t{"content_permissions"}')
            print(f'{"-"*30}\t{"-"*60}\t{"-"*40}\t{"-"*40}')
            for prj in projects:
                print(f"{prj.name:30s}\t{prj.description and prj.description[:59] or '':60s}\t{prj.id:40s}\t{prj.parent_id or '':40s} ({type(prj.parent_id)})\t{prj.content_permissions}")
                prj_lkp[prj.id] = prj.name
            #print(prj_lkp)
    
        do_run = input('\nList Users?: ') or 'no'
        if do_run[0] == 'y': 
            users = list(TSC.Pager(server.users, request_options))
            print(f'\n\nUsers:\n----------\n{"name":40s}\t{"domain_name":20s}\t{"id":40s}\t{"auth_setting":30s}\t{"email":30s}\t{"fullname":30s}\t{"site_role":30s}\t{"last_login":30s}\t{"groups":10s}\t{"workbooks":10s}')
            print(f'{"-"*40}\t{"-"*20}\t{"-"*40}\t{"-"*30}\t{"-"*30}\t{"-"*30}\t{"-"*30}\t{"-"*30}\t{"-"*30}\t{"-"*30}')
            for usr in users:
                page_n = server.users.populate_groups(usr)
                print(page_n.total_available)
                server.users.populate_workbooks(usr)
                wbks = [workbook.name for workbook in usr.workbooks]
                print(f"{usr.name:40s}\t{usr.domain_name or '':20s}\t{usr.id:40s}\t{usr.auth_setting or '':30s}\t{usr.email or '':30s}\t{usr.fullname or '':30s}\t{usr.site_role or '':30s}\t{usr.last_login or ''}\t{len(page_n.total_available) or 0:10}\t{len(wbks) or 0:10}") 
    
  3. changed the title [-]'User' object has not attribute 'populate_groups[/-] [+]'User' object has no attribute 'populate_groups'[/+] on Mar 4, 2021
  4. bcantoni commented on Mar 4, 2021

    @bcantoni
    Contributor

    @pablo-vivanco thanks for the sample code. I was able to reproduce your problem and realized the issue - the populate_groups() capability was added in release 0.15 (via #799). If you upgrade to that version (pip install --upgrade tableauserverclientI believe your script should work now.

  5. patawan commented on Apr 22, 2021

    @patawan

    @pablo-vivanco thanks for the sample code. I was able to reproduce your problem and realized the issue - the populate_groups() capability was added in release 0.15 (via #799). If you upgrade to that version (pip install --upgrade tableauserverclientI believe your script should work now.

    I was having the same issue and this initially solved it. But now I'm running into a separate issue:
    When running this snippet

    `
    with server.auth.sign_in(tableau_auth):
    all_users, pagination_item = server.users.get()

    print("\nThere are {} user on site: ".format(pagination_item.total_available))
    
    print([user.name for user in all_users])
    
    page_n = server.users.populate_groups(all_users[0])
    
    print("\nUser {0} is a member of {1} groups".format(all_users[0].name, page_n.total_available))
    
    print("\nThe groups are:")
    
    for group in all_users[0].groups :
        print(group.name)`
    

    I receive
    `AttributeError Traceback (most recent call last)
    in
    4 print([user.name for user in all_users])
    5 page_n = server.users.populate_groups(all_users[0])
    ----> 6 print("\nUser {0} is a member of {1} groups".format(all_users[0].name, page_n.total_available))
    7 print("\nThe groups are:")
    8 for group in all_users[0].groups :

    AttributeError: 'NoneType' object has no attribute 'total_available'`

  6. bcantoni commented on Apr 23, 2021

    @bcantoni
    Contributor

    @patawan if you don't mind, since that's a separate issue could you create a new issue with those details? Then I'll close this one out.

  7. patawan commented on Apr 23, 2021

    @patawan

    @bcantoni for sure - just created a new one

  8. bcantoni commented on Apr 23, 2021

    @bcantoni
    Contributor

    Great - we'll continue that conversation over in new issue #837 and will consider this one closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions