Ubuntu Accomplishments Daemon Reference

class accomplishments.daemon.api.Accomplishments(service, show_notifications=None)[source]

The main accomplishments daemon.

No D-Bus required, so that it can be used for testing.

create_extra_information_file(item, data)[source]

Does exactly the same as write_extra_information_file(), but it does not overwrite any existing data

get_acc_categories(accomID)[source]

Returns a list of categories for a given accomplishment. This can include sub-categories (which are formatted like ‘category:subcategory’ (e.g. AskUbuntu:Asking)).

Args:
  • accomID - (str) The Accomplishment ID (e.g. ‘ubuntu-community/registered-on-launchpad’)
Returns:
  • list(str) The list of categories.
Example:
>>> obj.get_acc_categories("ubuntu-community/registered-on-launchpad")
["Launchpad"]
>>> obj.get_acc_categories("some_other_collection/another-accomplishment")
["Category One", "Category Two:Subcategory"]
get_acc_collection(accomID)[source]

Returns the name of the collection this accomplishment orginates from.

Args:
  • accomID - (str) The Accomplishment ID (e.g. ‘ubuntu-community/registered-on-launchpad’)
Returns:
  • str - Collection name.
Example:
>>> acc.get_acc_collection("ubuntu-community/signed-code-of-conduct")
ubuntu-community
get_acc_date_completed(accomID)

Returns the date that the accomplishment specified by ‘accomID’ was completed.

Args:
accomID (str): The Accomplishment ID (e.g. ‘ubuntu-community/registered-on-launchpad’)
Returns:
(string) The completed date
Example:
>>> obj.get_acc_date_completed("ubuntu-community/registered-on-launchpad")
"2012-06-15 12:32"
get_all_extra_information()[source]

This function is used to retrieve all extra-information data, along with its name, description - as provided by the accomplishment collection - and it’s current value.

Returns:
  • array(dict(str:str)) - A list of all extra-information items used by currently installed accomplishments collections. Note that a single item can be present several times, if more than one collection uses the same extra-information data (see example).

  • The list of fields in returned dictionaries:
    • collection - the name of colletion that uses this extra-information (e.g. ubuntu-community)
    • needs-information - the name of extra-information data bit (e.g. launchpad-email)
    • label - the user-readable name of this extra-information field. It is provided by the collection so may vary. It should be translated according to user’s locale.
    • description - an user-readable, one line long description for this extra-information item. It is also provided by the collection, and a translated string is provided, if available.
    • example - a example value for this extra-information, provided by the collection (e.g. launchpad-email might have an example: foo@bar.com). If no example is provided, it will be an empty string.
    • regex - a regular expression used to check whether the value of this extra-information field uses a correct format. If collection provides no regexp, it will be an empty string.
    • value - the current value of this field, as set by the user. It will be the same for all collections that use this extra-information item.
Example:
>>> acc.get_all_extra_information()
[{"collection" : "ubuntu-community", "needs-information" : "launchpad-email", "label" : "Launchpad e-mail", "description" : "The e-mail address you use to log in to Launchpad", "example" : "foo@bar.com", "regex" : "", "value" : "someuser@somehost.org"},
 {"collection" : "ubuntu-italiano", "needs-information" : "launchpad-email", "label" : "Launchpad e-mail", "description" : "Type in your LP e-mail, amigo!", "example" : "some@email.com", "regex" : "", "value" : "someuser@somehost.org"},
 {"collection" : "ubuntu-community", "needs-information" : "askubuntu-user-url", "label" : "AskUbuntu user profile URL", "description" : "The URL of your AskUbuntu usr profile page", "example" : "http://askubuntu.com/users/42/nick", "regex" : "", "value" : ""}]
get_all_extra_information_required()[source]

This function does pretty much the same as get_all_extra_information() , but it filters out entries that have no value set. This way it can be easily used to get a list of all extra-information that user still has to provide.

Returns:
  • array(dict(str:str)) - A list of all extra-information items used by currently installed accomplishments collections that are not yet set. Details are the same as in get_all_extra_information()
Example:
>>> acc.get_all_extra_information_required()
[{"collection" : "ubuntu-community", "needs-information" : "askubuntu-user-url", "label" : "AskUbuntu user profile URL", "description" : "The URL of your AskUbuntu usr profile page", "example" : "http://askubuntu.com/users/42/nick", "regex" : "", "value" : ""}]
get_collection_authors(collection)[source]

