~seb128/langpack-o-matic/import-extra-log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python

# this is part of langpack-o-matic, by Martin Pitt <martin.pitt@canonical.com>
#
# (C) 2010 Canonical Ltd.
#
# Remove packages from an obsolete distro release from the langpack PPA.
#
# Author: Martin Pitt <martin.pitt@canonical.com>

import sys

from launchpadlib.launchpad import Launchpad

if len(sys.argv) != 2:
    sys.stderr.write('Usage: %s <release>\n' % sys.argv[0])
    sys.exit(1)

release = sys.argv[1]

lp = Launchpad.login_with('langpack-o-matic', 'production')

ppa = lp.people['ubuntu-langpack'].getPPAByName(name='ppa')
series = lp.distributions['ubuntu'].getSeries(name_or_version=release)

for arch in ('i386', 'amd64', 'powerpc', 'armhf', 'armel'):
    try:
        das = series.getDistroArchSeries(archtag=arch)
    except Exception as e:
        print('Cannot get architecture %s: %s' % (arch, str(e)))
        continue
    for bpr in ppa.getPublishedBinaries(distro_arch_series=das, status='Published'):
        print('deleting %s %s (%s)' % (bpr.binary_package_name,
                bpr.binary_package_version, arch))
        bpr.requestDeletion()

for spr in ppa.getPublishedSources(distro_series=series, status='Published'):
    print('deleting %s %s' % (spr.source_package_name,
            spr.source_package_version))
    spr.requestDeletion()