~doctormo/python-snippets/lp-merge-request-example

« back to all changes in this revision

Viewing changes to launchpadlib/get_current_package_version.py

  • Committer: Jono Bacon
  • Date: 2010-01-12 18:38:28 UTC
  • mfrom: (12.1.1 launchpadlib)
  • Revision ID: jono@ubuntu.com-20100112183828-9wdutnsi2ohe38sk
Our first liblaunchpad examples! Thanks Markus!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# [SNIPPET_NAME: get current package version]
 
4
# [SNIPPET_CATEGORIES: launchpadlib]
 
5
# [SNIPPET_DESCRIPTION: get the latest package version of an ubuntu package]
 
6
# [SNIPPET_AUTHOR: Markus Korn <thekorn@gmx.de>]
 
7
# [SNIPPET_LICENSE: GPL]
 
8
 
 
9
# For more Examples see https://help.launchpad.net/API/Examples
 
10
 
 
11
from launchpadlib.launchpad import Launchpad, STAGING_SERVICE_ROOT
 
12
 
 
13
# connect ot the staging service of launchpad
 
14
launchpad = Launchpad.login_with("python-snippets", STAGING_SERVICE_ROOT)
 
15
# get the ubuntu object
 
16
ubuntu = launchpad.distributions["ubuntu"]
 
17
# look in the main archive and for the current development focus
 
18
archive = ubuntu.main_archive
 
19
series = ubuntu.current_series
 
20
# get a list of all publishec sources of apport in this archive
 
21
published_sources = archive.getPublishedSources(exact_match=True,
 
22
    source_name="apport", distro_series=series)
 
23
 
 
24
# this list is sorted by release date, newest first,
 
25
# the first object is the current one
 
26
print published_sources[0].source_package_version
 
27