Returns a list of accomplishment contributors that have written accomplishments for given collection.

Args:
  • collection - (str) Sellected collection name (e.g. “ubuntu-community”)
Returns:
  • set(str) - A list of accomplishment contributors names along with their e-mails (debian maintainter format).
Example:
>>> acc.get_collection_authors("ubuntu-community")
set(['Surgemcgee <RobertSteckroth@gmail.com>', 'Silver Fox <silver-fox@ubuntu.com>', 'Hernando Torque <sirius@sonnenkinder.org>', 'Nathan Osman <admin@quickmediasolutions.com>', 'Rafał Cieślak <rafalcieslak256@ubuntu.com>', 'Michael Hall <mhall119@ubuntu.com>', 'Angelo Compagnucci <angelo.compagnucci@gmail.com>', 'Matt Fischer <matthew.fischer@canonical.com>', 'Bruno Girin <brunogirin@gmail.com>', 'Jorge O. Castro <jorge@ubuntu.com>', 'Andrea Grandi <a.grandi@gmail.com>', 'Marco Ceppi <marco@ceppi.net>', 'Agmenor <agmenor@laposte.net>', 'Christopher Kyle Horton <christhehorton@gmail.com>', 'José Antonio Rey <joseeantonior@ubuntu-pe.org>', 's.fox <silver-fox@ubuntu.com>', 'Jono Bacon <jono@ubuntu.com>'])
get_collection_categories(collection)[source]

Lists all categories within a given collection, as well as their subcategories.

Args:
  • collection - (str) Sellected collection name (e.g. “ubuntu-community”)
Returns:
  • dict(str:list(str)) - A dictionary that translates all categories into a list of their subcategories.
Example:
>>> acc.get_collection_categories("ubuntu-community")
{'Development': ['Ubuntu Accomplishments', 'Packaging'],
 'QA': [],
 'Launchpad': ['Your Profile', 'Code Hosting'],
 'LoCo Teams': ['Events'],
 'Documentation': [],
 'Governance': [],
 'General': [],
 'Juju': [],
 'Ask Ubuntu': ['Membership', 'Starter Badges', 'Asking & Answering', 'Unrecognized Contributions', 'Publicity', 'Popularity', 'Starter badges', 'Chat', 'Flagging & Cleanup', 'Visiting', 'Comment', 'Tagging', 'Meta Participation', 'Voting', 'Starter', 'Editing badges'],
 'IRC': [],
 'Forums': [],
 'Events': []  }
get_collection_data(collection)[source]

This function returns all data stored in accDB for a given collection. It may be only useful if you need to access any data that don’t have their own get_collection_* function.

Args:
  • collection - (str) Sellected collection name (e.g. “ubuntu-community”)
Returns:
  • dict(str:variable) - A dictionary of all data related to this collection. List of its fields:
    • langdefault - (str) the default language of this collection, as specified in it’s ABOUT file
    • acc_num - (int) the number of accomplishments in this collection
    • base_path - (str) the path where this collection is installed
    • type - (str) always equal to “collection”
    • name - (str) human-readable name, use get_collection_name instead
    • authors - set(str) list of authors, use get_collection_authors instead
    • extra-information - dict(str:dict(str:str)) list of all extra-information used with it’s medatada, use get_extra_information or get_all_extra_information instead
    • categories - dict(str:list(str)) list of all categories and subcategories, use get_collection_categories instead
get_collection_exists(collection)[source]

Checks if a collection is a valid name and is installed in the system.

Args:
  • collection - (str) Sellected collection name (e.g. “ubuntu-community”)
Returns:
  • bool - Whether such collection exists or not.
Example:
>>> acc.get_collection_exists("ubuntu-desktop")
True
>>> acc.get_collection_exists("a totally wrong name")
False
get_collection_name(collection)[source]

Returns a human-readable collection name, as it provides in it’s ABOUT file.

Args:
  • collection - (str) Sellected collection name (e.g. “ubuntu-community”)
Returns:
  • str - Human-readable name (e.g. “Ubuntu Comunity”)
Example:
>>> acc.get_collection_name("ubuntu-desktop")
Ubuntu Desktop
get_config_value(section, item)[source]

Return a configuration value from the .accomplishments file

get_extra_information(coll, item)[source]

Note

