Giter Site home page Giter Site logo

Comments (4)

jay6413682 avatar jay6413682 commented on September 17, 2024

As I check, there is no "UserProfile" attribute in "user" object fetched from RallyRESTResponse on our Rally instance. As a workaround, I put "if getattr(user,"UserProfile",None):" before code below as a condition:

    # do our own brute force "join" operation on User to UserProfile info 
    for user in users:
        # get any matching user profiles (aka mups), there really should only be 1 matching...
        mups = [prof for prof in profiles 
                      if prof._ref == user.UserProfile._ref] 
        if not mups:
            problem = "unable to find a matching UserProfile record for User: %s  UserProfile: %s"
            warning("%s" % (problem % (user.DisplayName, user.UserProfile)))
            continue
        else:
            if len(mups) > 1:
                anomaly = "Found %d UserProfile items associated with username: %s"
                warning("%s" % (anomaly % (len(mups), user.UserName)))
            # now attach the first matching UserProfile to the User
            user.UserProfile = mups[0]  

The code should consider condition that an attribute of an object may not exist

from rallyresttoolkitforpython.

michaelusner avatar michaelusner commented on September 17, 2024

I've also encountered this issue.
My fix was to add the following to line 570:

    mups = [prof for prof in profiles
        if hasattr(user, 'UserProfile') and prof._ref == user.UserProfile._ref]

from rallyresttoolkitforpython.

klehman-rally avatar klehman-rally commented on September 17, 2024

Incorporated user contributed code in 1.1.1

from rallyresttoolkitforpython.

 avatar commented on September 17, 2024

I'm still getting this in 1.1.1 when doing rally.getAllUsers() and user isn't found

Traceback (most recent call last):
  File "C:\Users\ross\python\integration_rally-trello\rallyPython.py", line 67, in <module>
    all_users = rally.getAllUsers()
  File "C:\Python27\lib\site-packages\pyral\restapi.py", line 575, in getAllUsers
    warning("%s" % (problem % (user.DisplayName, user.UserProfile)))
  File "C:\Python27\lib\site-packages\pyral\entity.py", line 172, in __getattr__
    raise AttributeError(description)
AttributeError: User instance has no attribute: 'UserProfile'

Solution is to guard the UserProfile here as well. I've guarded both properties.

if hasattr(user, 'UserProfile') and hasattr(user, 'DisplayName'):
   warning("%s" % (problem % (user.DisplayName, user.UserProfile)))

from rallyresttoolkitforpython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.