The main accomplishments daemon.
No D-Bus required, so that it can be used for testing.
Does exactly the same as write_extra_information_file(), but it does not overwrite any existing data
Returns a list of categories for a given accomplishment. This can include sub-categories (which are formatted like ‘category:subcategory’ (e.g. AskUbuntu:Asking)).
>>> obj.get_acc_categories("ubuntu-community/registered-on-launchpad")
["Launchpad"]
>>> obj.get_acc_categories("some_other_collection/another-accomplishment")
["Category One", "Category Two:Subcategory"]
Returns the name of the collection this accomplishment orginates from.
>>> acc.get_acc_collection("ubuntu-community/signed-code-of-conduct")
ubuntu-community
Returns the date that the accomplishment specified by ‘accomID’ was completed.
>>> obj.get_acc_date_completed("ubuntu-community/registered-on-launchpad")
"2012-06-15 12:32"
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.
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).
>>> 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" : ""}]
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.
>>> 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" : ""}]
Returns a list of accomplishment contributors that have written accomplishments for given collection.
>>> 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>'])
Lists all categories within a given collection, as well as their subcategories.
>>> 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': [] }
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.
Checks if a collection is a valid name and is installed in the system.
>>> acc.get_collection_exists("ubuntu-desktop")
True
>>> acc.get_collection_exists("a totally wrong name")
False
Returns a human-readable collection name, as it provides in it’s ABOUT file.
>>> acc.get_collection_name("ubuntu-desktop")
Ubuntu Desktop
Return a configuration value from the .accomplishments file
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.
>>> 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"}
>>> 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"}
Detect if we are currently publishing online or not. Returns True if we are or False if we are not.
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).
>>> 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'}
This function returns a path to the .trophy file related to given accomplishmentID. The trophy file may or may not exist.
>>> acc.get_trophy_path("ubuntu-community/registered-on-launchpad")
/home/cielak/.local/share/accomplishments/trophies/ubuntu-community/registered-on-launchpad.trophy
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.
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__.