Creating

Revision 3 as of 2012-02-10 07:25:04

Clear message

Go back to the accomplishments main page.

Creating Ubuntu Accomplishments

This page explains how you can contribute different Ubuntu Accomplishments to be used as part of the accomplishments system. Fortunately creating accomplishments is simple. Let's get started.

Getting The Archive

We keep all of the Ubuntu Accomplishments in a branch in Launchpad. Get it with:

bzr branch lp:~jonobacon/ubuntuaccomplishments/ubuntu-accomplishments

Inside the branch you will see a accomplishments and scripts directory. We need to create both an .accomplishment file as well as provide a script.

Creating an Accomplishment

Create an .accomplishment file

First create the .accomplishment file in the accomplishments/ directory. This needs to have a unique name (e.g. made-a-translation.accomplishment). Remember this unique name, we will need to call our script the same name later.

The file contains information about this particular accomplishment. There are a number of set fields you should add under a [accomplishment] block:

  • title - a human readable name for the accomplishment.

  • description - a single line summary of what the accomplishment is.

  • application - this should be set to ubuntu-application as it is part of the Ubuntu Accomplishments package.

  • category - add what category this fits into. See the CATEGORIES file in the branch to see existing categories that have been used (add another one if what you need does not exist).

  • depends - if your accomplishment requires another accomplishments to be completed before yours can be (and is thus locked), specify what other accomplishment is required here.

  • needs-signing - set this to true - this means the accomplishment needs verifying.

  • needs-information - you can specify multiple of these identifying what information you need for the associated script to run.

  • summary - this is a longer HTML infused paragraph summarizing what needs to be done to achieve the accomplishment.

  • steps - add each step in a new line to describe how to achieve this accomplishment.

  • links - add each link on a new line (this can be links to documentation).

  • help - describe each help resource where users can find help on a new line.

AN example:

[accomplishment]
title=Filed First Bug
description=Filed your first bug in Ubuntu
application=ubuntu-community
category=QA
depends=ubuntu-community/registered-on-launchpad
needs-signing=true
needs-information=launchpad-email
summary = A bug is a defect in a piece of software. Filing a bug means that you let the Ubuntu project know about one of these defects. There are a few different ways in which you can file a bug, but we recommend you use a tool called <tt>ubuntu-bug</tt> that comes pre-installed on all Ubuntu systems. You can file a bug in a more graphical way by using the Report a Problem option in the Help menu of an application.
steps: Open up a terminal by clicking the Ubuntu button and typing 'terminal' into the dash.
        Type in <tt>ubuntu-bug</tt> and then the name of the package you want to file a bug against (e.g. 'ubuntu-bug unity' for Unity).
        Follow the instructions in Launchpad.
links: http://www.ubuntu.com
        http://www.jonobacon.org
help = #ubuntu-testing on Freenode

Create a script

With your .accomplishment file ready, you now need to create a script that will do the work of checking to see if you accomplished the thing described.

You will need to write you script in Python today; although we hope to open this up to other languages in the future.

Every script will need some information for to run (e.g. such as the user's Launchpad email address). You can specify these in the needs-information part of the .accomplishment file. As an example, launchpad-email is a standard piece of information we can ask for to get the Launchpad email address.

When a particular piece of information is requested (e.g. launchpad-email) that has no data, the client app will ask for it. You should see the EXTRAINFORMATION file in the branch to see which information is already available and add additional information types where you see fit.

Your your script should use the libaccomplishments Python module and use the getExtraInformation to query this information from the daemon by asking for 'Launchpad Email':

    libaccom = libaccomplishments.Accomplishments()
    f = libaccom.getExtraInformation("ubuntu-community", "Launchpad Email")

This function returns a list

You should now check to see if the data exists, if it doesn't, exit with error code 4:

    if bool(f[0]["Launchpad Email"]) == False:
        sys.exit(4)
    else:
        email = f[0]["Launchpad Email"]

Now write your script to check if the accomplishment was achieved. Based upon the outcome you should exit with one of the following exit codes:

  • 0 - the accomplishment was achieved.

  • 1 - the accomplishment was not achieved.

  • 2 - something went wrong when trying to run the script (e.g. the network is down).

Contributing Your Accomplishment

To contribute your accomplishment add the above files (and be sure to update CATEGORIES and NEEDSINFORMATION if you added new items there) and then run:

bzr add

Now commit your changes:

bzr commit

Finally push your changes to Launchpad:

bzr push lp:your-lp-username/ubuntuaccomplishments/ubuntu-community/your-branch-name

Now go to the branch in Launchpad and propose it for merging into lp:~jonobacon/ubuntuaccomplishments/ubuntu-community.