This function is particularly sensitive - accomplishment scripts use it to fetch credentials they need.

This function returns extra-information’s value, as set by user. It also provides it with translated label of this extra-information.

Args:
  • coll - (str) the name of collection that needs this item. Depending on this, different label may be returned, if collections provide different extrainformation details.
  • item - (str) the name of requested item.
Returns:
  • dict(str:str) - output is wrapped in a dictionary:
    • item - the value of this item. (e.g. "askubuntu-user-url" : "askubuntu.com/users/12345/nickname").
    • label - a translated label, as provided by chosen collection.
Example:
>>> acc.get_extra_information("ubuntu-community","launchpad-email")
{"launchpad-email" : "user@host.org", "label" : "Adres e-mail uzywany do logowania w portalu Launchpad"}
>>> acc.get_extra_information("ubuntu-italiano","launchpad-email")
{"launchpad-email" : "user@host.org", "label" : "E-mail address used to log into Launchpad"}
In above example user has an outdated ubuntu-italiano collection, and it doesn’t yet have a Polish label - therefore it differs from previous call.
>>> acc.get_extra_information("ubuntu-community","askubuntu-user-url")
{"askubuntu-user-url" : "http://askubuntu.com/users/12345/nickname", "label" : "URL of your AskUbuntu profile page"}
get_published_status()

Detect if we are currently publishing online or not. Returns True if we are or False if we are not.

get_trophy_data(accomID)[source]

This function can be used to retrieve all data from a .trophy file. It returns all it’s contents as a dict (provided this .trophy exists).

Args:
  • accomID - (str) The accomplishmendID.
Returns:
  • None - in case this accomplishment hasn’t been completed.
  • dict(str:str) - in case this accomplishment has been awarded. It represents all keys and it’s values in a .trophy file.
Example:
>>> acc.get_trophy_data("ubuntu-community/registered-on-launchpad")
{'needs-signing': 'true', 'date-accomplished': '1990-04-12 02:22', 'needs-information': 'launchpad-email', 'version': '0.2', '__name__': 'trophy', 'launchpad-email': 'launchpaduser@ubuntu.com', 'id': 'ubuntu-community/registered-on-launchpad'}
get_trophy_path(accomID)[source]

This function returns a path to the .trophy file related to given accomplishmentID. The trophy file may or may not exist.

Args:
  • accomID - (str) The accomplishmentID.
Returns:
  • (str) - A path to .trophy file of this accomplishment.
Example:
>>> acc.get_trophy_path("ubuntu-community/registered-on-launchpad")
/home/cielak/.local/share/accomplishments/trophies/ubuntu-community/registered-on-launchpad.trophy
invalidate_extra_information(extrainfo)[source]

Warning

This function is deprecated.

This function was used to remove all trophies that were accomplished using given extra-information. For example, if I used launchpad-email userA@mail.com and then switched to userB@mail.com, it was useful to call this function to remove all trophies that were awarded to userA@mail.com. However, since 0.2 throphies may not be deleted automatically under no circumstances, this function does nothing now.

Args:
  • extrainfo - (str) the extra-information field that is no more valid (e.g. launchpad-email)
reload_accom_database()[source]

This is the function that builds up the accDB accomplishments database. It scans all accomplishment installation directories (as set in the config file), looks for all installed collections, and caches all accomplishments’ data in memory. If a translated .accomplishment file is available, it’s contents are loaded instead.

It also groups collection categories, authors, finds accomplishment script paths, and counts accomplishments in collections.

All results are stored in an internal variable, self.accDB. They can be accessed afterwards using get_acc_* functions.

Running this function also calls _update_all_locked_and_completed_statuses(), which completes initialising the accDB, as it fills in it’s “completed” and “locked” fields.

Note

There is no need for clients to run this method manually when the daemon is started - this function is called by this class’ __init__.

Args:
None.
Returns:
  • Nothing.
write_config_file_item(section, item, value)[source]

Set a configuration value in the .accomplishments file

class accomplishments.daemon.api.AsyncAPI(parent)[source]

This class simply organizes all the Twisted calls into a single location for better readability and separation of concerns.

register_trophy_dir(*args, **kwargs)[source]

Creates the Ubuntu One share for the trophydir and offers it to the server. Returns True if the folder was successfully shared, False if not.

Previous topic

Ubuntu Accomplishments Client API Reference

This Page