plot join date launchpad team

Asked by Albert Vilella

I would like to do a XY plot of join dates for different launchpad teams in a Google Spreadsheet. I can fetch tables from webpages in a Google Spreadsheet, but for a launchpad team with a large number of members, the details on join dates are split into different pages. What URL should one be parsing to get the complete list of join dates for the team that can be feed into a Google Spreadsheet?

Question information

Language:
English Edit question
Status:
Answered
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was originally filed as bug #625159.

Revision history for this message
Curtis Hovey (sinzui) said :
#1

You can do this using Launchpad API.

#!/usr/bin/python
from launchpadlib.launchpad import Launchpad

# This script uses the API defined at:
# https://launchpad.net/+apidoc/devel.html

def team_join_dates():
    # Production is https://api.launchpad.net/. Use staging when
    # testing your script.
    lp = Launchpad.login_with(
        'teamjoined', 'https://api.staging.launchpad.net/')
    # Provide your team's launchpad ID. The ID is used in the URL.
    team = lp.people['launchpad-registry']
    for membership in team.members_details:
        joined = membership.date_joined.strftime('%Y-%m-%d')
        user = membership.member
        if user.team_owner is not None:
            # The user is actually a team, all the members joined at the
            # same time.
            for member in user.members:
                print '%s, %s' % (member.displayname, joined)
        else:
            # The user is a user.
            print '%s, %s' % (user.displayname, joined)

if __name__ == '__main__':
    team_join_dates()

Revision history for this message
Albert Vilella (avilella) said :
#2

I tried the script above, and I get this error:

python plot_join_date_launchpad.py
Traceback (most recent call last):
  File "plot_join_date_launchpad.py", line 29, in <module>
    team_join_dates()
  File "plot_join_date_launchpad.py", line 26, in team_join_dates
    print '%s, %s' % (user.displayname, joined)
  File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 673, in __getattr__
    return super(Entry, self).__getattr__(name)
  File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 319, in __getattr__
    % (self.__class__.__name__, attr))
AttributeError: 'Entry' object has no attribute 'displayname'
avilella@magneto:~/data/python_playfulness$ python plot_join_date_launchpad.py
Traceback (most recent call last):
  File "plot_join_date_launchpad.py", line 29, in <module>
    team_join_dates()
  File "plot_join_date_launchpad.py", line 15, in team_join_dates
    team = lp.people['launchpad-registry']
  File "/usr/lib/python2.7/dist-packages/lazr/restfulclient/resource.py", line 935, in __getitem__
    raise KeyError(key)
KeyError: 'launchpad-registry'

Revision history for this message
Max Bowsher (maxb) said :
#3

It should be display_name rather than displayname.

launchpad-registry is not a real team, you are expected to replace this with the id of a team you are interested in.

Can you help with this problem?

Provide an answer of your own, or ask Albert Vilella for more information if necessary.

To post a message you must log in.